Acessing modal pipe using bash (or python)
-
For context, I was trying to use the instructions from docs/voxl-vision-px4-nuttx-shell to interface with the newer
voxl-px4-shell
which uses the modal pipe architecture instead of raw pipes.Previously, you could do
echo "command" > /tmp/to_px4_shell
and read the response with
cat /tmp/from_px4_shell
Creating a pipe by echoing a name to
/run/mpa/vvpx4_shell
then echoing commands to that newly created pipe seems to work fine, but it seems there is no way to access the data without first setting up a callback.From libmodal, client.c,
static void* _helper_func(void* context) { ... if(is_simple_helper){ if(c[ch].simple_cb){ c[ch].simple_cb(ch, c[ch].buf, bytes_read, c[ch].cb_context_simple); } continue; } }
Am I missing some way to get this output without having to compile a new client program? Python bindings would also be very convenient for making a simple callback function, but I understand it would be less trivial for non-text data, especially if custom classes are supported.
-
We have a command line utility "voxl-px4-shell" which will should have the interactions that you want. If you call it without any args it will open up an interactive shell that lets you put commands through stdin, but you can also run it with an argument which puts that command to px4 and send the output to stdout such as:
-
The original thing I was trying to accomplish was getting logs from the PX4 to the voxl just using
cat
but this doesn't work because I can't redirect the output in interactive mode and in single command mode multiple characters match the terminating character so the stream is truncated.But really I'm more looking for a general method of interacting with the modal pipe architecture without needing to compile something. The ability to create a pipe without specifying a callback would Make quick scripting or even more complicated python scripts possible. Is there currently any plans to expand the extensibility around the mpa?
-
Hi Zach,
I just updated libmodal_pipe to 2.0.8 with a fix to cleanup the trailing characters from echoing a pipe name to the request pipe. Now you can run modal-hello-server in one window and see the output in another:
yocto:/run/mpa/hello$ echo "test" > request && cat test hello160hello161hello162hello163hello164hello165hello166
Let me know if this is along the right path. I have no immediate intention for making a python library.
Best,
James