Commit 27c1e10f authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Improved error reporting

parent ee9be737
#!/usr/bin/python3
import moberg
def scan():
result = [[], [], [], [], []]
m = moberg.Moberg()
for i, f in enumerate([m.analog_in, m.analog_out,
m.digital_in, m.digital_out,
m.encoder_in]):
for j in range(0, 100):
try:
result[i].append((j, f(j)))
pass
except:
pass
pass
pass
return result
def main():
channels = scan()
for c in channels:
print(len(c))
pass
pass
if __name__ == '__main__':
main()
......@@ -151,16 +151,22 @@ static struct moberg_status map(
struct moberg_channel *channel)
{
struct moberg_status result = MOBERG_ERRNO(EINVAL);
if (device->range->kind != channel->kind) {
fprintf(stderr, "Mapping wrong kind of channel %d != %d\n",
device->range->kind, channel->kind);
return MOBERG_ERRNO(EINVAL);
}
if (device->range->min > device->range->max) {
fprintf(stderr, "Mapping outside range %d > %d\n",
device->range->min, device->range->max);
return MOBERG_ERRNO(ENOSPC);
}
result = add_channel(device, device->range->kind, device->range->min,
(union channel) { .channel=channel });
if (! OK(result)) {
fprintf(stderr, "Failed to add channel kind=%d, index=%d\n",
device->range->kind, device->range->min);
return result;
}
device->range->min++;
......
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