Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
moberg
Commits
27c1e10f
Commit
27c1e10f
authored
Apr 03, 2019
by
Anders Blomdell
Browse files
Improved error reporting
parent
ee9be737
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/example.py
0 → 100755
View file @
27c1e10f
#!/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
()
moberg_device.c
View file @
27c1e10f
...
...
@@ -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
++
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment