- if( WaitForColon() ) {
- fprintf(stderr, "Coke machine timed out\n");
- return -2; // -EMYBAD
- }
-
- // Ask the coke machine
- sprintf(tmp, "s%i\r\n", Item);
- write(giCoke_SerialFD, tmp, 4);
-
- ret = ReadLine(sizeof(tmp)-1, tmp);
- printf("ret = %i, tmp = '%s'\n", ret, tmp);
-
- if( ret <= 0 ) {
- fprintf(stderr, "Coke machine is not being chatty (read = %i)\n", ret);
- if( ret == -1 ) {
- perror("Coke Machine");
- }
- return -1;
- }
- ret = RunRegex(&gCoke_StatusRegex, tmp, sizeof(matches)/sizeof(matches[0]), matches, "Bad Response");
- if( ret ) {
- return -1;
- }
-
- tmp[ matches[3].rm_eo ] = '\0';
- status = &tmp[ matches[3].rm_so ];
-
- printf("Machine responded slot status '%s'\n", status);
-
- if( strcmp(status, "full") == 0 )