From 4aa8febd55aabdbd693365681a8c6da1d5203e3d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 31 Aug 2024 10:26:40 -0400 Subject: [PATCH] Update main.c check c2cStatus each time --- main.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index d031f500..3ecef964 100644 --- a/main.c +++ b/main.c @@ -81,7 +81,7 @@ int main(int argc, char * argv[]) { } FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r"); - if (command_file == NULL) { + if (command_file == NULL) { fprintf(stderr,"Command and control is OFF\n"); c2cStatus = 0; } else { @@ -94,7 +94,8 @@ int main(int argc, char * argv[]) { c2cStatus = 2; } } - printf("c2cStatus: %d", c2cStatus); + printf("c2cStatus: %d", c2cStatus); + char resbuffer[1000]; // const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//' | grep '9000'"; const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//'"; @@ -1567,7 +1568,28 @@ void get_tlm_fox() { (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; encodeA(b, 51 + head_offset, status); - printf("c2cStatus: %d \n", c2cStatus); + + FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r"); + if (command_file == NULL) { + if (c2cStatus != 0) { + fprintf(stderr,"Command and control is OFF\n"); + c2cStatus = 0; + } + } else { + command_file = fopen("/home/pi/CubeSatSim/command_control_direwolf", "r"); + if (command_file == NULL) { + if (c2cStatus != 1) { + fprintf(stderr,"Command and control Carrier (squelch) is ON\n"); + c2cStatus = 1; + } + } else { + if (c2cStatus != 2) { + fprintf(stderr,"Command and control DTMF or APRS is ON\n"); + c2cStatus = 2; + } + } + } + printf("c2cStatus: %d", c2cStatus); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); if (txAntennaDeployed == 0) {