Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
François Revol
firmware
Commits
a4c05d3f
Commit
a4c05d3f
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
feat(micropython): Print exceptions to the screen
parent
db8f0f82
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pycardium/mphalport.c
+73
-0
73 additions, 0 deletions
pycardium/mphalport.c
with
73 additions
and
0 deletions
pycardium/mphalport.c
+
73
−
0
View file @
a4c05d3f
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include
"py/mpprint.h"
#include
"py/mpprint.h"
#include
<stdint.h>
#include
<stdint.h>
#include
<stdbool.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<string.h>
#include
<string.h>
...
@@ -86,6 +87,68 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len)
...
@@ -86,6 +87,68 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len)
epic_uart_write_str
(
str
,
len
);
epic_uart_write_str
(
str
,
len
);
}
}
static
char
exception_lines
[
2
][
80
];
static
bool
exception
;
static
size_t
exception_line_index
;
static
void
exception_feed
(
char
c
)
{
if
(
c
==
'\n'
)
{
exception_lines
[
1
][
exception_line_index
]
=
0
;
if
(
exception_lines
[
1
][
0
]
==
' '
)
{
memcpy
(
exception_lines
[
0
],
exception_lines
[
1
],
sizeof
(
exception_lines
[
0
]));
exception_line_index
=
0
;
}
else
{
exception
=
false
;
epic_disp_open
();
epic_disp_clear
(
0
);
epic_disp_print_adv
(
1
,
0
,
0
,
"Exception:"
,
0xF800
,
0x0000
);
char
buf
=
exception_lines
[
0
][
26
];
exception_lines
[
0
][
26
]
=
0
;
epic_disp_print_adv
(
1
,
0
,
12
,
exception_lines
[
0
],
0xFFFF
,
0x0000
);
exception_lines
[
0
][
26
]
=
buf
;
if
(
strlen
(
exception_lines
[
0
])
>
26
)
{
epic_disp_print_adv
(
1
,
0
,
24
,
exception_lines
[
0
]
+
26
,
0xFFFF
,
0x0000
);
}
buf
=
exception_lines
[
1
][
26
];
exception_lines
[
1
][
26
]
=
0
;
epic_disp_print_adv
(
1
,
0
,
40
,
exception_lines
[
1
],
0xF800
,
0x0000
);
exception_lines
[
1
][
26
]
=
buf
;
if
(
strlen
(
exception_lines
[
1
])
>
26
)
{
epic_disp_print_adv
(
1
,
0
,
52
,
exception_lines
[
1
]
+
26
,
0xF800
,
0x0000
);
}
epic_disp_update
();
}
}
else
{
if
(
exception_line_index
<
sizeof
(
exception_lines
[
0
])
-
1
)
{
exception_lines
[
1
][
exception_line_index
++
]
=
c
;
}
}
}
/* Send a string, but replace \n with \n\r */
/* Send a string, but replace \n with \n\r */
void
mp_hal_stdout_tx_strn_cooked
(
const
char
*
str
,
size_t
len
)
void
mp_hal_stdout_tx_strn_cooked
(
const
char
*
str
,
size_t
len
)
{
{
...
@@ -93,6 +156,16 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len)
...
@@ -93,6 +156,16 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len)
* Only print one line at a time. Insert `\r` between lines so
* Only print one line at a time. Insert `\r` between lines so
* they are properly displayed on the serial console.
* they are properly displayed on the serial console.
*/
*/
if
(
strncmp
(
str
,
"Traceback (most recent call last):
\n
"
,
len
)
==
0
)
{
exception
=
true
;
exception_line_index
=
0
;
}
else
if
(
exception
)
{
for
(
size_t
i
=
0
;
i
<
len
;
i
++
)
{
exception_feed
(
str
[
i
]);
}
}
size_t
i
,
last
=
0
;
size_t
i
,
last
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
str
[
i
]
==
'\n'
)
{
if
(
str
[
i
]
==
'\n'
)
{
...
...
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