From 6da665d3871a499528d77480d03dd7258b52d5e0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 8 Apr 2023 09:57:57 -0400 Subject: [PATCH] add telem file write --- main.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index ab285b52..a7c74239 100644 --- a/main.c +++ b/main.c @@ -18,7 +18,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + +FILE *telem_file; #include "main.h" @@ -120,6 +121,14 @@ int main(int argc, char * argv[]) { } } + // Open telemetry file with STEM Payload Data + telem_file = fopen("/home/pi/CubeSatSim/telem.txt", "a"); + if (telem_file == NULL) + printf("Error opening telem file\n"); + fclose(telem_file); + printf("Opened telem file\n"); + + // Open configuration file with callsign and reset count FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); if (config_file == NULL) { @@ -1079,6 +1088,20 @@ void get_tlm(void) { } else { // APRS using rpitx + if (payload == ON) { + telem_file = fopen("/home/pi/CubeSatSim/telem.txt", "a"); + printf("Writing payload string\n"); + time_t timeStamp; + time(&timeStamp); // get timestamp +// printf("Timestamp: %s\n", ctime(&timeStamp)); + + char timeStampNoNl[31]; + snprintf(timeStampNoNl, 30, "%.24s", ctime(&timeStamp)); + printf("TimeStamp: %s\n", timeStampNoNl); + fprintf(telem_file, "%s %s\n", timeStampNoNl, sensor_payload); // write telemetry string to telem.txt file + fclose(telem_file); + } + strcat(str, footer_str1); // strcat(str, call); strcat(str, footer_str);