Commit graph

33 commits

Author SHA1 Message Date
mattprost
cf0c6b5a13 mpm: Fix rpc process shared state and port argument positions
The rpc_server_process was spawning with its parameters reversed. The
calling function also had its parameters reversed, so this is
functionally the same. This change makes sure that the parameters are
aligned with the arguments throughout the callstack.

Signed-off-by: mattprost <matt.prost@ni.com>
2022-10-20 10:12:21 -05:00
Samuel O'Brien
00c306d5c4 sim: Integrate simulator into UHD
This commit adds a device::register_device which allows uhd to start up
a simulator when uhd is called with the arguments type=sim. Creating the
device object creates a subprocess using pybind and an embedded
interpreter, and destroying the object cleans up those subprocesses.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
c91cf54766 mpm: Fix more gevent errors on SIGTERM
Sometimes when running usrp_hwd.py in a terminal and then canceling it
with Ctrl+C, it prints a really large stacktrace into the terminal
resulting from an uncaught gevent BlockingSwitchOutError. This comes
from trying to block on Process#join inside a gevent signal handler.

This commit resolves this issue by simply triggering an event in the
signal handler which prompts a different non-daemon thread to join the
subprocesses and end the parent process.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-28 16:16:54 -05:00
Samuel O'Brien
97852aba23 mpm: Fix gevent errors on SIGTERM
Sometimes when running usrp_hwd.py in a terminal and then canceling it
with Ctrl+C, it prints a really large stacktrace into the terminal
resulting from an uncaught gevent BlockingSwitchOutError. It seems like
there was an attempt to catch this in usrp_hwd.py:kill_time(). This
try-except was surrounding a call to Process.join() which, to the best
of my knowledge, can't ever throw this exception.

Based on my troubleshooting, this error comes from the SIGTERM signal
handler of the RPC process. The handler (defined in
rpc_server.py:_rpc_server_process), is just a direct call to
RPCServer.stop(). When the server's backed is a thread pool, this call
may block when joining the thread pool, causing gevent to complain about
execution attempting to block in a signal handler.

This commit resolves this issue by simply triggering an event in the
signal handler which prompts a different thread to clean up the server
and end the process.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-24 15:26:36 -05:00
Martin Braun
a252a2f3d8 mpm: Fix various Pylint issues
No functional changes. Fixes for things that PyLint complains about, but
are safe to change anyway, as well as a minor improvement to a docstring
that referenced non-existant args.

This touches files that are mpm.conf-related.
2020-07-09 00:39:11 -07:00
Joerg Hofrichter
3c38411bb6 mpm: usrp_hwd: fix for gevent 1.4.0
Openembedded release warrior includes python3-gevent 1.4.0 which
leads to the following error when starting usrp-hwd.py:

ImportError: cannot import name 'BlockingSwitchOutError' from 'gevent.hub'

This commit fixes the issue.

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
2019-10-08 12:03:47 -07:00
Martin Braun
118e7a21bf mpm: n3xx: Init device on boot
Specify skip_boot_init=1 to not init during boot. This will increase
boot time for an N310, typically by around 15 seconds.
2018-07-18 17:55:50 -07:00
Martin Braun
a5b87ab7c4 mpm: cmake: Add git hash and version info to Python module
Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com>
2018-04-02 15:27:05 -07:00
Martin Braun
725debb964 mpm: Rename n310 to n3xx
This module (and class) are, in fact, used for all N3xx-derivates so
renaming it is the more correct thing to do.
2018-03-05 15:56:41 -08:00
Martin Braun
e9288a439c mpm: Update all license headers
- Fix typo in company name (missing 'a')
- Updated SPDX license identifier to version 3.0
2018-02-19 16:55:08 -08:00
Martin Braun
832cbe095a mpm: Use prefs API for periph manager
- Allow to set default args via config file
- Read them from prefs API
- override-db-pids uses the same APIs now ([overrides] section in
  config file, prefs API, and same dictionary as --default-args when
  used on the command line
2018-02-08 22:18:14 +01:00
Martin Braun
66d0257b2e mpm: Enable systemd watchdog and update it from MPM
- Updated systemd service file
- Added health status flag in shared data object
- Added thread in RPC process to update watchdog

Reviewed-by: Moritz Fischer <moritz.fischer@ettus.com>
2018-01-15 10:45:07 -08:00
Martin Braun
1889469efc mpm: usrp_hwd: Fix logging issue on default_args failure
Failure to provide valid default args no longer results in an
unexpected error.
Also fixed minor formatting issues (PyLint).
2018-01-11 14:50:12 -08:00
Martin Braun
0691c5ea75 mpm: Spawn periph manager inside the RPC process
Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com>
2018-01-10 17:29:49 -08:00
Martin Braun
8815098747 mpm: Harmonize all license header
Now uses SPDX headers everywhere.
2017-12-22 15:05:58 -08:00
Martin Braun
f357dee69c mpm: Return correct value for usrp_hwd.py --init-only
Before, it would always return success even if that failed.
2017-12-22 15:05:57 -08:00
Brent Stapleton
19cdfb4148 mpm: Reset periph manager on update
Upon updating certain components (the FPGA, for example), the
Peripheral Manager is restarted, and the overlay is reapplied. In order
to facilitate this, the RPC server intercepts and handles the
update_component function.

Tested on the RJ45 ethernet connection. It probably won't work as well
if the SFP connection goes down when the overlay is removed.
2017-12-22 15:05:57 -08:00
Martin Braun
6701025706 mpm: Let usrp_hwd.py --init-only show init status and duration
Reviewed-By: Brent Stapleton <brent.stapleton@ettus.com>
2017-12-22 15:05:07 -08:00
Brent Stapleton
23e1187538 mpm: discovery returns 'product' information
- Added 'product' information to N310
- MPM discovery checks for 'product' field
2017-12-22 15:05:06 -08:00
Martin Braun
eccd185efb mpm: Add configurable log levels 2017-12-22 15:05:05 -08:00
Martin Braun
16da5da375 mpm: Remove leading _ from _get_device_info()
Use @norpc instead. This fixes some linting issues.
2017-12-22 15:05:05 -08:00
Martin Braun
e25e52d9a8 mpm: Catch multiprocess exception on exit 2017-12-22 15:04:01 -08:00
Martin Braun
5f99240bd2 mpm: Made Python3 the default interpreter for all N3xx-related executables 2017-12-22 15:04:00 -08:00
Martin Braun
3c385a4587 mpm: discovery can now be bound to subnet 2017-12-22 15:03:59 -08:00
Martin Braun
40235b8c5a mpm/mpmd: Call init() during UHD session init, not on hwd spawn 2017-12-22 15:03:59 -08:00
Martin Braun
9dee6175da mpm: Moved device and dboard init/deinit to their own methods
Also cleaned up some cruft.
2017-12-22 15:03:53 -08:00
Martin Braun
13cd22e867 mpm: Added command line args to usrp_hwd.py 2017-12-22 15:03:53 -08:00
Martin Braun
2270a6b1a6 mpm: Fixed python import in discovery module 2017-12-22 15:03:53 -08:00
Martin Braun
0920bf97ea mpm: Fixed logging in exit case 2017-12-22 15:03:52 -08:00
Martin Braun
285f14392b mpm: Moved over to new logging infrastructure
Also currently hardcodes some settings.
2017-12-22 15:03:45 -08:00
Andrej Rode
6a12add156 mpm: mpm reorganization 2017-12-22 15:03:45 -08:00
Andrej Rode
8ac9014d5c mpm: CMake cleanup, Python code enhancements
- Send user defined data in ping
- Improve rpc_shell, add mpm_debug.py, fix tracebacks in multiprocessing
2017-12-22 15:03:44 -08:00
Martin Braun
1a4348038d Initial commit for N3xx development.
- Creates mpm/ subdirectory
- First pass at hardware daemon/MPM
- New code for LMK04828, AD9371
- spidev integration

Contributions by:

Martin Braun <martin.braun@ettus.com>
Derek Kozel <derek.kozel@ettus.com>
Mark Meserve <mark.meserve@ni.com>
Andrej Rode <andrej.rode@ettus.com>
2017-12-22 15:03:44 -08:00