X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fserver%2Fhandler_coke.c;h=79d0a4697b2bdb4218a43cf119bb7d2a6e84c26e;hb=135e5ad4cc018ec05d1118e4d40be5c51db3f293;hp=58e3b790be4fc6042158c24a076017a178e755bd;hpb=7d365dad3ca15281ead0d97d37d71fbba0e5d09f;p=tpg%2Fopendispense2.git diff --git a/src/server/handler_coke.c b/src/server/handler_coke.c index 58e3b79..79d0a46 100644 --- a/src/server/handler_coke.c +++ b/src/server/handler_coke.c @@ -21,7 +21,7 @@ #include #define READ_TIMEOUT 2 // 2 seconds for ReadChar -#define TRACE_COKE 0 +#define TRACE_COKE 1 #if TRACE_COKE # define TRACE(v...) do{printf("%s: ",__func__);printf(v);}while(0) @@ -60,7 +60,7 @@ int Coke_InitHandler() { CompileRegex(&gCoke_StatusRegex, "^slot\\s+([0-9]+)\\s+([^:]+):([a-zA-Z]+)\\s*", REG_EXTENDED); - printf("connecting to coke machine...\n"); + printf("Connecting to coke machine on '%s'\n", gsCoke_SerialPort); giCoke_SerialFD = InitSerial(gsCoke_SerialPort, 9600); if( giCoke_SerialFD == -1 ) { @@ -90,6 +90,8 @@ int Coke_InitHandler() Coke_int_UpdateSlotStatuses(); } + else + fprintf(stderr, "Coke machine timed out.\n"); } AddPeriodicFunction(Coke_int_UpdateSlotStatuses); @@ -154,7 +156,8 @@ void Coke_int_UpdateSlotStatuses(void) for( i = 0; i <= 6; i ++ ) { - len = ReadLine(sizeof tmp, tmp); + // Read until non-blank line + while( (len = ReadLine(sizeof tmp, tmp)) == 0 ) ; if( len == -1 ) { TRACE("Read failed on slot %i\n", i); goto ret; // I give up :(