+ // Check if user is in door
+ if( !(Bank_GetFlags(User) & USER_FLAG_DOORGROUP) )
+ {
+ #if DEBUG
+ printf("Door_CanDispense: User %i not in door\n", User);
+ #endif
+ return 1;
+ }
+
+ door_serial_handle = InitSerial(gsDoor_SerialPort, 1200);
+
+ if( write(door_serial_handle, "ATH1\n", 5) != 5 ) {
+ fprintf(stderr, "Unable to open door (sending ATH1)\n");
+ perror("Sending ATH1");
+ return -1;
+ }
+
+ // Wait before re-locking
+ sleep(DOOR_UNLOCKED_DELAY);
+
+ if( write(door_serial_handle, "ATH0\n", 5) != 5 ) {
+ fprintf(stderr, "Oh, hell! Door not re-locking, big error (sending ATH0 failed)\n");
+ perror("Sending ATH0");
+ return -1;
+ }
+
+ close(door_serial_handle);
+
+ #if DEBUG
+ printf("Door_DoDispense: User %i opened door\n", User);
+ #endif