Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
efc49c55
Commit
efc49c55
authored
Oct 30, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Improve CAN print function.
parent
6a15ac80
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
stmhal/can.c
+4
-3
4 additions, 3 deletions
stmhal/can.c
tests/pyb/can.py
+5
-4
5 additions, 4 deletions
tests/pyb/can.py
tests/pyb/can.py.exp
+3
-3
3 additions, 3 deletions
tests/pyb/can.py.exp
with
12 additions
and
10 deletions
stmhal/can.c
+
4
−
3
View file @
efc49c55
...
...
@@ -144,7 +144,7 @@ STATIC void pyb_can_print(void (*print)(void *env, const char *fmt, ...), void *
if
(
!
self
->
is_enabled
)
{
print
(
env
,
"CAN(%u)"
,
self
->
can_id
);
}
else
{
print
(
env
,
"CAN(%u, "
,
self
->
can_id
);
print
(
env
,
"CAN(%u,
CAN.
"
,
self
->
can_id
);
qstr
mode
;
switch
(
self
->
can
.
Init
.
Mode
)
{
case
CAN_MODE_NORMAL
:
mode
=
MP_QSTR_NORMAL
;
break
;
...
...
@@ -152,7 +152,7 @@ STATIC void pyb_can_print(void (*print)(void *env, const char *fmt, ...), void *
case
CAN_MODE_SILENT
:
mode
=
MP_QSTR_SILENT
;
break
;
case
CAN_MODE_SILENT_LOOPBACK
:
default
:
mode
=
MP_QSTR_SILENT_LOOPBACK
;
break
;
}
print
(
env
,
"%s, "
,
qstr_str
(
mode
));
print
(
env
,
"%s,
extframe=
"
,
qstr_str
(
mode
));
if
(
self
->
extframe
)
{
mode
=
MP_QSTR_True
;
}
else
{
...
...
@@ -162,7 +162,7 @@ STATIC void pyb_can_print(void (*print)(void *env, const char *fmt, ...), void *
}
}
/// \method init(mode, prescaler=100, *, sjw=1, bs1=6, bs2=8)
/// \method init(mode,
extframe=False,
prescaler=100, *, sjw=1, bs1=6, bs2=8)
///
/// Initialise the CAN bus with the given parameters:
///
...
...
@@ -184,6 +184,7 @@ STATIC mp_obj_t pyb_can_init_helper(pyb_can_obj_t *self, mp_uint_t n_args, const
mp_arg_parse_all
(
n_args
,
pos_args
,
kw_args
,
MP_ARRAY_SIZE
(
allowed_args
),
allowed_args
,
args
);
self
->
extframe
=
args
[
1
].
u_bool
;
// set the CAN configuration values
memset
(
&
self
->
can
,
0
,
sizeof
(
self
->
can
));
CAN_InitTypeDef
*
init
=
&
self
->
can
.
Init
;
...
...
This diff is collapsed.
Click to expand it.
tests/pyb/can.py
+
5
−
4
View file @
efc49c55
from
pyb
import
CAN
can
=
CAN
(
1
,
CAN
.
LOOPBACK
)
can
=
CAN
(
1
)
print
(
can
)
can
.
init
(
CAN
.
LOOPBACK
)
print
(
can
)
print
(
can
.
any
(
0
))
can
.
send
(
'
abcd
'
,
123
)
print
(
can
.
any
(
0
))
print
(
can
.
recv
(
0
))
...
...
@@ -37,6 +41,3 @@ else:
print
(
'
passed
'
)
else
:
print
(
'
failed, wrong data received
'
)
print
(
'
end
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/pyb/can.py.exp
+
3
−
3
View file @
efc49c55
CAN(1, LOOPBACK, False)
CAN(1)
CAN(1, CAN.LOOPBACK, extframe=False)
False
True
(123, 0, 0, b'abcd')
(2047, 0, 0, b'abcd')
(0, 0, 0, b'abcd')
passed
CAN(1, LOOPBACK, True)
CAN(1,
CAN.
LOOPBACK,
extframe=
True)
passed
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment