-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Welcome to the TVSIO app wiki.
Trick Variable Sever Input Output or TVS_IO (sometimes referred to as TVS-IO or TVSIO) is a group of NASA Core Flight System (cFS) to Trick Simulation interface software packages which integrate with the cFS System and/or the Trick Simulation Environment. This software allows bidirectional communication and translation between simulation variables and Flight Software (FSW) messages.
It is highly recommended for users to take the Trick tutorial and CFS 101 tutorial prior to digging into TVSIO. Pay special attention to the Trick Variable Server and the cFS Software Bus topics.
TVS_IO supports mapping between complex (composite) data type instances in CFS, to members of an arbitrary number of instances of Trick simulation data types. The user will capture this mapping in a Trick Variable Mapping (TVM) file, which is a JSON object file with some required and optional key-value pairs. The use of TVM files permits the application to stay generic, allowing developers to reuse and reconfigure TVS_IO by only modifying input files. One or more TVM files are ingested by a python script (TVM Compiler or tvmc.py), which generates code to marshal and un-marshal data for transport between CFS and Trick. The data is transferred in CFS using the CFS Software Bus Network and CCSDS message format; a connection is made with the Trick Variable Server to write the data to Trick.
In its current implementation, TVSIO uses malloc to allocate memory for data buffers and is not initializing the data. It is up to the user to make sure that data received by TVSIO from CFS or from Trick (and then sent the other direction), is not garbage. This behavior will be improved in the future. Note that data is sent by TVSIO if it has first received something to send. In theory garbage should not get sent by TVSIO, even for the first message.
For processing data from Trick to CFS (flowDirection 1): TVSIO spawns a child task to read from trick. This task continually attempts to read from the Trick Variable Server if the connection is available. If the connection is closed, it will attempt to reconnect every 3 seconds. Currently TVSIO uses the Trick Variable Server default data rate of 10 Hz
For processing data from CFS to Trick (flowDirection 2): TVSIO runs at 10 Hz and will read all messages destined for Trick in a single cycle. The data is packed in an individual buffer for each MID, and sent to the trick variable server as each is read. In other words, all data destined for Trick is processed in a single 10hz frame, but Trick will receive it in multiple packets as they are sent/processed.
See dedicated Trick Variable Mapping Compiler page
See Trick Variable Mapping Definition for detailed descriptions of tvm file formats
There are three ways to let TVSIO know how to connect to the trick variable server. In order of preference:
1. #define
the connection definition macros in the mission config file or other project level config file
The connection definition macros are:
-
TVS_NUM_SIM_CONN
- The integer number of sim connections TVSIO will connect to -
TVS_SERVER_IPS
- Array of trick server IP Addresses, array length should be equal to number of connections -
TVS_SERVER_PORTS
- Array of trick server ports, array length should be equal to number of connections
For example in TVSIO Demo's tvsio_mission_cfg.h we have
#define TVS_NUM_SIM_CONN 2
#define TVS_SERVER_IPS ((char const*[]) { "127.0.0.1", "127.0.0.1" })
#define TVS_SERVER_PORTS (int[]) {17000, 17001}
Here we have two connections to connect to two trick sims, the first is on 127.0.0.1:17000
and the second is 127.0.0.1:17001
When TVSIO is initialized, it will loop through TVS_NUM_SIM_CONN
number of connections and check for the existence of environment variables TVS_<n>_PORT
and TVS_<n>_HOST
, where <n>
is the zero-indexed connection number, before connecting to the trick variable server. If these environment variables exist, they will overwrite the TVS_SERVER_IPS
and TVS_SERVER_PORTS
connection definition macros.
For example, to overwrite the preferred method above, we could set
export TVS_0_HOST='127.0.0.1'
export TVS_0_PORT=17000
export TVS_1_HOST='127.0.0.1'
export TVS_1_PORT=17001
Note that there is no environment variable to get around a #define TVS_NUM_SIM_CONN
somewhere in the project
This isn't really a method but is worth noting that it is happening. In fsw/platform_inc/tvs_io_platform_cfg.h, default values are defined if they don't already exist. They can be modified for testing but can't (or shouldn't) be pushed. Alternatively you could modify your trick sims to use the default values, assuming you have the default number of connections
During make, the Trick Variable Mapping Compiler (tvmc.py) will parse your .tvm files and generate C code (tvs_io_generated.c and tvs_io_generated.h) which is then compiled into tvsio app.
To make sure this works properly you must either
- a). have the tvm files in the CFS mission apps directory under inc/tvm_files/ where it will be found automatically by the default make process
- e.g. apps/inc/tvm_files
- b.) Set the environment variable
TVM_FILE_DIR
to your directory containing the tvm files- e.g.
export TVM_FILE_DIR='my/custom/tvm/path'
- e.g.
I think the current preferred way to add an app to a CFS mission build list is to include it in the targets.cmake at the top level project definitions. For example in tvsio-demo we have
SET(TGT1_APPLIST
sch
sbn
tvs_io
temp_mon)
At this point you should be ready to start building TVSIO in your CFS Mission.
During make install
you should see some output from tvmc and typical build output for tvsio app
- TVS-IO Demo for a running CFS project that uses TVS-IO to communicate with two sims
- Build and run unit tests