//0 - ready, >0 - busy, -1 - err/unknown
static volatile int mix_state;
+static volatile int last_pump;
+
static void mix(const char *recipe){
int idx;
int vol;
int sr;
s = recipe;
-
+ last_pump = 0;
while (!force_quit && s && *s){
fprintf (stderr, "#%s#\n", s);
idx = strtoul(s, &n, 10);
fprintf (stderr, "START PUMP: %d VOL %d\n", idx, vol);
if (0 != pump_add(idx)) break; //or continue?
+ last_pump = idx;
mgmt_start(vol);
pump_on(idx);
while (MGMT_CONTINUE == (sr = mgmt_stop()) && !force_quit) usleep(100);
else {
total += bread;
if ('\n' == buf[total - 1]){
- buf[total - 1] = 0;
+ memset (buf + total - 1, 0, sizeof buf - total);
fprintf (stderr, "%s\n", buf);
if (0 == strncmp((char *)buf, "MIX:", 4)) mix((char *)buf + 4);
if (0 == strncmp((char *)buf, "QUIT", 4)) res = -1;
DPRINT ("PID: %lX\n", dealer);
break;
case -1:
-
- write (as, "ERROR\n", 6);
+ if (!last_pump)
+ write (as, "ERROR\n", 6);
+ else {
+ char buf[256];
+ write (as, buf, sprintf (buf, "ERROR, LAST PUMP:%u\n", last_pump));
+ }
net_close (as);
break;
default: