X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fserver%2Fhandler_coke.c;h=fffa7b663d60f18bb09987a18a1aca4d56916671;hb=989710c614c291be681e272d96a0b65eb164232c;hp=79d0a4697b2bdb4218a43cf119bb7d2a6e84c26e;hpb=135e5ad4cc018ec05d1118e4d40be5c51db3f293;p=tpg%2Fopendispense2.git diff --git a/src/server/handler_coke.c b/src/server/handler_coke.c index 79d0a46..fffa7b6 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 1 +#define TRACE_COKE 0 #if TRACE_COKE # define TRACE(v...) do{printf("%s: ",__func__);printf(v);}while(0) @@ -73,20 +73,23 @@ int Coke_InitHandler() // Reset the slot names. // - Dunno why this is needed, but the machine plays silly // sometimes. - Writef("n0 Slot0\n"); + Writef("\r\n\r\n"); + WaitForColon(); + Writef("n0 Slot0\r\n"); if( !WaitForColon() ) { - Writef("n1 Slot1\n"); + Writef("n1 Slot1\r\n"); WaitForColon(); - Writef("n2 Slot2\n"); + Writef("n2 Slot2\r\n"); WaitForColon(); - Writef("n3 Slot3\n"); + Writef("n3 Slot3\r\n"); WaitForColon(); - Writef("n4 Slot4\n"); + Writef("n4 Slot4\r\n"); WaitForColon(); - Writef("n5 Slot5\n"); + Writef("n5 Slot5\r\n"); + WaitForColon(); + Writef("n6 Coke\r\n"); WaitForColon(); - Writef("n6 Coke\n"); Coke_int_UpdateSlotStatuses(); } @@ -185,7 +188,11 @@ int Coke_CanDispense(int UNUSED(User), int Item) // Can't dispense if the machine is not connected if( giCoke_SerialFD == -1 ) return -2; - + + // HACK! + // 2011-10-21: The sensors in slot 1 and 3 a bad, just ignore the sensor result + if( Item == 1 || Item == 3 ) return 0; + return gaCoke_CachedStatus[Item]; } @@ -303,7 +310,10 @@ char ReadChar() FD_SET(giCoke_SerialFD, &readfs); ret = select(giCoke_SerialFD+1, &readfs, NULL, NULL, &timeout); - if( ret == 0 ) return 0; // Timeout + if( ret == 0 ) { + fprintf(stderr, "ReadChar: Timeout of %is expired\n", READ_TIMEOUT); + return 0; // Timeout + } if( ret != 1 ) { printf("ReadChar: select return %i\n", ret); return 0;