Commit f238d407 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Handle more than 7 channels

parent 64da2a2f
......@@ -73,60 +73,48 @@ void *Reader(void *argument) {
// Currently unused
} break;
}
} else {
switch (channel) {
case 0:{ printf("I0=%3d ", value); } break;
case 1:{ printf("I1=%3d ", value); } break;
case 2:{ printf("I2=%3d ", value); } break;
case 3:{ printf("I3=%3d ", value); } break;
case 4:{ printf("I4=%3d ", value); } break;
case 5:{ printf("I5=%3d ", value); } break;
case 6:{ printf("I6=%3d ", value); } break;
case 31:{
int kind = (value>>5)& 0x7;
int cmd = (value>>8)& 0x3;
int conf_channel = value & 0x1f;
int *maxdata = 0;
switch(kind) {
case 1: {
printf("digital in ");
digital_in |= 1 << conf_channel;
} break;
case 2: {
printf("digital out ");
digital_out |= 1 << conf_channel;
} break;
case 3: {
printf("analog in ");
analog_in |= 1 << conf_channel;
maxdata = &maxdata_in[conf_channel];
} break;
case 4: {
printf("analog out ");
analog_out |= 1 << conf_channel;
maxdata = &maxdata_out[conf_channel];
} break;
case 5: {
printf("encoder in ");
encoder_in |= 1 << conf_channel;
maxdata = &maxdata_in[conf_channel];
} break;
}
printf("#%d ", conf_channel);
switch (cmd) {
case 0: {
printf("maxdata %d\n", (1<<(value>>10))-1);
if (maxdata) { *maxdata = (1<<(value>>10))-1; }
} break;
case 1: { printf("min %d\n", millivolts(value>>10)); } break;
case 2: { printf("max %d\n", millivolts(value>>10)); } break;
default: { printf("cmd %d %d\n", cmd, (value>>10)); } break;
}
} break;
default: {
printf("%d=%x (%d)\n", channel, value, length);
} break;
}
} else if (channel < 31) {
printf("I%d=%3d ", channel, value);
} else if (channel == 31) {
int kind = (value>>5)& 0x7;
int cmd = (value>>8)& 0x3;
int conf_channel = value & 0x1f;
int *maxdata = 0;
switch(kind) {
case 1: {
printf("digital in ");
digital_in |= 1 << conf_channel;
} break;
case 2: {
printf("digital out ");
digital_out |= 1 << conf_channel;
} break;
case 3: {
printf("analog in ");
analog_in |= 1 << conf_channel;
maxdata = &maxdata_in[conf_channel];
} break;
case 4: {
printf("analog out ");
analog_out |= 1 << conf_channel;
maxdata = &maxdata_out[conf_channel];
} break;
case 5: {
printf("encoder in ");
encoder_in |= 1 << conf_channel;
maxdata = &maxdata_in[conf_channel];
} break;
}
printf("#%d ", conf_channel);
switch (cmd) {
case 0: {
printf("maxdata %d\n", (1<<(value>>10))-1);
if (maxdata) { *maxdata = (1<<(value>>10))-1; }
} break;
case 1: { printf("min %d\n", millivolts(value>>10)); } break;
case 2: { printf("max %d\n", millivolts(value>>10)); } break;
default: { printf("cmd %d %d\n", cmd, (value>>10)); } break;
}
}
value = 0;
length = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment