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
Fixing serial handling
[tpg/opendispense2.git]
/
src
/
server
/
handler_coke.c
diff --git
a/src/server/handler_coke.c
b/src/server/handler_coke.c
index
3ab46c5
..
53cbd0f
100644
(file)
--- a/
src/server/handler_coke.c
+++ b/
src/server/handler_coke.c
@@
-37,10
+37,13
@@
regex_t gCoke_StatusRegex;
int Coke_InitHandler()
{
printf("connecting to coke machine...\n");
int Coke_InitHandler()
{
printf("connecting to coke machine...\n");
- giCoke_SerialFD = open(gsCoke_SerialPort, O_RDWR);
+ giCoke_SerialFD = open(gsCoke_SerialPort, O_RDWR
| O_NOCTTY | O_NONBLOCK
);
if( giCoke_SerialFD == -1 ) {
fprintf(stderr, "ERROR: Unable to open coke serial port ('%s')\n", gsCoke_SerialPort);
}
if( giCoke_SerialFD == -1 ) {
fprintf(stderr, "ERROR: Unable to open coke serial port ('%s')\n", gsCoke_SerialPort);
}
+
+ InitSerial(giCoke_SerialFD, 9600);
+
CompileRegex(&gCoke_StatusRegex, "^slot\\s+(\\d)\\s+([^:]+):([a-zA-Z]+)\\s*", REG_EXTENDED);
return 0;
}
CompileRegex(&gCoke_StatusRegex, "^slot\\s+(\\d)\\s+([^:]+):([a-zA-Z]+)\\s*", REG_EXTENDED);
return 0;
}
@@
-77,9
+80,9
@@
int Coke_CanDispense(int User, int Item)
printf("Machine responded slot status '%s'\n", status);
if( strcmp(status, "full") == 0 )
printf("Machine responded slot status '%s'\n", status);
if( strcmp(status, "full") == 0 )
- return
1
;
+ return
0
;
- return
0
;
+ return
1
;
}
/**
}
/**
UCC
git Repository :: git.ucc.asn.au