run python scripts through a component

24 views
Skip to first unread message

sheershak agarwal

unread,
Jun 9, 2021, 11:01:54 PM6/9/21
to F´ Community Group
I want to run python scripts or functions from a F-Prime component. I was thinking of doing it exactly like gds, which means connecting fprime and python scripts using socketIp driver and flask. Is this a correct approach or there is an easier way to run python scripts using F-Prime components. (If yes, I also want to pass data between C++ and Python, so can I create external ports?) 

lestarch

unread,
Jun 10, 2021, 3:08:50 PM6/10/21
to F´ Community Group
I assume  python is install on the flight computer.  In this case there are several simplier options:

1. Call python script with FM_ShellCommand.  This can be used to delegate functionality to another shell process, python included.  It has limitations (command sizes, shell constraints) but would be quick.
2. Create a python wrapper component that has the C++ interface to F´ as a component, but delegates to calls to python using `os.system` to create the python process.

Your process would work to, but comes with a lot of other requirements: a socket to write between C++ and python, a flask server, API design, ect.  Since I assume the FSW (C++) and python are on the same system, you can investigate other more tradition methods for calling python from C++.

-Michael
Reply all
Reply to author
Forward
0 new messages