-int Coke_CanDispense(int User, int Item)
-{
- char tmp[32], *status;
- regmatch_t matches[4];
- int ret;
-
- // Sanity please
- if( Item < 0 || Item > 6 ) return -1; // -EYOURBAD
-
- // Ask the coke machine
- sprintf(tmp, "s%i\n", Item);
- write(giCoke_SerialFD, tmp, 2);
-
- // Wait a little
- sleep(250);
-
- // Read the response
- 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;
+ // Open modbus
+ modbus_new_tcp(gsCoke_ModbusAddress, 502);
+ if( !gCoke_Modbus )
+ {
+ perror("coke - modbus_new_tcp");