Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
224fee0e
Commit
224fee0e
authored
Nov 15, 2014
by
Damien George
Browse files
stmhal: Fix HAL error raising; make test for it.
Addresses issue #968.
parent
aec189a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/mphal.c
View file @
224fee0e
...
...
@@ -16,5 +16,5 @@ const byte mp_hal_status_to_errno_table[4] = {
};
NORETURN
void
mp_hal_raise
(
HAL_StatusTypeDef
status
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
(
mp_obj_t
)(
mp_uint_t
)
mp_hal_status_to_errno_table
[
status
]));
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
mp_hal_status_to_errno_table
[
status
]))
)
;
}
tests/pyb/halerror.py
0 → 100644
View file @
224fee0e
# test hal errors
import
pyb
i2c
=
pyb
.
I2C
(
2
,
pyb
.
I2C
.
MASTER
)
try
:
i2c
.
recv
(
1
,
1
)
except
OSError
as
e
:
print
(
repr
(
e
))
can
=
pyb
.
CAN
(
1
,
pyb
.
CAN
.
NORMAL
)
try
:
can
.
send
(
'1'
,
1
,
timeout
=
50
)
except
OSError
as
e
:
print
(
repr
(
e
))
tests/pyb/halerror.py.exp
0 → 100644
View file @
224fee0e
OSError(5,)
OSError(116,)
Write
Preview
Markdown
is supported
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