From 4b4dcb9edf60f41743c71c5576e7e8bc9c5d1027 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 12:45:32 -0500 Subject: [PATCH] Update main.c handling telem_string error --- main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 5e5d5472..01842dce 100644 --- a/main.c +++ b/main.c @@ -841,9 +841,12 @@ int main(int argc, char * argv[]) { } #endif FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); - printf("Writing telem_string.txt\n"); - fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); - fclose(fp); + if (fp != NULL) { + printf("Writing telem_string.txt\n"); + fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); + fclose(fp); + } else + printf("Error writing to telem_string.txt\n"); /**/ // sleep(1); // Delay 1 second