Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
non-destructive text 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
Show more breadcrumbs
badge fixer
non-destructive text micropython
Commits
964ae328
Commit
964ae328
authored
6 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
extmod/uos_dupterm: Add mp_uos_dupterm_poll to poll all dupterms.
parent
b7da67cd
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
extmod/misc.h
+1
-0
1 addition, 0 deletions
extmod/misc.h
extmod/uos_dupterm.c
+40
-1
40 additions, 1 deletion
extmod/uos_dupterm.c
with
41 additions
and
1 deletion
extmod/misc.h
+
1
−
0
View file @
964ae328
...
...
@@ -36,6 +36,7 @@ MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj);
#if MICROPY_PY_OS_DUPTERM
bool
mp_uos_dupterm_is_builtin_stream
(
mp_const_obj_t
stream
);
uintptr_t
mp_uos_dupterm_poll
(
uintptr_t
poll_flags
);
int
mp_uos_dupterm_rx_chr
(
void
);
void
mp_uos_dupterm_tx_strn
(
const
char
*
str
,
size_t
len
);
void
mp_uos_deactivate
(
size_t
dupterm_idx
,
const
char
*
msg
,
mp_obj_t
exc
);
...
...
This diff is collapsed.
Click to expand it.
extmod/uos_dupterm.c
+
40
−
1
View file @
964ae328
...
...
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2016 Paul Sokolovsky
* Copyright (c) 2017 Damien P. George
* Copyright (c) 2017
-2019
Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -53,6 +53,45 @@ void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) {
}
}
uintptr_t
mp_uos_dupterm_poll
(
uintptr_t
poll_flags
)
{
uintptr_t
poll_flags_out
=
0
;
for
(
size_t
idx
=
0
;
idx
<
MICROPY_PY_OS_DUPTERM
;
++
idx
)
{
mp_obj_t
s
=
MP_STATE_VM
(
dupterm_objs
[
idx
]);
if
(
s
==
MP_OBJ_NULL
)
{
continue
;
}
int
errcode
=
0
;
mp_uint_t
ret
=
0
;
const
mp_stream_p_t
*
stream_p
=
mp_get_stream
(
s
);
#if MICROPY_PY_UOS_DUPTERM_BUILTIN_STREAM
if
(
mp_uos_dupterm_is_builtin_stream
(
s
))
{
ret
=
stream_p
->
ioctl
(
s
,
MP_STREAM_POLL
,
poll_flags
,
&
errcode
);
}
else
#endif
{
nlr_buf_t
nlr
;
if
(
nlr_push
(
&
nlr
)
==
0
)
{
ret
=
stream_p
->
ioctl
(
s
,
MP_STREAM_POLL
,
poll_flags
,
&
errcode
);
nlr_pop
();
}
else
{
// Ignore error with ioctl
}
}
if
(
ret
!=
MP_STREAM_ERROR
)
{
poll_flags_out
|=
ret
;
if
(
poll_flags_out
==
poll_flags
)
{
// Finish early if all requested flags are set
break
;
}
}
}
return
poll_flags_out
;
}
int
mp_uos_dupterm_rx_chr
(
void
)
{
for
(
size_t
idx
=
0
;
idx
<
MICROPY_PY_OS_DUPTERM
;
++
idx
)
{
if
(
MP_STATE_VM
(
dupterm_objs
[
idx
])
==
MP_OBJ_NULL
)
{
...
...
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