Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
a9ded633
Commit
a9ded633
authored
10 years ago
by
Oleg Hahm
Browse files
Options
Downloads
Plain Diff
Merge pull request #1569 from OlegHahm/pyterm_timer
pyterm: adds timer function
parents
1db984a7
dce96763
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dist/tools/pyterm/pyterm
+25
-1
25 additions, 1 deletion
dist/tools/pyterm/pyterm
with
25 additions
and
1 deletion
dist/tools/pyterm/pyterm
+
25
−
1
View file @
a9ded633
...
@@ -403,11 +403,25 @@ class SerCmd(cmd.Cmd):
...
@@ -403,11 +403,25 @@ class SerCmd(cmd.Cmd):
sys
.
stderr
.
write
(
"
JSON regex with ID %s not found
"
%
line
)
sys
.
stderr
.
write
(
"
JSON regex with ID %s not found
"
%
line
)
def
do_PYTERM_init
(
self
,
line
):
def
do_PYTERM_init
(
self
,
line
):
"""
Pyterm command: Add a
n
startup command. (Only useful in
"""
Pyterm command: Add a startup command. (Only useful in
addition with /save).
addition with /save).
"""
"""
self
.
init_cmd
.
append
(
line
.
strip
())
self
.
init_cmd
.
append
(
line
.
strip
())
def
do_PYTERM_timer
(
self
,
line
):
"""
Pyterm command: Scheduler a timer.
"""
line
=
line
.
strip
()
argv
=
line
.
partition
(
'
'
)
if
(
len
(
argv
[
2
])
==
0
):
sys
.
stderr
.
write
(
"
Usage: /timer <interval> <command>
\n
"
)
return
interval
=
int
(
argv
[
0
])
cmd
=
argv
[
2
]
self
.
logger
.
info
(
"
Schedule %s to fire after %i seconds
"
%
(
cmd
,
interval
))
t
=
threading
.
Timer
(
interval
,
self
.
timer_handler
,
(
cmd
,))
t
.
start
()
def
load_config
(
self
):
def
load_config
(
self
):
"""
Internal function to laod configuration from file.
"""
Internal function to laod configuration from file.
"""
"""
...
@@ -445,6 +459,16 @@ class SerCmd(cmd.Cmd):
...
@@ -445,6 +459,16 @@ class SerCmd(cmd.Cmd):
if
opt
not
in
self
.
__dict__
:
if
opt
not
in
self
.
__dict__
:
self
.
__dict__
[
opt
]
=
self
.
config
.
get
(
sec
,
opt
)
self
.
__dict__
[
opt
]
=
self
.
config
.
get
(
sec
,
opt
)
def
timer_handler
(
self
,
line
):
"""
Handles a scheduled timer event.
Args:
line (str): the command line to be executed, when the timer
fires.
"""
self
.
logger
.
debug
(
"
Firing timer with %s
"
%
line
)
self
.
onecmd
(
self
.
precmd
(
line
+
'
\n
'
))
def
process_line
(
self
,
line
):
def
process_line
(
self
,
line
):
"""
Processes a valid line from node that should be printed and
"""
Processes a valid line from node that should be printed and
possibly forwarded.
possibly forwarded.
...
...
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