From 2a9161bc9e5e28f54f467c426a21f0a85ff0f76c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 13:35:26 -0400 Subject: [PATCH 01/49] Create sensor_extension.c copied from payload_extension.cpp --- sensor_extension.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 sensor_extension.c diff --git a/sensor_extension.c b/sensor_extension.c new file mode 100644 index 00000000..5b8dd2ec --- /dev/null +++ b/sensor_extension.c @@ -0,0 +1,25 @@ +// Use this template for adding additional sensors +// see Payload_BME280_MPU6050_XS_Extended for an example + +// put your library includes here +#include "Arduino.h" + +// put your globals here + +// put your setup code here +void payload_setup() { + +// Serial.println("Starting new sensor!"); + +} + +// put your loop code here +// Very Important: only use print, not println!! +void payload_loop() { + +/* + Serial1.print(" NEW 0.0"); // send sensor data over serial to Pi Zero + Serial.print(" NEW 0.0"); // send sensor data over serial monitor for testing +*/ + +} From 13929eaddfac071db69372c006b9ac2a3f16f9a6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 13:37:49 -0400 Subject: [PATCH 02/49] Update sensor_extension.c function names to sensor --- sensor_extension.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sensor_extension.c b/sensor_extension.c index 5b8dd2ec..7172ea5f 100644 --- a/sensor_extension.c +++ b/sensor_extension.c @@ -2,24 +2,26 @@ // see Payload_BME280_MPU6050_XS_Extended for an example // put your library includes here -#include "Arduino.h" + // put your globals here // put your setup code here -void payload_setup() { +void sensor_setup() { -// Serial.println("Starting new sensor!"); + printf("Starting new sensor!"); } // put your loop code here // Very Important: only use print, not println!! -void payload_loop() { +void sensor_loop() { + + printf("Reading new sensor!"); /* - Serial1.print(" NEW 0.0"); // send sensor data over serial to Pi Zero - Serial.print(" NEW 0.0"); // send sensor data over serial monitor for testing + printf(" NEW 0.0"); // send sensor data over serial to Pi Zero + printf(" NEW 0.0"); // send sensor data over serial monitor for testing */ } From 943a979f7465a66615fcb67c0b95a4d6b3358f4a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 13:39:12 -0400 Subject: [PATCH 03/49] Update sensor_extension.c cleanup --- sensor_extension.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensor_extension.c b/sensor_extension.c index 7172ea5f..a53c6a3b 100644 --- a/sensor_extension.c +++ b/sensor_extension.c @@ -1,11 +1,12 @@ // Use this template for adding additional sensors -// see Payload_BME280_MPU6050_XS_Extended for an example +// see example ... // put your library includes here // put your globals here + // put your setup code here void sensor_setup() { From 077b1cff5e4c93b3b245c0a6ef4ce5be1774eb80 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 13:40:34 -0400 Subject: [PATCH 04/49] Update main.h add sensor_setup and loop declarations --- main.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.h b/main.h index 0f990ea5..f7822513 100644 --- a/main.h +++ b/main.h @@ -241,6 +241,8 @@ int groundCommandCount = 0; int m_ileaver_index; /* Byte counter for interleaver */ unsigned char m_conv_sr; /* Convolutional encoder shift register state */ +void sensor_setup(); // defined in sensor_extension.c +void sensor_loop(); // defined in sensor_extension.c // from funcubeLib/common/fecConstants.h From 8093f65a09dddb8a30d514af464e7734232181e2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 14:07:59 -0400 Subject: [PATCH 05/49] Update main.c add sensor_setup and sensor_loop --- main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index be581eda..68099fa1 100644 --- a/main.c +++ b/main.c @@ -342,6 +342,8 @@ int main(int argc, char * argv[]) { fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno)); } + sensor_setup(); + if ((i2c_bus3 == OFF) || (sim_mode == TRUE)) { sim_mode = TRUE; @@ -645,8 +647,13 @@ int main(int argc, char * argv[]) { // printf("String: %s\n", buffer2); fflush(stdout); strcpy(sensor_payload, buffer2); + + printf(" Response from STEM Payload: %s\n", sensor_payload); + + sensor_loop(); + strcpy(sensor_payload, sensor_buffer); - printf(" Response from STEM Payload board: %s\n", sensor_payload); + printf(" Payload after new sensor read: %s\n", sensor_payload); telem_file = fopen("/home/pi/CubeSatSim/telem.txt", "a"); // printf("Writing payload string\n"); From f779da83bdb0d2eb0d32ad223b32df53f90b0900 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 14:10:13 -0400 Subject: [PATCH 06/49] Update Makefile add sensor_extension.c --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bf295216..a4f7030c 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ clean: rm -f libax5043.a rm -f */*.o rm -f */*/*.o - rm -f telem + rm -f libax5043.a: ax5043/crc/crc.o libax5043.a: ax5043/ax5043support/ax5043tx.o @@ -41,9 +41,10 @@ cubesatsim: libax5043.a cubesatsim: afsk/ax25.o cubesatsim: afsk/ax5043.o cubesatsim: TelemEncoding.o +cubesatsim: sensor_extension.c cubesatsim: main.o cubesatsim: codecAO40.o - gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o cubesatsim -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o TelemEncoding.o codecAO40.o main.o -lwiringPi -lax5043 -lm + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o cubesatsim -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o TelemEncoding.o sensor_extension.o codecAO40.o main.o -lwiringPi -lax5043 -lm telem: telem.o gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o telem -Wall -Wextra -L./ telem.o -lwiringPi @@ -52,6 +53,9 @@ TelemEncoding.o: TelemEncoding.c TelemEncoding.o: TelemEncoding.h gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c TelemEncoding.c +sensor_extension.o: sensor_extension.c + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c sensor_extension.c + codecAO40.o: codecAO40.c codecAO40.o: codecAO40.h gcc -std=gnu99 $(DEBUG_BEHAVIOR) -Wall -Wextra -c codecAO40.c From c2db0b2b7e42d8fe921b4d4eb40eea5cdef00089 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 16:16:35 -0400 Subject: [PATCH 07/49] Update main.h add NEW_SENSOR_FIELDS_MAX --- main.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.h b/main.h index f7822513..a4f0ac42 100644 --- a/main.h +++ b/main.h @@ -52,7 +52,8 @@ #define XS1 20 // NEW user defined token will be position 19 #define XS2 21 #define XS3 22 -#define SENSOR_FIELDS 26 +#define NEW_SENSOR_FIELDS_MAX 6 +#define SENSOR_FIELDS (26 + 6) #define FC_EPS 1 #define FC_BOB 25 #define FC_SW 50 From f76082be54f5a5447dabb6812176fdcc8da56f4f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 16:19:33 -0400 Subject: [PATCH 08/49] Update main.h add char *char *sensor_buffer --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index a4f0ac42..01293f93 100644 --- a/main.h +++ b/main.h @@ -243,7 +243,7 @@ int groundCommandCount = 0; unsigned char m_conv_sr; /* Convolutional encoder shift register state */ void sensor_setup(); // defined in sensor_extension.c -void sensor_loop(); // defined in sensor_extension.c +int sensor_loop(char *sensor_buffer); // defined in sensor_extension.c // from funcubeLib/common/fecConstants.h From 980b310b6431840775317cdacb7c9a2048e013e4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 16:23:28 -0400 Subject: [PATCH 09/49] Update sensor_extension.c add sensor_buffer and sensor count --- sensor_extension.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sensor_extension.c b/sensor_extension.c index a53c6a3b..63961b37 100644 --- a/sensor_extension.c +++ b/sensor_extension.c @@ -16,13 +16,17 @@ void sensor_setup() { // put your loop code here // Very Important: only use print, not println!! -void sensor_loop() { +int sensor_loop(char *sensor_buffer) { - printf("Reading new sensor!"); + int sensors = 3; // set to the number of sensor readings adding. + sensor_buffer[0] = 0; // make sure buffer is empty + + printf("Reading new sensors!\n"); + + strcpy(sensor_buffer, "NEW 0.0 0.0 0.0"); + + printf("New sensor string: %s\n", sensor_buffer); -/* - printf(" NEW 0.0"); // send sensor data over serial to Pi Zero - printf(" NEW 0.0"); // send sensor data over serial monitor for testing -*/ + return(sensors); } From 6de0ffa37e67791917f6aedaf79584cd0bd569f1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 16:42:47 -0400 Subject: [PATCH 10/49] Update main.c add sensor buffer and count --- main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 68099fa1..1d4b2ef0 100644 --- a/main.c +++ b/main.c @@ -650,11 +650,18 @@ int main(int argc, char * argv[]) { printf(" Response from STEM Payload: %s\n", sensor_payload); - sensor_loop(); - strcpy(sensor_payload, sensor_buffer); - - printf(" Payload after new sensor read: %s\n", sensor_payload); - + char sensor_buffer[30]; + int sensor_count; + sensor_buffer[0] = 0; + sensor_count = sensor_loop(sensor_buffer); + if (sensor_count > NEW_SENSOR_FIELDS_MAX) + sensor_count = NEW_SENSOR_FIELDS_MAX; + if (sensor_count > 0) { + char space[] = " "; + strcat(sensor_payload, space); + strcat(sensor_payload, sensor_buffer); + printf(" Payload after new sensor read: %s\n", sensor_payload); + } telem_file = fopen("/home/pi/CubeSatSim/telem.txt", "a"); // printf("Writing payload string\n"); time_t timeStamp; From 0ccccba831a29ea46625dd4272b8efc87ad1364b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 22 Aug 2025 10:24:40 -0400 Subject: [PATCH 11/49] Update Makefile fix typos --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a4f7030c..a2c69fcb 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ clean: rm -f libax5043.a rm -f */*.o rm -f */*/*.o - rm -f + rm -f telem libax5043.a: ax5043/crc/crc.o libax5043.a: ax5043/ax5043support/ax5043tx.o @@ -41,7 +41,7 @@ cubesatsim: libax5043.a cubesatsim: afsk/ax25.o cubesatsim: afsk/ax5043.o cubesatsim: TelemEncoding.o -cubesatsim: sensor_extension.c +cubesatsim: sensor_extension.o cubesatsim: main.o cubesatsim: codecAO40.o gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o cubesatsim -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o TelemEncoding.o sensor_extension.o codecAO40.o main.o -lwiringPi -lax5043 -lm From 85b7a23a6ec03112f3b1457817240831ac1ef75a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 24 Aug 2025 10:21:25 -0400 Subject: [PATCH 12/49] Update main.h add X Y Z --- main.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.h b/main.h index 01293f93..22d2c7d7 100644 --- a/main.h +++ b/main.h @@ -58,6 +58,9 @@ #define FC_BOB 25 #define FC_SW 50 #define FC_PAYLOAD 55 +#define X 0 +#define Y 1 +#define Z 2 #define RSSI 0 #define IHU_TEMP 2 From e6b8b6e8c4eaec0a7eebca1e0ebd35df013c883b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 24 Aug 2025 10:48:29 -0400 Subject: [PATCH 13/49] Update main.c change sim telem generation --- main.c | 70 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/main.c b/main.c index 1d4b2ef0..7c7ed8f7 100644 --- a/main.c +++ b/main.c @@ -352,27 +352,27 @@ int main(int argc, char * argv[]) { srand((unsigned int)time(0)); - axis[0] = rnd_float(-0.2, 0.2); - if (axis[0] == 0) - axis[0] = rnd_float(-0.2, 0.2); - axis[1] = rnd_float(-0.2, 0.2); - axis[2] = (rnd_float(-0.2, 0.2) > 0) ? 1.0 : -1.0; + axis[X] = rnd_float(-0.2, 0.2); + if (axis[X] == 0) + axis[X] = rnd_float(-0.2, 0.2); + axis[Y] = rnd_float(-0.2, 0.2); + axis[Z] = (rnd_float(-0.2, 0.2) > 0) ? 1.0 : -1.0; - angle[0] = (float) atan(axis[1] / axis[2]); - angle[1] = (float) atan(axis[2] / axis[0]); - angle[2] = (float) atan(axis[1] / axis[0]); + angle[X] = (float) atan(axis[Y] / axis[Z]); + angle[Y] = (float) atan(axis[Z] / axis[X]); + angle[Z] = (float) atan(axis[Y] / axis[X]); - volts_max[0] = rnd_float(4.5, 5.5) * (float) sin(angle[1]); - volts_max[1] = rnd_float(4.5, 5.5) * (float) cos(angle[0]); - volts_max[2] = rnd_float(4.5, 5.5) * (float) cos(angle[1] - angle[0]); + volts_max[X] = rnd_float(9.0, 12.0) * (float) sin(angle[Y]); + volts_max[Y] = rnd_float(9.0, 12.0) * (float) cos(angle[X]); + volts_max[Z] = rnd_float(9.0, 12.0) * (float) cos(angle[Y] - angle[X]); - float amps_avg = rnd_float(150, 300); + float amps_avg = rnd_float(150, 750); - amps_max[0] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) sin(angle[1]); - amps_max[1] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) cos(angle[0]); - amps_max[2] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) cos(angle[1] - angle[0]); + amps_max[X] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) sin(angle[Y]); + amps_max[Y] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) cos(angle[X]); + amps_max[Z] = (amps_avg + rnd_float(-25.0, 25.0)) * (float) cos(angle[Y] - angle[X]); - batt = rnd_float(3.8, 4.3); + batt = rnd_float(3.8, 4.1); speed = rnd_float(1.0, 2.5); eclipse = (rnd_float(-1, +4) > 0) ? 1.0 : 0.0; // eclipse = 1; @@ -382,7 +382,7 @@ int main(int argc, char * argv[]) { temp_min = rnd_float(10, 20); // #ifdef DEBUG_LOGGING - for (int i = 0; i < 3; i++) + for (int i = X; i <= Z; i++) printf("axis: %f angle: %f v: %f i: %f \n", axis[i], angle[i], volts_max[i], amps_max[i]); printf("batt: %f speed: %f eclipse_time: %f eclipse: %f period: %f temp: %f max: %f min: %f\n", batt, speed, eclipse_time, eclipse, period, tempS, temp_max, temp_min); // #endif @@ -813,15 +813,6 @@ int main(int argc, char * argv[]) { current[map[PLUS_Z]] = (Zi >= 0) ? Zi : 0; current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi); - voltage[map[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1); - voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1); - voltage[map[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1); - voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1); - voltage[map[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1); - voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1); - - printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); - tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0f) : ((temp_min - tempS) / 50.0f); tempS += +rnd_float(-1.0, 1.0); // IHUcpuTemp = (int)((tempS + rnd_float(-1.0, 1.0)) * 10 + 0.5); @@ -834,22 +825,39 @@ int main(int argc, char * argv[]) { // float charging = eclipse * (fabs(amps_max[0] * 0.707) + fabs(amps_max[1] * 0.707) + rnd_float(-4.0, 4.0)); // current[map[BAT]] = ((current[map[BAT2]] * voltage[map[BAT2]]) / batt) - charging; - current[map[BAT]] = rnd_float(285, 305) - charging; + current[map[BAT]] = rnd_float(320, 510) - charging; printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BAT2]], batt, voltage[map[BAT2]]); batt -= (batt > 3.5) ? current[map[BAT]] / 30000 : current[map[BAT]] / 3000; - if (batt < 3.0) { - batt = 3.0; + if (batt < 3.6) { + batt = 3.6; SafeMode = 1; printf("Safe Mode!\n"); } else SafeMode= 0; - if (batt > 4.5) - batt = 4.5; + if (batt > 4.1) + batt = 4.1; voltage[map[BAT]] = batt + rnd_float(-0.01, 0.01); + + float Vm, Vp; + Vm = batt + 0.5; + Vp = (Xv >= 1) ? Xv : rnd_float(0.0, 0.1); + voltage[map[PLUS_X]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); + Vp = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.0, 0.1); + voltage[map[MINUS_X]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); + Vp = (Yv >= 1) ? Yv : rnd_float(0.0, 0.1); + voltage[map[PLUS_Y]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); + Vp = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.0, 0.1); + voltage[map[MINUS_Y]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); + Vp = (Zv >= 1) ? Zv : rnd_float(0.0, 0.1); + voltage[map[PLUS_Z]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); + Vp = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.0, 0.1); + voltage[map[MINUS_Z]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); + + printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); // end of simulated telemetry } From 7971f2284da2f7f13828e300c4b0ead94d57a204 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 24 Aug 2025 12:47:40 -0400 Subject: [PATCH 14/49] Update main.h add atmosphere --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index 22d2c7d7..f8165a49 100644 --- a/main.h +++ b/main.h @@ -186,7 +186,7 @@ double cpuTemp; int frameTime; long int newGpsTime; -float axis[3], angle[3], volts_max[3], amps_max[3], batt, speed, period, tempS, temp_max, temp_min, eclipse; +float axis[3], angle[3], volts_max[3], amps_max[3], batt, speed, period, tempS, temp_max, temp_min, eclipse, atmosphere; int i2c_bus0 = OFF, i2c_bus1 = OFF, i2c_bus3 = OFF, camera = OFF, sim_mode = FALSE, SafeMode = FALSE; int rxAntennaDeployed = 0, txAntennaDeployed = 0, c2cStatus = 0; int sim_config = FALSE; // sim mode not set by configuration From 9b51f5c4226de77e4b2ad4f65d1ea01bbecabd04 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 24 Aug 2025 13:18:47 -0400 Subject: [PATCH 15/49] Update main.c add sim sensors --- main.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 7c7ed8f7..ae60035e 100644 --- a/main.c +++ b/main.c @@ -356,7 +356,9 @@ int main(int argc, char * argv[]) { if (axis[X] == 0) axis[X] = rnd_float(-0.2, 0.2); axis[Y] = rnd_float(-0.2, 0.2); - axis[Z] = (rnd_float(-0.2, 0.2) > 0) ? 1.0 : -1.0; + float axis_z; + axis_z = sqrt(1 - axis[X] * axis[X] - axis[Y] * axis[Y]); + axis[Z] = (rnd_float(-0.2, 0.2) > 0) ? axis_z : -1.0 * axis_z; angle[X] = (float) atan(axis[Y] / axis[Z]); angle[Y] = (float) atan(axis[Z] / axis[X]); @@ -375,6 +377,50 @@ int main(int argc, char * argv[]) { batt = rnd_float(3.8, 4.1); speed = rnd_float(1.0, 2.5); eclipse = (rnd_float(-1, +4) > 0) ? 1.0 : 0.0; + atmosphere = (rnd_float(-1, +4) > 0) ? 0.0 : 1.0; + + if (atmosphere == 0) { + sensor[PRES] = 0; + strcpy(sensor_string[PRES], "0.0"); + sensor[ALT] = 109343; + strcpy(sensor_string[ALT], "109343"); + sensor[HUMI] = 0; + strcpy(sensor_string[HUMI], "0.0"); + sensor[TEMP] = 0; + strcpy(sensor_string[TEMP], "0.0"); + } else { + sensor[PRES] = 1015; + strcpy(sensor_string[PRES], "1015"); + sensor[ALT] = 175; + strcpy(sensor_string[ALT], "175"); + sensor[HUMI] = 48; + strcpy(sensor_string[HUMI], "48"); + sensor[TEMP] = 27; + strcpy(sensor_string[TEMP], "27.0"); + } + char sensor_number[20]; + sensor[ACCEL_X] = AXIS[X]; + sprintf(sensor_number, "%7.2f", AXIS[X]); + strcpy(sensor_string[ACCEL_X], sensor_number); + sensor[ACCEL_Y] = AXIS[Y]; + sprintf(sensor_number, "%7.2f", AXIS[Y]); + strcpy(sensor_string[ACCEL_Y], sensor_number); + sensor[ACCEL_Z] = AXIS[Z]; + sprintf(sensor_number, "%7.2f", AXIS[Z]); + strcpy(sensor_string[ACCEL_Z], sensor_number); + + float spin; + spin = rnd_float(-30.0, 30.0); + sensor[GYRO_X] = AXIS[X] * spin; + sprintf(sensor_number, "%7.2f", sensor[GYRO_X]); + strcpy(sensor_string[ACCEL_X], sensor_number); + sensor[GYRO_Y] = AXIS[Y] * spin; + sprintf(sensor_number, "%7.2f", sensor[GYRO_Y]); + strcpy(sensor_string[ACCEL_Y], sensor_number); + sensor[GYRO_Z] = AXIS[Z] * spin; + sprintf(sensor_number, "%7.2f", sensor[GYRO_Z]); + strcpy(sensor_string[ACCEL_Z], sensor_number); + // eclipse = 1; period = rnd_float(150, 300); tempS = rnd_float(20, 55); @@ -684,7 +730,8 @@ int main(int argc, char * argv[]) { sensor_payload[0] = '\0'; // This will cause the payload to not be processed. printf("Simulated Payload Failure.\n"); } - + + if (!sim_mode) { if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { // printf("Valid Payload!\n"); @@ -705,6 +752,7 @@ int main(int argc, char * argv[]) { token = strtok(NULL, space); } } + printf("\n"); // if (sensor[GPS1] != 0) { @@ -723,9 +771,10 @@ int main(int argc, char * argv[]) { newGpsTime = millis(); } } - } - else - ; //payload = OFF; // turn off since STEM Payload is not responding + } + } +// else +// ; //payload = OFF; // turn off since STEM Payload is not responding if ((millis() - newGpsTime) > 60000) { longitude += rnd_float(-0.05, 0.05) / 100.0; // was .05 @@ -763,7 +812,7 @@ int main(int argc, char * argv[]) { printf("Simulated MPU Failure!\n"); } - if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU)) // recreaate sensor_payload string + if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU) || sim_mode) // recreaate sensor_payload string { sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { @@ -860,8 +909,8 @@ int main(int argc, char * argv[]) { printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); // end of simulated telemetry - } - + } + FILE * cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); if (cpuTempSensor) { // double cpuTemp; From 21b573d11c50ec9aafbb07cfd77b473fb6420285 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 24 Aug 2025 15:50:51 -0400 Subject: [PATCH 16/49] Update main.c fixed sim voltages --- main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index ae60035e..80706fd3 100644 --- a/main.c +++ b/main.c @@ -893,18 +893,18 @@ int main(int argc, char * argv[]) { float Vm, Vp; Vm = batt + 0.5; - Vp = (Xv >= 1) ? Xv : rnd_float(0.0, 0.1); - voltage[map[PLUS_X]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); - Vp = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.0, 0.1); - voltage[map[MINUS_X]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); - Vp = (Yv >= 1) ? Yv : rnd_float(0.0, 0.1); - voltage[map[PLUS_Y]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); - Vp = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.0, 0.1); - voltage[map[MINUS_Y]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); - Vp = (Zv >= 1) ? Zv : rnd_float(0.0, 0.1); - voltage[map[PLUS_Z]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); - Vp = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.0, 0.1); - voltage[map[MINUS_Z]] = (Vp >= Vm) ? Vp : (Vm + rnd_float(-0.1, 0.1)); + Vp = (Xv > 0) ? Xv : rnd_float(0.0, 0.1); + voltage[map[PLUS_X]] = (Vp >= Vm) ? (Vm + rnd_float(-0.1, 0.1)) : Vp; + Vp = (Xv < 0) ? ((-1.0f) * Xv) : rnd_float(0.0, 0.1); + voltage[map[MINUS_X]] = (Vp >= Vm) ? (Vm + rnd_float(-0.1, 0.1)) : Vp; + Vp = (Yv > 0) ? Yv : rnd_float(0.0, 0.1); + voltage[map[PLUS_Y]] = (Vp >= Vm) ? (Vm + rnd_float(-0.1, 0.1)) : Vp; + Vp = (Yv < 0) ? ((-1.0f) * Yv) : rnd_float(0.0, 0.1); + voltage[map[MINUS_Y]] = (Vp >= Vm) ? (Vm + rnd_float(-0.1, 0.1)) : Vp; + Vp = (Zv > 0) ? Zv : rnd_float(0.0, 0.1); + voltage[map[PLUS_Z]] = (Vp >= Vm) ? (Vm + rnd_float(-0.1, 0.1)) : Vp; + Vp = (Zv < 0) ? ((-1.0f) * Zv) : rnd_float(0.0, 0.1); + voltage[map[MINUS_Z]] = (Vp >= Vm) ? (Vm + rnd_float(-0.1, 0.1)) : Vp; printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); From 0f041314d3add626eaf8eaf54fa6d82e0ac8ad45 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 26 Aug 2025 09:25:56 -0400 Subject: [PATCH 17/49] Update sensor_extension.c missing libs --- sensor_extension.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensor_extension.c b/sensor_extension.c index 63961b37..b506cb78 100644 --- a/sensor_extension.c +++ b/sensor_extension.c @@ -2,7 +2,8 @@ // see example ... // put your library includes here - +#include +#include // put your globals here From a65d574884647632a545c00e06348328ac924007 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 26 Aug 2025 09:26:33 -0400 Subject: [PATCH 18/49] Update main.c fix axis --- main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index 80706fd3..b827a3da 100644 --- a/main.c +++ b/main.c @@ -399,25 +399,25 @@ int main(int argc, char * argv[]) { strcpy(sensor_string[TEMP], "27.0"); } char sensor_number[20]; - sensor[ACCEL_X] = AXIS[X]; - sprintf(sensor_number, "%7.2f", AXIS[X]); + sensor[ACCEL_X] = axis[X]; + sprintf(sensor_number, "%7.2f", axis[X]); strcpy(sensor_string[ACCEL_X], sensor_number); - sensor[ACCEL_Y] = AXIS[Y]; - sprintf(sensor_number, "%7.2f", AXIS[Y]); + sensor[ACCEL_Y] = axis[Y]; + sprintf(sensor_number, "%7.2f", axis[Y]); strcpy(sensor_string[ACCEL_Y], sensor_number); - sensor[ACCEL_Z] = AXIS[Z]; - sprintf(sensor_number, "%7.2f", AXIS[Z]); + sensor[ACCEL_Z] = axis[Z]; + sprintf(sensor_number, "%7.2f", axis[Z]); strcpy(sensor_string[ACCEL_Z], sensor_number); float spin; spin = rnd_float(-30.0, 30.0); - sensor[GYRO_X] = AXIS[X] * spin; + sensor[GYRO_X] = axis[X] * spin; sprintf(sensor_number, "%7.2f", sensor[GYRO_X]); strcpy(sensor_string[ACCEL_X], sensor_number); - sensor[GYRO_Y] = AXIS[Y] * spin; + sensor[GYRO_Y] = axis[Y] * spin; sprintf(sensor_number, "%7.2f", sensor[GYRO_Y]); strcpy(sensor_string[ACCEL_Y], sensor_number); - sensor[GYRO_Z] = AXIS[Z] * spin; + sensor[GYRO_Z] = axis[Z] * spin; sprintf(sensor_number, "%7.2f", sensor[GYRO_Z]); strcpy(sensor_string[ACCEL_Z], sensor_number); From e4d5c45f10ba02f70878c7b74bd6701271967c85 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 26 Aug 2025 09:45:58 -0400 Subject: [PATCH 19/49] Update main.c print sim sensor --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index b827a3da..e4eb4019 100644 --- a/main.c +++ b/main.c @@ -419,7 +419,9 @@ int main(int argc, char * argv[]) { strcpy(sensor_string[ACCEL_Y], sensor_number); sensor[GYRO_Z] = axis[Z] * spin; sprintf(sensor_number, "%7.2f", sensor[GYRO_Z]); - strcpy(sensor_string[ACCEL_Z], sensor_number); + strcpy(sensor_string[GYRO_Z], sensor_number); + + printf("sim sensor: %s\n", sensor_string[GYRO_Z]); // eclipse = 1; period = rnd_float(150, 300); From a8da9b358f46cbc40f6d5c6db73d040df6753e9b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 26 Aug 2025 22:11:33 -0400 Subject: [PATCH 20/49] Update main.c batt changes by 1/10 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index e4eb4019..2b4f44e5 100644 --- a/main.c +++ b/main.c @@ -880,7 +880,7 @@ int main(int argc, char * argv[]) { printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BAT2]], batt, voltage[map[BAT2]]); - batt -= (batt > 3.5) ? current[map[BAT]] / 30000 : current[map[BAT]] / 3000; + batt -= (batt > 3.5) ? current[map[BAT]] / 300000 : current[map[BAT]] / 30000; if (batt < 3.6) { batt = 3.6; SafeMode = 1; From a38e225c83519e26bd8136c95c41a6834986a6f0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 26 Aug 2025 22:22:10 -0400 Subject: [PATCH 21/49] Update main.c remove print --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 2b4f44e5..8fe20393 100644 --- a/main.c +++ b/main.c @@ -421,7 +421,7 @@ int main(int argc, char * argv[]) { sprintf(sensor_number, "%7.2f", sensor[GYRO_Z]); strcpy(sensor_string[GYRO_Z], sensor_number); - printf("sim sensor: %s\n", sensor_string[GYRO_Z]); +// printf("sim sensor: %s\n", sensor_string[GYRO_Z]); // eclipse = 1; period = rnd_float(150, 300); From 4349ae48c738d0bd5c68343aa1deb44718bcba96 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:06:41 -0400 Subject: [PATCH 22/49] Update main.c add back length print --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 8fe20393..a8dd440b 100644 --- a/main.c +++ b/main.c @@ -422,6 +422,7 @@ int main(int argc, char * argv[]) { strcpy(sensor_string[GYRO_Z], sensor_number); // printf("sim sensor: %s\n", sensor_string[GYRO_Z]); + printf("sim sensor value: %d length: %d\n", sensor[GYRO_Z], strlen(sensor_string[GYRO_Z])); // eclipse = 1; period = rnd_float(150, 300); From 6024b58c27e94b3c1a0d07e7e9f9ca2a165fcee4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:10:19 -0400 Subject: [PATCH 23/49] Update sensor_extension.c add \n --- sensor_extension.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor_extension.c b/sensor_extension.c index b506cb78..a0494350 100644 --- a/sensor_extension.c +++ b/sensor_extension.c @@ -11,7 +11,7 @@ // put your setup code here void sensor_setup() { - printf("Starting new sensor!"); + printf("Starting new sensor!\n"); } From 0788699386d0fabc679b42f52f9f9e08ebd2a8af Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:15:49 -0400 Subject: [PATCH 24/49] Update main.c print spin too --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index a8dd440b..cc3e73b1 100644 --- a/main.c +++ b/main.c @@ -422,7 +422,7 @@ int main(int argc, char * argv[]) { strcpy(sensor_string[GYRO_Z], sensor_number); // printf("sim sensor: %s\n", sensor_string[GYRO_Z]); - printf("sim sensor value: %d length: %d\n", sensor[GYRO_Z], strlen(sensor_string[GYRO_Z])); + printf("sim sensor spin: %f value: %f length: %d\n", spin, sensor[GYRO_Z], strlen(sensor_string[GYRO_Z])); // eclipse = 1; period = rnd_float(150, 300); From e22ac07b7163c661ed0a1f82e7ccfd91ca1e949d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:19:23 -0400 Subject: [PATCH 25/49] Update main.c add string --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index cc3e73b1..92cee3a9 100644 --- a/main.c +++ b/main.c @@ -422,7 +422,7 @@ int main(int argc, char * argv[]) { strcpy(sensor_string[GYRO_Z], sensor_number); // printf("sim sensor: %s\n", sensor_string[GYRO_Z]); - printf("sim sensor spin: %f value: %f length: %d\n", spin, sensor[GYRO_Z], strlen(sensor_string[GYRO_Z])); + printf("sim sensor spin: %f value: %f length: %d string: %s\n", spin, sensor[GYRO_Z], strlen(sensor_string[GYRO_Z]), sensor_string[GYRO_Z]); // eclipse = 1; period = rnd_float(150, 300); From 02925df573a5315833dd61c460e4fa10035cbff0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:26:59 -0400 Subject: [PATCH 26/49] Update main.c print new sensor string --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 92cee3a9..b5dd682e 100644 --- a/main.c +++ b/main.c @@ -822,7 +822,7 @@ int main(int argc, char * argv[]) { strcat(sensor_payload, sensor_string[count1]); strcat(sensor_payload, " "); } -// printf("New Sensor String: %s\n", sensor_payload); + printf("New Sensor String: %s\n", sensor_payload); } else if (failureMode != FAIL_PAYLOAD) strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation From 7b721f85fcb757c7f515466d4879f58296814682 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:34:45 -0400 Subject: [PATCH 27/49] Update main.c add sensor payload 0,1,2 set --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index b5dd682e..152e5e3b 100644 --- a/main.c +++ b/main.c @@ -817,7 +817,10 @@ int main(int argc, char * argv[]) { if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU) || sim_mode) // recreaate sensor_payload string { - sensor_payload[0] = 0; + sensor_payload[0] = "OK"; + sensor_payload[1] = "BME280"; + sensor_payload[6] = "MPU6050"; + for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { strcat(sensor_payload, sensor_string[count1]); strcat(sensor_payload, " "); From 6da3c74f58f790ec72796dc8bba5bf1bd00a50c8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:36:13 -0400 Subject: [PATCH 28/49] Update main.c use strcpy --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 152e5e3b..77619d5b 100644 --- a/main.c +++ b/main.c @@ -817,9 +817,9 @@ int main(int argc, char * argv[]) { if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU) || sim_mode) // recreaate sensor_payload string { - sensor_payload[0] = "OK"; - sensor_payload[1] = "BME280"; - sensor_payload[6] = "MPU6050"; + strcpy(sensor_payload[0], "OK"); + strcpy(sensor_payload[1], "BME280"); + strcpy(sensor_payload[6], "MPU6050"); for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { strcat(sensor_payload, sensor_string[count1]); From c1bd7d1c5e52f923a370e54f8e20e66370ed7c16 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:49:43 -0400 Subject: [PATCH 29/49] Update main.c change to sensor_string --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 77619d5b..209c2d80 100644 --- a/main.c +++ b/main.c @@ -817,9 +817,9 @@ int main(int argc, char * argv[]) { if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU) || sim_mode) // recreaate sensor_payload string { - strcpy(sensor_payload[0], "OK"); - strcpy(sensor_payload[1], "BME280"); - strcpy(sensor_payload[6], "MPU6050"); + strcpy(sensor_string[0], "OK"); + strcpy(sensor_string[1], "BME280"); + strcpy(sensor_string[6], "MPU6050"); for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { strcat(sensor_payload, sensor_string[count1]); From 173069ce1db9ccd49b79d7a268dadedcbce420f2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 10:56:23 -0400 Subject: [PATCH 30/49] Update main.c no sim failure print --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 209c2d80..b3a9856e 100644 --- a/main.c +++ b/main.c @@ -1335,7 +1335,7 @@ void get_tlm_fox() { buffSize = (int) sizeof(buffer_test); if (failureMode == FAIL_NONE) - printf("No Simulated Failure\n"); + printf("No Simulated Failure!\n"); // if (failureMode == -1) { // failureMode = (int) rnd_float(1, FAIL_COUNT); // printf("Random Failure\n"); From d4be3c8cb8ad951d8ab792d89fe5c2f360a45a62 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 13:17:42 -0400 Subject: [PATCH 31/49] Update update add unzip -u option --- update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update b/update index 2f72c779..722a8fcb 100755 --- a/update +++ b/update @@ -261,7 +261,7 @@ if [ ! -d "/home/pi/fctelem" ]; then mkdir /home/pi/fctelem/public_html cd fctelem wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip - unzip fctelem.zip + unzip -u fctelem.zip FLAG=1 elif [ ! -f "/home/pi/fctelem/v0.2" ]; then echo "Updating fctelem binary to version v0.2 for FUNcube mode" @@ -271,7 +271,7 @@ elif [ ! -f "/home/pi/fctelem/v0.2" ]; then sudo mv fcdecode.conf fcdecode.conf.bk sudo mv fctelem.zip fctelem.zip.1 wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip - unzip fctelem.zip + unzip -u fctelem.zip FLAG=1 fi From 5e7956c9adeba325ff530cd30dee18ebe0071a52 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 13:24:29 -0400 Subject: [PATCH 32/49] Update install add -u to unzip --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 4049706e..f722958b 100755 --- a/install +++ b/install @@ -123,7 +123,7 @@ mkdir /home/pi/fctelem mkdir /home/pi/fctelem/public_html cd fctelem wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip -unzip fctelem.zip +unzip -u fctelem.zip cd echo "Installing fcdctl to set FUNcubeDongle Pro gain" From c1e8383441bdf8324a38bd9d5db51fc32a7775b8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:03:30 -0400 Subject: [PATCH 33/49] Update main.h fail_bme wrong --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index f8165a49..e87ee936 100644 --- a/main.h +++ b/main.h @@ -136,7 +136,7 @@ FILE *image_file; #define FAIL_I2C3 6 #define FAIL_CAMERA 7 #define FAIL_PAYLOAD 8 -#define FAIL_BME 8 +#define FAIL_BME 9 #define FAIL_MPU 10 #define FAIL_AUDIO 11 int failureMode = FAIL_NONE; From 755edd2fa81ecc6c176c15cae8f9a874de045db8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:10:07 -0400 Subject: [PATCH 34/49] Update main.c add back sensor_payload clear --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index b3a9856e..dc1750fb 100644 --- a/main.c +++ b/main.c @@ -817,6 +817,7 @@ int main(int argc, char * argv[]) { if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU) || sim_mode) // recreaate sensor_payload string { + sensor_payload[0] = "\0"; strcpy(sensor_string[0], "OK"); strcpy(sensor_string[1], "BME280"); strcpy(sensor_string[6], "MPU6050"); From 3c37a522130da5f1dfc69e4d460ab6e159c31f8c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:11:06 -0400 Subject: [PATCH 35/49] Update main.c ' not ' --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index dc1750fb..60d3e535 100644 --- a/main.c +++ b/main.c @@ -817,7 +817,7 @@ int main(int argc, char * argv[]) { if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU) || sim_mode) // recreaate sensor_payload string { - sensor_payload[0] = "\0"; + sensor_payload[0] = '\0'; strcpy(sensor_string[0], "OK"); strcpy(sensor_string[1], "BME280"); strcpy(sensor_string[6], "MPU6050"); From ad2e1e3c713594d7bc4bf0aa20a895be87f8f420 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:15:08 -0400 Subject: [PATCH 36/49] Update main.c add gyro_x y --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 60d3e535..4637e45f 100644 --- a/main.c +++ b/main.c @@ -413,10 +413,10 @@ int main(int argc, char * argv[]) { spin = rnd_float(-30.0, 30.0); sensor[GYRO_X] = axis[X] * spin; sprintf(sensor_number, "%7.2f", sensor[GYRO_X]); - strcpy(sensor_string[ACCEL_X], sensor_number); + strcpy(sensor_string[GYRO_X], sensor_number); sensor[GYRO_Y] = axis[Y] * spin; sprintf(sensor_number, "%7.2f", sensor[GYRO_Y]); - strcpy(sensor_string[ACCEL_Y], sensor_number); + strcpy(sensor_string[GYRO_Y], sensor_number); sensor[GYRO_Z] = axis[Z] * spin; sprintf(sensor_number, "%7.2f", sensor[GYRO_Z]); strcpy(sensor_string[GYRO_Z], sensor_number); @@ -826,7 +826,7 @@ int main(int argc, char * argv[]) { strcat(sensor_payload, sensor_string[count1]); strcat(sensor_payload, " "); } - printf("New Sensor String: %s\n", sensor_payload); + printf("Updated Sensor String: %s\n", sensor_payload); } else if (failureMode != FAIL_PAYLOAD) strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation From cfea0c4b4a76e3b009e87426862d16aabf13f9ee Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:18:57 -0400 Subject: [PATCH 37/49] Update main.c just %.2f --- main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 4637e45f..5f6876e7 100644 --- a/main.c +++ b/main.c @@ -400,25 +400,25 @@ int main(int argc, char * argv[]) { } char sensor_number[20]; sensor[ACCEL_X] = axis[X]; - sprintf(sensor_number, "%7.2f", axis[X]); + sprintf(sensor_number, "%.2f", axis[X]); strcpy(sensor_string[ACCEL_X], sensor_number); sensor[ACCEL_Y] = axis[Y]; - sprintf(sensor_number, "%7.2f", axis[Y]); + sprintf(sensor_number, "%.2f", axis[Y]); strcpy(sensor_string[ACCEL_Y], sensor_number); sensor[ACCEL_Z] = axis[Z]; - sprintf(sensor_number, "%7.2f", axis[Z]); + sprintf(sensor_number, "%.2f", axis[Z]); strcpy(sensor_string[ACCEL_Z], sensor_number); float spin; spin = rnd_float(-30.0, 30.0); sensor[GYRO_X] = axis[X] * spin; - sprintf(sensor_number, "%7.2f", sensor[GYRO_X]); + sprintf(sensor_number, "%.2f", sensor[GYRO_X]); strcpy(sensor_string[GYRO_X], sensor_number); sensor[GYRO_Y] = axis[Y] * spin; - sprintf(sensor_number, "%7.2f", sensor[GYRO_Y]); + sprintf(sensor_number, "%.2f", sensor[GYRO_Y]); strcpy(sensor_string[GYRO_Y], sensor_number); sensor[GYRO_Z] = axis[Z] * spin; - sprintf(sensor_number, "%7.2f", sensor[GYRO_Z]); + sprintf(sensor_number, "%.2f", sensor[GYRO_Z]); strcpy(sensor_string[GYRO_Z], sensor_number); // printf("sim sensor: %s\n", sensor_string[GYRO_Z]); From 4b4efa99fc85247f1517491c653b056bf95d3904 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:22:17 -0400 Subject: [PATCH 38/49] Update main.c change space alt to 1000 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 5f6876e7..5acbedf9 100644 --- a/main.c +++ b/main.c @@ -383,7 +383,7 @@ int main(int argc, char * argv[]) { sensor[PRES] = 0; strcpy(sensor_string[PRES], "0.0"); sensor[ALT] = 109343; - strcpy(sensor_string[ALT], "109343"); + strcpy(sensor_string[ALT], "1000"); sensor[HUMI] = 0; strcpy(sensor_string[HUMI], "0.0"); sensor[TEMP] = 0; From 3142c2457cd725ef91f969cc80af1559a52314d8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:29:17 -0400 Subject: [PATCH 39/49] Update main.c add restore printf --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 5acbedf9..930207d2 100644 --- a/main.c +++ b/main.c @@ -828,8 +828,10 @@ int main(int argc, char * argv[]) { } printf("Updated Sensor String: %s\n", sensor_payload); } - else if (failureMode != FAIL_PAYLOAD) + else if (failureMode != FAIL_PAYLOAD) { + printf("Restoring sensor_payload\n"); strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation + } if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { // printf("Valid Payload!!\n"); From 253fbf8ae67c66db2a3e7377eca8f816727e9a32 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:36:28 -0400 Subject: [PATCH 40/49] Update main.c changed --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 930207d2..eaa54710 100644 --- a/main.c +++ b/main.c @@ -1483,7 +1483,7 @@ void get_tlm_fox() { else frm_type = 0x02; // BPSK always send MAX MIN frame } - sensor_payload[0] = 0; // clear for next payload +or sensor_payload[0] = 0; // clear for next payload // if (mode == FSK) { // remove this // } From 037448d3fbf8bc17676e62472a2f062c064fe381 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:37:21 -0400 Subject: [PATCH 41/49] Update main.c revert --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index eaa54710..930207d2 100644 --- a/main.c +++ b/main.c @@ -1483,7 +1483,7 @@ void get_tlm_fox() { else frm_type = 0x02; // BPSK always send MAX MIN frame } -or sensor_payload[0] = 0; // clear for next payload + sensor_payload[0] = 0; // clear for next payload // if (mode == FSK) { // remove this // } From 4421f5a9d150558e3c145b1b58c7f558635a4442 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 15:49:51 -0400 Subject: [PATCH 42/49] Update main.c don't clear sensor_payload in sim mode --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 930207d2..98ac3e55 100644 --- a/main.c +++ b/main.c @@ -594,8 +594,9 @@ int main(int argc, char * argv[]) { fflush(stdout); fflush(stderr); // frames_sent++; + if (!sim_mode) + sensor_payload[0] = '\0'; - sensor_payload[0] = 0; memset(voltage, 0, sizeof(voltage)); memset(current, 0, sizeof(current)); memset(sensor, 0, sizeof(sensor)); From 704ce85fda4e898a941b5a736db45ae057719ffc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 16:02:34 -0400 Subject: [PATCH 43/49] Update main.c print sensor[ALT] --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 98ac3e55..471c4230 100644 --- a/main.c +++ b/main.c @@ -1393,7 +1393,9 @@ void get_tlm_fox() { cam = OFF; printf("Camera Simulated Failure!\n"); } - + + printf("Sensor ALT: %f\n", sensor[ALT]); + if (mode == FSK) id = 7; else From 7956936154380e0e3c366e36186df55c8c6d0377 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 16:03:17 -0400 Subject: [PATCH 44/49] Update main.c sim no atmosphere 1000 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 471c4230..6c9c3eb9 100644 --- a/main.c +++ b/main.c @@ -382,7 +382,7 @@ int main(int argc, char * argv[]) { if (atmosphere == 0) { sensor[PRES] = 0; strcpy(sensor_string[PRES], "0.0"); - sensor[ALT] = 109343; + sensor[ALT] = 1000; strcpy(sensor_string[ALT], "1000"); sensor[HUMI] = 0; strcpy(sensor_string[HUMI], "0.0"); From 10daca87d47ebb5bea13ec67b06260f98ee9234d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 16:07:47 -0400 Subject: [PATCH 45/49] Update main.c don't clear sensor --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 6c9c3eb9..38e7c384 100644 --- a/main.c +++ b/main.c @@ -594,12 +594,13 @@ int main(int argc, char * argv[]) { fflush(stdout); fflush(stderr); // frames_sent++; - if (!sim_mode) + if (!sim_mode) { sensor_payload[0] = '\0'; + memset(sensor, 0, sizeof(sensor)); + } memset(voltage, 0, sizeof(voltage)); memset(current, 0, sizeof(current)); - memset(sensor, 0, sizeof(sensor)); memset(other, 0, sizeof(other)); FILE * uptime_file = fopen("/proc/uptime", "r"); From 53e506cae24b845c250ae0ddb833c707e6ab2754 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 16:16:07 -0400 Subject: [PATCH 46/49] Update main.c move sim_mode sensor --- main.c | 92 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/main.c b/main.c index 38e7c384..4dde1192 100644 --- a/main.c +++ b/main.c @@ -378,51 +378,6 @@ int main(int argc, char * argv[]) { speed = rnd_float(1.0, 2.5); eclipse = (rnd_float(-1, +4) > 0) ? 1.0 : 0.0; atmosphere = (rnd_float(-1, +4) > 0) ? 0.0 : 1.0; - - if (atmosphere == 0) { - sensor[PRES] = 0; - strcpy(sensor_string[PRES], "0.0"); - sensor[ALT] = 1000; - strcpy(sensor_string[ALT], "1000"); - sensor[HUMI] = 0; - strcpy(sensor_string[HUMI], "0.0"); - sensor[TEMP] = 0; - strcpy(sensor_string[TEMP], "0.0"); - } else { - sensor[PRES] = 1015; - strcpy(sensor_string[PRES], "1015"); - sensor[ALT] = 175; - strcpy(sensor_string[ALT], "175"); - sensor[HUMI] = 48; - strcpy(sensor_string[HUMI], "48"); - sensor[TEMP] = 27; - strcpy(sensor_string[TEMP], "27.0"); - } - char sensor_number[20]; - sensor[ACCEL_X] = axis[X]; - sprintf(sensor_number, "%.2f", axis[X]); - strcpy(sensor_string[ACCEL_X], sensor_number); - sensor[ACCEL_Y] = axis[Y]; - sprintf(sensor_number, "%.2f", axis[Y]); - strcpy(sensor_string[ACCEL_Y], sensor_number); - sensor[ACCEL_Z] = axis[Z]; - sprintf(sensor_number, "%.2f", axis[Z]); - strcpy(sensor_string[ACCEL_Z], sensor_number); - - float spin; - spin = rnd_float(-30.0, 30.0); - sensor[GYRO_X] = axis[X] * spin; - sprintf(sensor_number, "%.2f", sensor[GYRO_X]); - strcpy(sensor_string[GYRO_X], sensor_number); - sensor[GYRO_Y] = axis[Y] * spin; - sprintf(sensor_number, "%.2f", sensor[GYRO_Y]); - strcpy(sensor_string[GYRO_Y], sensor_number); - sensor[GYRO_Z] = axis[Z] * spin; - sprintf(sensor_number, "%.2f", sensor[GYRO_Z]); - strcpy(sensor_string[GYRO_Z], sensor_number); - -// printf("sim sensor: %s\n", sensor_string[GYRO_Z]); - printf("sim sensor spin: %f value: %f length: %d string: %s\n", spin, sensor[GYRO_Z], strlen(sensor_string[GYRO_Z]), sensor_string[GYRO_Z]); // eclipse = 1; period = rnd_float(150, 300); @@ -789,6 +744,53 @@ int main(int argc, char * argv[]) { newGpsTime = millis(); } + if (sim_mode) { + if (atmosphere == 0) { + sensor[PRES] = 0; + strcpy(sensor_string[PRES], "0.0"); + sensor[ALT] = 1000; + strcpy(sensor_string[ALT], "1000"); + sensor[HUMI] = 0; + strcpy(sensor_string[HUMI], "0.0"); + sensor[TEMP] = 0; + strcpy(sensor_string[TEMP], "0.0"); + } else { + sensor[PRES] = 1015; + strcpy(sensor_string[PRES], "1015"); + sensor[ALT] = 175; + strcpy(sensor_string[ALT], "175"); + sensor[HUMI] = 48; + strcpy(sensor_string[HUMI], "48"); + sensor[TEMP] = 27; + strcpy(sensor_string[TEMP], "27.0"); + } + char sensor_number[20]; + sensor[ACCEL_X] = axis[X]; + sprintf(sensor_number, "%.2f", axis[X]); + strcpy(sensor_string[ACCEL_X], sensor_number); + sensor[ACCEL_Y] = axis[Y]; + sprintf(sensor_number, "%.2f", axis[Y]); + strcpy(sensor_string[ACCEL_Y], sensor_number); + sensor[ACCEL_Z] = axis[Z]; + sprintf(sensor_number, "%.2f", axis[Z]); + strcpy(sensor_string[ACCEL_Z], sensor_number); + + float spin; + spin = rnd_float(-30.0, 30.0); + sensor[GYRO_X] = axis[X] * spin; + sprintf(sensor_number, "%.2f", sensor[GYRO_X]); + strcpy(sensor_string[GYRO_X], sensor_number); + sensor[GYRO_Y] = axis[Y] * spin; + sprintf(sensor_number, "%.2f", sensor[GYRO_Y]); + strcpy(sensor_string[GYRO_Y], sensor_number); + sensor[GYRO_Z] = axis[Z] * spin; + sprintf(sensor_number, "%.2f", sensor[GYRO_Z]); + strcpy(sensor_string[GYRO_Z], sensor_number); + + // printf("sim sensor: %s\n", sensor_string[GYRO_Z]); + printf("sim sensor spin: %f value: %f length: %d string: %s\n", spin, sensor[GYRO_Z], strlen(sensor_string[GYRO_Z]), sensor_string[GYRO_Z]); + } + if (failureMode == FAIL_BME) { sensor[TEMP] = 0.0; strcpy(sensor_string[TEMP], "0.0"); From d2f7400b81c5084ac68ba25b3f3c5c232f422c09 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 16:28:46 -0400 Subject: [PATCH 47/49] Update main.c always clear sensor and sensor payload --- main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 4dde1192..bf6832c7 100644 --- a/main.c +++ b/main.c @@ -549,10 +549,10 @@ int main(int argc, char * argv[]) { fflush(stdout); fflush(stderr); // frames_sent++; - if (!sim_mode) { +// if (!sim_mode) { sensor_payload[0] = '\0'; memset(sensor, 0, sizeof(sensor)); - } +// } memset(voltage, 0, sizeof(voltage)); memset(current, 0, sizeof(current)); @@ -1397,8 +1397,6 @@ void get_tlm_fox() { printf("Camera Simulated Failure!\n"); } - printf("Sensor ALT: %f\n", sensor[ALT]); - if (mode == FSK) id = 7; else From 55174c641f99edddcf1713e865f804d300bd9015 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 16:33:46 -0400 Subject: [PATCH 48/49] Update main.c change max altitude to 400 --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index bf6832c7..9a9d3def 100644 --- a/main.c +++ b/main.c @@ -748,8 +748,8 @@ int main(int argc, char * argv[]) { if (atmosphere == 0) { sensor[PRES] = 0; strcpy(sensor_string[PRES], "0.0"); - sensor[ALT] = 1000; - strcpy(sensor_string[ALT], "1000"); + sensor[ALT] = 400; + strcpy(sensor_string[ALT], "400"); sensor[HUMI] = 0; strcpy(sensor_string[HUMI], "0.0"); sensor[TEMP] = 0; @@ -757,8 +757,8 @@ int main(int argc, char * argv[]) { } else { sensor[PRES] = 1015; strcpy(sensor_string[PRES], "1015"); - sensor[ALT] = 175; - strcpy(sensor_string[ALT], "175"); + sensor[ALT] = 75; + strcpy(sensor_string[ALT], "75"); sensor[HUMI] = 48; strcpy(sensor_string[HUMI], "48"); sensor[TEMP] = 27; From 45fd4ad899dd3830e200f6d74f75c7714a10cb52 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 27 Aug 2025 16:44:05 -0400 Subject: [PATCH 49/49] Update main.c if payload failure, no sim payload telemetry --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 9a9d3def..d3c1403d 100644 --- a/main.c +++ b/main.c @@ -744,7 +744,7 @@ int main(int argc, char * argv[]) { newGpsTime = millis(); } - if (sim_mode) { + if (sim_mode && (failureMode != FAIL_PAYLOAD)) { if (atmosphere == 0) { sensor[PRES] = 0; strcpy(sensor_string[PRES], "0.0");