git.ucc.asn.au
/
tpg
/
opendispense2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Misc changes - Fixed coke, shut up boot, fixed disabled users dispensing
[tpg/opendispense2.git]
/
src
/
server
/
handler_coke.c
diff --git
a/src/server/handler_coke.c
b/src/server/handler_coke.c
index
58e3b79
..
fb58f79
100644
(file)
--- a/
src/server/handler_coke.c
+++ b/
src/server/handler_coke.c
@@
-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 ) {
@@
-73,23
+73,26
@@
int Coke_InitHandler()
// Reset the slot names.
// - Dunno why this is needed, but the machine plays silly
// sometimes.
- Writef("n0 Slot0\n");
+ 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();
}
+ else
+ fprintf(stderr, "Coke machine timed out.\n");
}
AddPeriodicFunction(Coke_int_UpdateSlotStatuses);
@@
-154,7
+157,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 :(
UCC
git Repository :: git.ucc.asn.au