Skip to content
Snippets Groups Projects
Commit 27c1e10f authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Improved error reporting

parent ee9be737
No related branches found
No related tags found
No related merge requests found
#!/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()
......@@ -153,14 +153,20 @@ static struct moberg_status map(
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++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment