From 874404c6d017f1b7d65282a5bf19e32bbf77218f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 24 Jan 2026 22:46:19 -0500 Subject: [PATCH] Update main.c fix telem_str.txt for SSTV mode --- main.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/main.c b/main.c index 4aaaf0ab..68f1cdde 100644 --- a/main.c +++ b/main.c @@ -1205,17 +1205,15 @@ int main(int argc, char * argv[]) { FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); if (fp != NULL) { - printf("Writing telem_string.txt v: %f v2: %f batteryVoltage: %f\n", voltage[map[BAT]], voltage[map[BAT2]], batteryVoltage); - if (batteryVoltage != 4.5) { - - if (failureMode != FAIL_I2C1) +// printf("Writing telem_string.txt v: %f v2: %f batteryVoltage: %f\n", voltage[map[BAT]], voltage[map[BAT2]], batteryVoltage); +] if (sim_mode || (failureMode != FAIL_NONE)) { if (voltage[map[BAT2]] == 0) - snprintf(tlm_str, 30, "BAT %.2f %.1f ", voltage[map[BAT]], current[map[BAT]]); + fprintf(fp, "BAT %.2f %.1f ", voltage[map[BAT]], current[map[BAT]]); else - snprintf(tlm_str, 30, "BAT %.2f %.1f ", voltage[map[BAT2]], current[map[BAT]] + current[map[BAT2]]); + fprintf(fp, "BAT %.2f %.1f ", voltage[map[BAT2]], current[map[BAT]] + current[map[BAT2]]); + } else { - fprintf(fp, "BAT %.2fV %.0fmA", 0.0, 0.0); - printf("Display battery voltage and current as zero since simulated I2C1 failure.\n"); + fprintf(fp, "BAT %.2fV %.0fmA", batteryVoltage, batteryCurrent); } // fprintf(fp, "BAT %.2fV %.0fmA", batteryVoltage, batteryCurrent); @@ -1226,19 +1224,6 @@ int main(int argc, char * argv[]) { fprintf(fp," S\n"); else fprintf(fp,"\n"); - } - else { - printf("Write simulted voltage and current to telem_string.txt\n"); - // fprintf(fp, "\n"); // don't show voltage and current if it isn't a sensor value - fprintf(fp, "BAT %.2fV %.0fmA", voltage[map[BAT]], current[map[BAT]]); // display simulated voltage and current - if (c2cStatus != DISABLED) - fprintf(fp," C"); - if (sim_mode || (failureMode != FAIL_NONE)) - fprintf(fp," S\n"); - else - fprintf(fp,"\n"); - - } fclose(fp); } else printf("Error writing to telem_string.txt\n");