mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
riotctrl_ctrl: provide helper class for native reset
This commit is contained in:
parent
609c9ada34
commit
49ea453df9
0
dist/pythonlibs/riotctrl_ctrl/__init__.py
vendored
Normal file
0
dist/pythonlibs/riotctrl_ctrl/__init__.py
vendored
Normal file
30
dist/pythonlibs/riotctrl_ctrl/native.py
vendored
Normal file
30
dist/pythonlibs/riotctrl_ctrl/native.py
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2021 Freie Universität Berlin
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
import riotctrl.ctrl
|
||||
|
||||
import psutil
|
||||
|
||||
|
||||
class NativeRIOTCtrl(riotctrl.ctrl.RIOTCtrl):
|
||||
"""RIOTCtrl abstraction for a native node
|
||||
|
||||
This works exactly as a normal RIOTCtrl, with the exception that
|
||||
`DEBUG_ADAPTER_ID` is set in the environment to the PID of the `native`
|
||||
process, whenever a terminal is started. This allows for `reset()` to also
|
||||
work for a the `native` instance.
|
||||
"""
|
||||
def _set_debug_adapter_id(self, child):
|
||||
if child.name().endswith('.elf'):
|
||||
self.env['DEBUG_ADAPTER_ID'] = str(child.pid)
|
||||
return True
|
||||
return False
|
||||
|
||||
def start_term(self, *args, **kwargs):
|
||||
super().start_term(*args, **kwargs)
|
||||
for child in psutil.Process(pid=self._term_pid()).children():
|
||||
if self._set_debug_adapter_id(child):
|
||||
break
|
2
dist/pythonlibs/riotctrl_ctrl/requirements.txt
vendored
Normal file
2
dist/pythonlibs/riotctrl_ctrl/requirements.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
psutil
|
||||
riotctrl
|
Loading…
Reference in New Issue
Block a user