// == CODE ===
int Coke_InitHandler()
{
+ printf("connecting to coke machine...\n");
giCoke_SerialFD = open(gsCoke_SerialPort, O_RDWR);
+ if( giCoke_SerialFD == -1 ) {
+ fprintf(stderr, "ERROR: Unable to open coke serial port ('%s')\n", gsCoke_SerialPort);
+ }
regcomp(&gCoke_StatusRegex, "^slot\\s+(\\d)\\s+([^:]+):([a-zA-Z]+)\\s*", REG_EXTENDED);
return 0;
}
// === IMPORTS ===
extern tHandler gCoke_Handler;
+extern tHandler gSnack_Handler;
// === PROTOTYPES ===
void Load_Itemlist(void);
int giNumItems = 0;
tItem *gaItems = NULL;
tHandler gPseudo_Handler = {Name:"pseudo"};
-tHandler *gaHandlers[] = {&gPseudo_Handler, &gCoke_Handler};
+tHandler *gaHandlers[] = {&gPseudo_Handler, &gCoke_Handler, &gSnack_Handler};
int giNumHandlers = sizeof(gaHandlers)/sizeof(gaHandlers[0]);
char *gsItemListFile = DEFAULT_ITEM_FILE;
extern int giServer_Port;
extern char* gsItemListFile;
extern char* gsCoke_SerialPort;
+extern char* gsSnack_SerialPort;
// === GLOBALS ===
int giDebugLevel = 0;
if( strcmp(arg, "--itemsfile") == 0 ) {
gsItemListFile = argv[++i];
}
- if( strcmp(arg, "--cokeport") == 0 ) {
+ else if( strcmp(arg, "--cokeport") == 0 ) {
gsCoke_SerialPort = argv[++i];
}
+ else if( strcmp(arg, "--snackport") == 0 ) {
+ gsSnack_SerialPort = argv[++i];
+ }
else {
// Usage error?
}