mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
5e0c9b4bff
Since the native process is a child process of pyterm when called via make we need to dig deeper for riotctrl. This also means that we require pyserial to execute it.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# 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 `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():
|
|
for grandchild in child.children():
|
|
if self._set_debug_adapter_id(grandchild):
|
|
break
|