- read(giCoke_SerialFD, tmp, sizeof(tmp)-1);
- regexec(&gCoke_StatusRegex, tmp, sizeof(matches)/sizeof(matches[0]), matches, 0);
+ tmp[0] = '\0';
+ ret = read(giCoke_SerialFD, tmp, sizeof(tmp)-1);
+ //printf("ret = %i\n", ret);
+ if( ret <= 0 ) {
+ fprintf(stderr, "Coke machine is not being chatty (read = %i)\n", ret);
+ return -1;
+ }
+ ret = RunRegex(&gCoke_StatusRegex, tmp, sizeof(matches)/sizeof(matches[0]), matches, "Bad Response");
+ if( ret ) {
+ return -1;
+ }