- CompileRegex(&gCoke_StatusRegex, "^slot\\s+([0-9]+)\\s+([^:]+):([a-zA-Z]+)\\s*", REG_EXTENDED);
-
- printf("Connecting to coke machine on '%s'\n", gsCoke_SerialPort);
-
- giCoke_SerialFD = InitSerial(gsCoke_SerialPort, 9600);
- if( giCoke_SerialFD == -1 ) {
- fprintf(stderr, "ERROR: Unable to open coke serial port ('%s')\n", gsCoke_SerialPort);
- }
- else {
- int i;
- for( i = 0; i < 7; i ++ )
- gaCoke_CachedStatus[i] = -1;
- // Reset the slot names.
- // - Dunno why this is needed, but the machine plays silly
- // sometimes.
- Writef("\r\n\r\n");
- WaitForColon();
- Writef("n0 Slot0\r\n");
- if( !WaitForColon() )
- {
- Writef("n1 Slot1\r\n");
- WaitForColon();
- Writef("n2 Slot2\r\n");
- WaitForColon();
- Writef("n3 Slot3\r\n");
- WaitForColon();
- Writef("n4 Slot4\r\n");
- WaitForColon();
- Writef("n5 Slot5\r\n");
- WaitForColon();
- Writef("n6 Coke\r\n");
- WaitForColon();
-
- Coke_int_UpdateSlotStatuses();
- }
- else
- fprintf(stderr, "Coke machine timed out.\n");
- }
-
- AddPeriodicFunction(Coke_int_UpdateSlotStatuses);
-
- return 0;
-}
-
-int Coke_int_GetSlotStatus(char *Buffer, int Slot)
-{
- regmatch_t matches[4];
- int ret;
- char *status;
-
- // Parse status response
- ret = RunRegex(&gCoke_StatusRegex, Buffer, sizeof(matches)/sizeof(matches[0]), matches, "Bad Response");
- if( ret ) {
- return -1;
+ // Configuable dummy/blank mode (all dispenses succeed)
+ // TODO: Find a better way of handling missing/invalid options
+ if( Config_GetValueCount("coke_dummy_mode") > 0 )
+ {
+ gbCoke_DummyMode = Config_GetValue_Bool("coke_dummy_mode", 0);
+ if(gbCoke_DummyMode == -1) gbCoke_DummyMode = 0;