Skip to content

tvsio-demo rework #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "apps/tvs_io"]
path = apps/tvs_io
[submodule "apps/tvsio"]
path = apps/tvsio
url = [email protected]:nasa/tvsio.git
branch = master
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This is a sample Core Flight Software (cFS) project to demonstrate how [Trick Va

This project includes two very basic Trick simulations and one basic CFS app. One trick sim is a 'temperature' data producer the other is a consumer. The CFS app, called temp_mon, will monitor the 'temperature' data and send a reset command to reset the data counter. TVS-IO app connects to the Trick Variable Server of each sim, reading and writing values as defined by the \*.tvm files. TVS-IO is the messenger that allows the two trick sims to talk to the temp_mon CFS app.

TVS-IO is included as a submodule at [`apps/tvs_io`](apps)
TVS-IO is included as a submodule at [`apps/tvsio`](apps)

## Building
### CFS[^1]
Expand Down
3 changes: 2 additions & 1 deletion apps/inc/TempStructDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ typedef struct
{
char cfsHeader[16];
float temperature;
double speed;

} Struct_Temp;

typedef struct
{
char commandHeader[CFE_SB_CMD_HDR_SIZE];
char commandHeader[CFE_SB_CMD_HDR_SIZE]; // 16 bytes
uint8 reset_flag;

} Temp_Cmd;
Expand Down
1 change: 1 addition & 0 deletions apps/inc/rpodvsmStructDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct
{
char commandHeader[CFE_SB_CMD_HDR_SIZE];
float temperature;
float speed;

} RPOD_TEMP_CMD;

Expand Down
3 changes: 2 additions & 1 deletion apps/inc/tvm_files/rpodvsm_cmd.tvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"cfsStructureType":"RPOD_TEMP_CMD",
"cfsStructureFileName":"rpodvsmStructDef.h",
"members": [
{"trickVar":"rendezvous.temp_in.temp", "trickType":"double", "cfsVar":"temperature", "cfsType":"float"}
{"trickVar":"rendezvous.temp_in.temp", "trickType":"double", "cfsVar":"temperature", "cfsType":"float"},
{"trickVar":"rendezvous.temp_in.speed", "trickType":"double", "cfsVar":"speed", "cfsType":"double"}
],
"messageId":"0xBABF",
"commandCode":24,
Expand Down
3 changes: 2 additions & 1 deletion apps/inc/tvm_files/temp_tlm.tvm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"cfsStructureType":"Struct_Temp",
"cfsStructureFileName":"TempStructDef.h",
"members": [
{"trickVar":"dyn.temperature.temp", "trickType":"double", "cfsVar":"temperature", "cfsType":"float"}
{"trickVar":"dyn.temperature.temp", "trickType":"double", "cfsVar":"temperature", "cfsType":"float"},
{"trickVar":"dyn.temperature.speed", "trickType":"double", "cfsVar":"speed", "cfsType":"double"}
],
"messageId":"0x01DD",
"flowDirection":1
Expand Down
3 changes: 2 additions & 1 deletion apps/temp_mon/fsw/src/temp_mon_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void TEMP_MON_AppMain( void )
case STRUCT_TEMP_MID:
temp_tlm = (Struct_Temp*) pMsg;
if ( temp_tlm == NULL) continue;
OS_printf( "\e[32m***** TEMP_MON *****\e[39m Received MID 0x%04X, Temp %.2f\n",msgId,temp_tlm->temperature );
OS_printf( "\e[32m***** TEMP_MON *****\e[39m Received MID 0x%04X, Temp %.2f, Speed %.2lf\n",msgId,temp_tlm->temperature,temp_tlm->speed );

//Send reset command to tvsio to send to the sim
if ( temp_tlm->temperature > 10 && g_TEMP_MON_AppData.tempOutMsg.reset_flag == 0 ) {
Expand All @@ -101,6 +101,7 @@ void TEMP_MON_AppMain( void )
}

g_TEMP_MON_AppData.rpodTempMsg.temperature = temp_tlm->temperature;
g_TEMP_MON_AppData.rpodTempMsg.speed = (float)(-1 * temp_tlm->speed);
iStatus = CFE_SB_SendMsg((CFE_SB_MsgPtr_t)&g_TEMP_MON_AppData.rpodTempMsg);
OS_printf( "\e[32m***** TEMP_MON *****\e[39m Sending RPOD Temp CMD MID, status = %d\n",iStatus);

Expand Down
1 change: 1 addition & 0 deletions trick_sims/SIM_range/models/range/include/range.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef struct {
typedef struct {

double temp; /* degF Temperature */
double speed; /* m/s */

} TEMP ;

Expand Down
3 changes: 2 additions & 1 deletion trick_sims/SIM_range/models/range/src/range_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ int range_init( CONTROL* C, TEMP* T) {
C->range = 0.0;
C->range_rate = 0.0;

T->temp = 0.0;
T->temp = 0.0;
T->speed = 0.0;
return 0 ;
}
1 change: 1 addition & 0 deletions trick_sims/SIM_range/models/range/src/range_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ int range_process( CONTROL* C ) {
int temp_process( TEMP* T )
{
printf( "Received temp: %5.2f\n", T->temp );
printf( "Received speed: %5.2f\n", T->speed );
return 0;
}
1 change: 1 addition & 0 deletions trick_sims/SIM_temp/models/temp/include/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PURPOSE: (Do stuff)
typedef struct {

double temp; /* degF Temperature */
double speed; /* m/s */
unsigned int reset_flag;

} TEMP ;
Expand Down
1 change: 1 addition & 0 deletions trick_sims/SIM_temp/models/temp/src/temp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PURPOSE: (Set the initial data values)
int temp_init( TEMP* T) {

T->temp = 0.0;
T->speed = 0.0;
T->reset_flag = 0;
return 0 ;
}
10 changes: 9 additions & 1 deletion trick_sims/SIM_temp/models/temp/src/temp_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ int temp_process( TEMP* T ) {
T->temp += 0.1;
if (T->temp > 100) {
T->temp = 0.0;
fprintf(stderr,"temp check\n");
fprintf(stderr, "temp check\n");
}

T->speed += 0.5;
if (T->speed > 30) {
T->speed = 0.0;
fprintf(stderr, "speed check\n");
}

if (T->reset_flag) {
fprintf(stderr,"temp reset\n");
T->temp = 0.0;
Expand All @@ -21,4 +28,5 @@ int temp_process( TEMP* T ) {
void temp_display( TEMP* T )
{
printf("Temp: %.1f\n", T->temp );
printf("Speed: %.1f\n", T->speed );
}
2 changes: 1 addition & 1 deletion tvsio_defs/targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ SET(TGT1_SYSTEM i686-pc-linux-gnu)
SET(TGT1_APPLIST
sch
sbn
tvs_io
tvsio
temp_mon)
SET(TGT1_FILELIST
cfe_es_startup.scr
Expand Down