Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
35e7d9c0
Commit
35e7d9c0
authored
Nov 01, 2015
by
Henrik Sölver
Committed by
Damien George
Nov 02, 2015
Browse files
stmhal/can: Fix a bug in filter handling.
Reported here:
http://forum.micropython.org/viewtopic.php?f=2&t=845
parent
06f70973
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/can.c
View file @
35e7d9c0
...
...
@@ -688,10 +688,10 @@ STATIC mp_obj_t pyb_can_setfilter(mp_uint_t n_args, const mp_obj_t *pos_args, mp
rtr_masks
[
1
]
=
mp_obj_get_int
(
rtr_flags
[
1
])
?
0x02
:
0
;
}
}
filter
.
FilterIdHigh
=
(
mp_obj_get_int
(
params
[
0
])
&
0xFF00
)
>>
13
;
filter
.
FilterIdLow
=
(((
mp_obj_get_int
(
params
[
0
])
&
0x00FF
)
<<
3
)
|
4
)
|
rtr_masks
[
0
];
filter
.
FilterMaskIdHigh
=
(
mp_obj_get_int
(
params
[
1
])
&
0xFF00
)
>>
13
;
filter
.
FilterMaskIdLow
=
(((
mp_obj_get_int
(
params
[
1
])
&
0x00FF
)
<<
3
)
|
4
)
|
rtr_masks
[
1
];
filter
.
FilterIdHigh
=
(
mp_obj_get_int
(
params
[
0
])
&
0x
1
FF
FE0
00
)
>>
13
;
filter
.
FilterIdLow
=
(((
mp_obj_get_int
(
params
[
0
])
&
0x00
001F
FF
)
<<
3
)
|
4
)
|
rtr_masks
[
0
];
filter
.
FilterMaskIdHigh
=
(
mp_obj_get_int
(
params
[
1
])
&
0x
1
FF
FE0
00
)
>>
13
;
filter
.
FilterMaskIdLow
=
(((
mp_obj_get_int
(
params
[
1
])
&
0x00
001F
FF
)
<<
3
)
|
4
)
|
rtr_masks
[
1
];
if
(
args
[
1
].
u_int
==
MASK32
)
{
filter
.
FilterMode
=
CAN_FILTERMODE_IDMASK
;
}
...
...
tests/pyb/can.py
View file @
35e7d9c0
...
...
@@ -58,6 +58,26 @@ else:
else
:
print
(
'failed, wrong data received'
)
# Test filters
for
n
in
[
0
,
8
,
16
,
24
]:
filter_id
=
0b00001000
<<
n
filter_mask
=
0b00011100
<<
n
id_ok
=
0b00001010
<<
n
id_fail
=
0b00011010
<<
n
can
.
clearfilter
(
0
)
can
.
setfilter
(
0
,
pyb
.
CAN
.
MASK32
,
0
,
(
filter_id
,
filter_mask
))
can
.
send
(
'ok'
,
id_ok
,
timeout
=
3
)
if
can
.
any
(
0
):
msg
=
can
.
recv
(
0
)
print
((
hex
(
filter_id
),
hex
(
filter_mask
),
hex
(
msg
[
0
]),
msg
[
3
]))
can
.
send
(
"fail"
,
id_fail
,
timeout
=
3
)
if
can
.
any
(
0
):
msg
=
can
.
recv
(
0
)
print
((
hex
(
filter_id
),
hex
(
filter_mask
),
hex
(
msg
[
0
]),
msg
[
3
]))
del
can
# Test RxCallbacks
...
...
tests/pyb/can.py.exp
View file @
35e7d9c0
...
...
@@ -16,6 +16,10 @@ True
passed
CAN(1, CAN.LOOPBACK, extframe=True)
passed
('0x8', '0x1c', '0xa', b'ok')
('0x800', '0x1c00', '0xa00', b'ok')
('0x80000', '0x1c0000', '0xa0000', b'ok')
('0x8000000', '0x1c000000', '0xa000000', b'ok')
cb0
pending
cb0
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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