From: John Hodge Date: Sat, 19 Feb 2011 07:30:31 +0000 (+0800) Subject: Debugging door X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=45a676d692c76885c7b0bfaf6bde158429a96a4e;p=tpg%2Fopendispense2.git Debugging door --- diff --git a/src/server/handler_door.c b/src/server/handler_door.c index 1341679..978c184 100644 --- a/src/server/handler_door.c +++ b/src/server/handler_door.c @@ -14,6 +14,8 @@ #include #include +#define DOOR_UNLOCKED_DELAY 10 // 10 seconds before it re-locks + // === IMPORTS === // === PROTOTYPES === @@ -34,12 +36,10 @@ char *gsDoor_Command; // == CODE === int Door_InitHandler(void) -{ -// printf("connecting to door...\n"); -// giDoor_SerialFD = open(gsDoor_SerialPort, O_RDWR); -// if( giDoor_SerialFD == -1 ) { -// fprintf(stderr, "ERROR: Unable to open coke serial port ('%s')\n", gsDoor_SerialPort); -// } +{ + gsDoor_Command = malloc(sizeof("llogin door -w ")+strlen(gsDoor_Password)); + sprintf(gsDoor_Command, "llogin door -w %s", gsDoor_Password); + return 0; } @@ -52,9 +52,6 @@ int Door_CanDispense(int User, int Item) if( !(Bank_GetFlags(User) & USER_FLAG_DOORGROUP) ) return 1; - - gsDoor_Command = malloc(sizeof("llogin door -w ")+strlen(gsDoor_Password)); - sprintf(gsDoor_Command, "llogin door -w %s", gsDoor_Password); return 0; } @@ -73,13 +70,15 @@ int Door_DoDispense(int User, int Item) return 1; // llogin or other - pipe = popen(gsDoor_Command, "w"); + //pipe = popen(gsDoor_Command, "w"); + pipe = popen("llogin door -w -", "w"); if( !pipe || pipe == (void*)-1 ) return -1; - fputs("ATH1F", pipe); - sleep(1); - fputs("ATH10", pipe); + fputs(gsDoor_Password, pipe); fputs("\n", pipe); + fputs("ATH1\n", pipe); + sleep(DOOR_UNLOCKED_DELAY); + fputs("ATH0\n", pipe); pclose(pipe);