From 717d8494a4869fa42845ffcd1eca77547c265059 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 10:56:57 -0400 Subject: [PATCH 001/295] Update main.c add simulated failures --- main.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index ff1d3654..f465abdc 100644 --- a/main.c +++ b/main.c @@ -1264,7 +1264,30 @@ void get_tlm_fox() { short int buffer_test[bufLen]; int buffSize; buffSize = (int) sizeof(buffer_test); - + + int failureMode = OFF; + FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); + if (failure_mode_file != NULL) { + char failure_string[10]; + if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) + failureMode = atoi(failure_string); + } else + printf("No simulated failures!\n"); + fclose(failure_mode_file); + + if (failureMode == 0) { + failureMode = (int) rnd_float(1, FAIL_COUNT); + if (failureMode == FAIL_SOLAR) { + voltage[PLUS_X] = 0.0; + current[PLUS_X] = 0.0; + } + if (failureMode == FAIL_SOLAR) { + voltage[MINUS_X] = voltage[MINUS_X] * 0.5; + current[MINUS_X] = currente[MINUS_X] * 0.5; + } + if (failureMode == FAIL_SHORT) { + voltage[MINUS_Y] = 0.0; + } if (mode == FSK) id = 7; else From d071bd5ee0430c8b34611b896855ef5908de93ac Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 10:57:06 -0400 Subject: [PATCH 002/295] Update main.h added simulated changes --- main.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.h b/main.h index 1c2e5e36..48818e37 100644 --- a/main.h +++ b/main.h @@ -124,6 +124,11 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 +#define FAIL_COUNT = 2 +#define FAIL_SOLAR = 1 +#define FAIL_DEGRADE = 2 +#define FAIL_SHORT = 3 + int transmitStatus = -1; float amplitude; // = ; // 20000; // 32767/(10%amp+5%amp+100%amp) From 16e34a7c67fd17a87546a700d8147be08a553ec6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 10:59:06 -0400 Subject: [PATCH 003/295] Update main.h typo --- main.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.h b/main.h index 48818e37..3f0c9c6f 100644 --- a/main.h +++ b/main.h @@ -124,10 +124,10 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 -#define FAIL_COUNT = 2 -#define FAIL_SOLAR = 1 -#define FAIL_DEGRADE = 2 -#define FAIL_SHORT = 3 +#define FAIL_COUNT 2 +#define FAIL_SOLAR 1 +#define FAIL_DEGRADE 2 +#define FAIL_SHORT 3 int transmitStatus = -1; From bf2156be94d4abc73d3b8488949fd05668f8f859 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 10:59:54 -0400 Subject: [PATCH 004/295] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index f465abdc..368229b6 100644 --- a/main.c +++ b/main.c @@ -1283,7 +1283,7 @@ void get_tlm_fox() { } if (failureMode == FAIL_SOLAR) { voltage[MINUS_X] = voltage[MINUS_X] * 0.5; - current[MINUS_X] = currente[MINUS_X] * 0.5; + current[MINUS_X] = current[MINUS_X] * 0.5; } if (failureMode == FAIL_SHORT) { voltage[MINUS_Y] = 0.0; From a2209b9921037462e98661894b6b430105cd9c9b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 11:03:12 -0400 Subject: [PATCH 005/295] Update main.c added prints for failure modes --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 368229b6..1cf595d0 100644 --- a/main.c +++ b/main.c @@ -1277,16 +1277,21 @@ void get_tlm_fox() { if (failureMode == 0) { failureMode = (int) rnd_float(1, FAIL_COUNT); + printf("Random Failure"); + } if (failureMode == FAIL_SOLAR) { voltage[PLUS_X] = 0.0; current[PLUS_X] = 0.0; + printf("+X Solar Panel Simulated Failure"); } - if (failureMode == FAIL_SOLAR) { + if (failureMode == FAIL_DEGRADE) { voltage[MINUS_X] = voltage[MINUS_X] * 0.5; current[MINUS_X] = current[MINUS_X] * 0.5; + printf("-X Solar Panel Degredation Simulated Failure"); } if (failureMode == FAIL_SHORT) { voltage[MINUS_Y] = 0.0; + printf("-Y Solar Panel Short Circuit Simulated Failure"); } if (mode == FSK) id = 7; From 784db834cfc01151b70b3b0b19b613dcead1f5b0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 11:18:49 -0400 Subject: [PATCH 006/295] Update main.c move close --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 1cf595d0..52d1d00e 100644 --- a/main.c +++ b/main.c @@ -1269,11 +1269,12 @@ void get_tlm_fox() { FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); if (failure_mode_file != NULL) { char failure_string[10]; - if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) + if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) { failureMode = atoi(failure_string); + fclose(failure_mode_file); + } } else printf("No simulated failures!\n"); - fclose(failure_mode_file); if (failureMode == 0) { failureMode = (int) rnd_float(1, FAIL_COUNT); From 3752b590aae4edca811c44c52abcbba5dc3635ec Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 11:29:40 -0400 Subject: [PATCH 007/295] Update main.c fixed prints --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 52d1d00e..95a11603 100644 --- a/main.c +++ b/main.c @@ -1278,21 +1278,21 @@ void get_tlm_fox() { if (failureMode == 0) { failureMode = (int) rnd_float(1, FAIL_COUNT); - printf("Random Failure"); + printf("Random Failure\n"); } if (failureMode == FAIL_SOLAR) { voltage[PLUS_X] = 0.0; current[PLUS_X] = 0.0; - printf("+X Solar Panel Simulated Failure"); + printf("+X Solar Panel Simulated Failure\n"); } if (failureMode == FAIL_DEGRADE) { voltage[MINUS_X] = voltage[MINUS_X] * 0.5; current[MINUS_X] = current[MINUS_X] * 0.5; - printf("-X Solar Panel Degredation Simulated Failure"); + printf("-X Solar Panel Degredation Simulated Failure\n"); } if (failureMode == FAIL_SHORT) { voltage[MINUS_Y] = 0.0; - printf("-Y Solar Panel Short Circuit Simulated Failure"); + printf("-Y Solar Panel Short Circuit Simulated Failure\n"); } if (mode == FSK) id = 7; From af803704d6b905a5921a862747346cbf028e1a46 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:07:45 -0400 Subject: [PATCH 008/295] Update main.c show Sim mode in FoxTelem --- main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 95a11603..6644c8f0 100644 --- a/main.c +++ b/main.c @@ -1623,9 +1623,13 @@ void get_tlm_fox() { printf("Error opening command_count.txt!\n"); fclose(command_count_file); -// printf("Command count: %d\n", groundCommandCount); - - int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + +// printf("Command count: %d\n", groundCommandCount); + int simulated; + simulted = sim_mode; + if (failureMode != OFF) + simulated == TRUE; +// int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + + int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; encodeA(b, 51 + head_offset, status); From 1d60c1723af2738c73947b5ce8b2db1f5c9dd716 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:10:32 -0400 Subject: [PATCH 009/295] Update main.c fix typo --- main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 6644c8f0..0b3e14b0 100644 --- a/main.c +++ b/main.c @@ -1283,16 +1283,16 @@ void get_tlm_fox() { if (failureMode == FAIL_SOLAR) { voltage[PLUS_X] = 0.0; current[PLUS_X] = 0.0; - printf("+X Solar Panel Simulated Failure\n"); + printf("+X Solar Simulated Failure\n"); } if (failureMode == FAIL_DEGRADE) { voltage[MINUS_X] = voltage[MINUS_X] * 0.5; current[MINUS_X] = current[MINUS_X] * 0.5; - printf("-X Solar Panel Degredation Simulated Failure\n"); + printf("-X Solar Deg Simulated Failure\n"); } if (failureMode == FAIL_SHORT) { voltage[MINUS_Y] = 0.0; - printf("-Y Solar Panel Short Circuit Simulated Failure\n"); + printf("-Y Solar SC Simulated Failure\n"); } if (mode == FSK) id = 7; @@ -1625,9 +1625,11 @@ void get_tlm_fox() { // printf("Command count: %d\n", groundCommandCount); int simulated; - simulted = sim_mode; - if (failureMode != OFF) + simulated = sim_mode; + if (failureMode != OFF) { simulated == TRUE; + printf("Showing Simulted in FoxTelem\n"); + } // int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; From 2d4a36b61e6a7d2d134d820a31e49098b6ab4ec9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:21:07 -0400 Subject: [PATCH 010/295] Update main.c change --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 0b3e14b0..26ee9f10 100644 --- a/main.c +++ b/main.c @@ -1292,7 +1292,7 @@ void get_tlm_fox() { } if (failureMode == FAIL_SHORT) { voltage[MINUS_Y] = 0.0; - printf("-Y Solar SC Simulated Failure\n"); + printf("-Y Solar SC Simulated Failure!\n"); } if (mode == FSK) id = 7; From 88009728236a67020cbed64e770c57ed21f3b1eb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:25:26 -0400 Subject: [PATCH 011/295] Update main.c fix FoxTelem indication --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 26ee9f10..d3aebf90 100644 --- a/main.c +++ b/main.c @@ -1294,6 +1294,7 @@ void get_tlm_fox() { voltage[MINUS_Y] = 0.0; printf("-Y Solar SC Simulated Failure!\n"); } + if (mode == FSK) id = 7; else @@ -1627,7 +1628,7 @@ void get_tlm_fox() { int simulated; simulated = sim_mode; if (failureMode != OFF) { - simulated == TRUE; + simulated = TRUE; printf("Showing Simulted in FoxTelem\n"); } // int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + From e9506d00e067a839dd0c82637ed82ebb068993e4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:30:24 -0400 Subject: [PATCH 012/295] Update main.h update fail count --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index 3f0c9c6f..b1000f06 100644 --- a/main.h +++ b/main.h @@ -124,7 +124,7 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 -#define FAIL_COUNT 2 +#define FAIL_COUNT 3 #define FAIL_SOLAR 1 #define FAIL_DEGRADE 2 #define FAIL_SHORT 3 From 5db96f8e82b7d05de108e0c67a1f91c1d1849b58 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:33:42 -0400 Subject: [PATCH 013/295] Update main.c change to +X --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index d3aebf90..e3f36ef3 100644 --- a/main.c +++ b/main.c @@ -1286,9 +1286,9 @@ void get_tlm_fox() { printf("+X Solar Simulated Failure\n"); } if (failureMode == FAIL_DEGRADE) { - voltage[MINUS_X] = voltage[MINUS_X] * 0.5; - current[MINUS_X] = current[MINUS_X] * 0.5; - printf("-X Solar Deg Simulated Failure\n"); + voltage[PLUS_X] = voltage[PLUS_X] * 0.5; + current[PLUS_X] = current[PLUS_X] * 0.5; + printf("+X Solar Deg Simulated Failure\n"); } if (failureMode == FAIL_SHORT) { voltage[MINUS_Y] = 0.0; From 68abd02fa7a24730f196604ac924bd6db1e1bf5d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:40:31 -0400 Subject: [PATCH 014/295] Update main.c add mapping --- main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index e3f36ef3..5b5ff80a 100644 --- a/main.c +++ b/main.c @@ -1281,17 +1281,17 @@ void get_tlm_fox() { printf("Random Failure\n"); } if (failureMode == FAIL_SOLAR) { - voltage[PLUS_X] = 0.0; - current[PLUS_X] = 0.0; + voltage[map[PLUS_X]] = 0.0; + current[map[PLUS_X]] = 0.0; printf("+X Solar Simulated Failure\n"); } if (failureMode == FAIL_DEGRADE) { - voltage[PLUS_X] = voltage[PLUS_X] * 0.5; - current[PLUS_X] = current[PLUS_X] * 0.5; - printf("+X Solar Deg Simulated Failure\n"); + voltage[map[MINUS_X]] = voltage[MINUS_X] * 0.5; + current[mapa[MINUS_X]] = current[MINUS_X] * 0.5; + printf("-X Solar Deg Simulated Failure\n"); } if (failureMode == FAIL_SHORT) { - voltage[MINUS_Y] = 0.0; + voltage[map[MINUS_Y]] = 0.0; printf("-Y Solar SC Simulated Failure!\n"); } From b25aa6361651de8f7ef2461343f5f4d58518b450 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 13:43:33 -0400 Subject: [PATCH 015/295] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 5b5ff80a..93a6e96c 100644 --- a/main.c +++ b/main.c @@ -1287,7 +1287,7 @@ void get_tlm_fox() { } if (failureMode == FAIL_DEGRADE) { voltage[map[MINUS_X]] = voltage[MINUS_X] * 0.5; - current[mapa[MINUS_X]] = current[MINUS_X] * 0.5; + current[map[MINUS_X]] = current[MINUS_X] * 0.5; printf("-X Solar Deg Simulated Failure\n"); } if (failureMode == FAIL_SHORT) { From 029ccc6b1a4a635158def7cda01d023e8dbbe221 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:07:54 -0400 Subject: [PATCH 016/295] Update main.h I2C and Camera Failures --- main.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.h b/main.h index b1000f06..aa97ad8b 100644 --- a/main.h +++ b/main.h @@ -124,10 +124,13 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 -#define FAIL_COUNT 3 +#define FAIL_COUNT 5 #define FAIL_SOLAR 1 #define FAIL_DEGRADE 2 #define FAIL_SHORT 3 +#define FAIL_I2C1 4 +#define FAIL_I2C3 5 +#define FAIL_CAMERA 6 int transmitStatus = -1; From 20e24087f11c36a3776fd974954ea12c46083f0d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:09:22 -0400 Subject: [PATCH 017/295] Update main.c I2C 1 and 3 and Camera failures --- main.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 93a6e96c..b9af4197 100644 --- a/main.c +++ b/main.c @@ -1294,6 +1294,32 @@ void get_tlm_fox() { voltage[map[MINUS_Y]] = 0.0; printf("-Y Solar SC Simulated Failure!\n"); } + if (failureMode == FAIL_I2C1) { + voltage[map[PLUS_X]] = 0.0; + current[map[PLUS_X]] = 0.0; + voltage[map[PLUS_Y]] = 0.0; + current[map[PLUS_Y]] = 0.0; + voltage[map[BAT]] = 0.0; + current[map[BAT]] = 0.0; + voltage[map[BAT2]] = 0.0; + current[map[BAT2]] = 0.0; + printf("I2C Bus 1 Simulated Failure!\n"); + } + if (failureMode == FAIL_I2C3) { + voltage[map[MINUS_X]] = 0.0; + current[map[MINUS_X]] = 0.0; + voltage[map[MINUS_Y]] = 0.0; + current[map[MINUS_Y]] = 0.0; + voltage[map[MINUS_Z]] = 0.0; + current[map[MINUS_Z]] = 0.0; + voltage[map[PLUS_Z]] = 0.0; + current[map[PLUS_Z]] = 0.0; + printf("I2C Bus 3 Simulated Failure!\n"); + } + if (failureMode == FAIL_CAMERA) { + camera = OFF; + printf("Camera Simulated Failure!\n"); + } if (mode == FSK) id = 7; @@ -1631,9 +1657,18 @@ void get_tlm_fox() { simulated = TRUE; printf("Showing Simulted in FoxTelem\n"); } + int i2c_1, i2c_3; + i2c_1 = i2c_bus1; + i2c_2 = i2c_bus2; + if (failureMode == FAIL_I2C1) { + i2c_1 = FALSE; + } else if (failureMode == FAIL_I2C3) { + i2c_3 = FALSE; + } // int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + +// (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + - (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; + (i2c_bus0 == OFF) * 16 + (i2c_1 == OFF) * 32 + (i2c_3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; encodeA(b, 51 + head_offset, status); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); From 4f34a9a513c394e48a852cf542b30e542120e2ef Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:10:03 -0400 Subject: [PATCH 018/295] Update main.c typo 2 to 3 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index b9af4197..67df1a9e 100644 --- a/main.c +++ b/main.c @@ -1659,7 +1659,7 @@ void get_tlm_fox() { } int i2c_1, i2c_3; i2c_1 = i2c_bus1; - i2c_2 = i2c_bus2; + i2c_3 = i2c_bus3; if (failureMode == FAIL_I2C1) { i2c_1 = FALSE; } else if (failureMode == FAIL_I2C3) { From d8ff3cca724d039f34f1a0707ac94b175d56d8bb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:16:31 -0400 Subject: [PATCH 019/295] Update main.c print i2c 1 and 3 bus --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index 67df1a9e..8ca7fb88 100644 --- a/main.c +++ b/main.c @@ -1662,8 +1662,10 @@ void get_tlm_fox() { i2c_3 = i2c_bus3; if (failureMode == FAIL_I2C1) { i2c_1 = FALSE; + printf("I2C Bus 1 Simulated Failure\n"); } else if (failureMode == FAIL_I2C3) { i2c_3 = FALSE; + printf("I2C Bus 3 Simulated Failure\n"); } // int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + // (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; From 3cfc9ee5b771c1e6602f389cc01885ded3ef6165 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:23:09 -0400 Subject: [PATCH 020/295] Update main.c print bus status --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 8ca7fb88..a48005a4 100644 --- a/main.c +++ b/main.c @@ -1659,7 +1659,8 @@ void get_tlm_fox() { } int i2c_1, i2c_3; i2c_1 = i2c_bus1; - i2c_3 = i2c_bus3; + i2c_3 = i2c_bus3; + printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3); if (failureMode == FAIL_I2C1) { i2c_1 = FALSE; printf("I2C Bus 1 Simulated Failure\n"); From c6eb2e459775585eff30752a76efab1c3c179c94 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:29:46 -0400 Subject: [PATCH 021/295] Update main.c fix i2c 1 and 3 bus on and off --- main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index a48005a4..53f36b9b 100644 --- a/main.c +++ b/main.c @@ -1655,18 +1655,18 @@ void get_tlm_fox() { simulated = sim_mode; if (failureMode != OFF) { simulated = TRUE; - printf("Showing Simulted in FoxTelem\n"); +// printf("Showing Simulted in FoxTelem\n"); } int i2c_1, i2c_3; i2c_1 = i2c_bus1; i2c_3 = i2c_bus3; printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3); if (failureMode == FAIL_I2C1) { - i2c_1 = FALSE; - printf("I2C Bus 1 Simulated Failure\n"); + i2c_1 = OFF; +// printf("I2C Bus 1 Simulated Failure\n"); } else if (failureMode == FAIL_I2C3) { - i2c_3 = FALSE; - printf("I2C Bus 3 Simulated Failure\n"); + i2c_3 = OFF; +// printf("I2C Bus 3 Simulated Failure\n"); } // int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + // (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; From fe325c5f39056eaf67162c224c46b29847913892 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:31:10 -0400 Subject: [PATCH 022/295] Update main.h add more --- main.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.h b/main.h index aa97ad8b..1f096e63 100644 --- a/main.h +++ b/main.h @@ -124,13 +124,16 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 -#define FAIL_COUNT 5 +#define FAIL_COUNT 9 #define FAIL_SOLAR 1 #define FAIL_DEGRADE 2 #define FAIL_SHORT 3 #define FAIL_I2C1 4 #define FAIL_I2C3 5 #define FAIL_CAMERA 6 +#define FAIL_EXPERIMENTS 7 +#define FAIL_BME 8 +#define FAIL_MPU 9 int transmitStatus = -1; From 619e508e9e153273fddc1e3c0ed24ba44d009871 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:34:24 -0400 Subject: [PATCH 023/295] Update main.h change to fail payload --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index 1f096e63..be6a11c9 100644 --- a/main.h +++ b/main.h @@ -131,7 +131,7 @@ FILE *image_file; #define FAIL_I2C1 4 #define FAIL_I2C3 5 #define FAIL_CAMERA 6 -#define FAIL_EXPERIMENTS 7 +#define FAIL_PAYLOAD 7 #define FAIL_BME 8 #define FAIL_MPU 9 From 89fb11c929fa3bfdd91d24250acc7d83488236ab Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 16:52:55 -0400 Subject: [PATCH 024/295] Update main.c add Payload, MPU, and BME failures --- main.c | 214 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 131 insertions(+), 83 deletions(-) diff --git a/main.c b/main.c index 53f36b9b..04e1f4e9 100644 --- a/main.c +++ b/main.c @@ -1320,6 +1320,10 @@ void get_tlm_fox() { camera = OFF; printf("Camera Simulated Failure!\n"); } + if (failureMode == FAIL_PAYLOAD) { + payload = OFF; + printf("Payload Simulated Failure!\n"); + } if (mode == FSK) id = 7; @@ -1461,13 +1465,23 @@ void get_tlm_fox() { // encodeB(b, 1 + head_offset, batt_b_v); encodeA(b, 3 + head_offset, batt_c_v); - encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + + if ((failureMode != FAIL_MPU) || (failureMode != FAIL_PAYLOAD)) { + encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + } + else + { + encodeB(b, 4 + head_offset, 2048); // 0 + encodeA(b, 6 + head_offset, 2048); // 0 + encodeB(b, 7 + head_offset, 2048); // 0 + } encodeA(b, 9 + head_offset, battCurr); - encodeB(b, 10 + head_offset, (int)(sensor[TEMP] * 10 + 0.5)); // Temp + if (failureMode != FAIL_PAYLOAD) + encodeB(b, 10 + head_offset, (int)(sensor[TEMP] * 10 + 0.5)); // Temp if (mode == FSK) { encodeA(b, 12 + head_offset, posXv); @@ -1522,40 +1536,52 @@ void get_tlm_fox() { encodeA(b_max, 39 + head_offset, (int)(other_max[IHU_TEMP] * 10 + 0.5)); encodeB(b_max, 31 + head_offset, ((int)(other_max[SPIN] * 10)) + 2048); - if (sensor_min[TEMP] != 1000.0) // make sure values are valid - { - encodeB(b_max, 4 + head_offset, (int)(sensor_max[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b_max, 6 + head_offset, (int)(sensor_max[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b_max, 7 + head_offset, (int)(sensor_max[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel - - encodeA(b_max, 33 + head_offset, (int)(sensor_max[PRES] + 0.5)); // Pressure - encodeB(b_max, 34 + head_offset, (int)(sensor_max[ALT] * 10.0 + 0.5)); // Altitude - encodeB(b_max, 40 + head_offset, (int)(sensor_max[GYRO_X] + 0.5) + 2048); - encodeA(b_max, 42 + head_offset, (int)(sensor_max[GYRO_Y] + 0.5) + 2048); - encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048); - - encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048); -// encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048); - encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); - encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5)); - - encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1])); - encodeA(b_max, 0 + head_offset, (int)(sensor_max[XS2])); - encodeB(b_max, 1 + head_offset, (int)(sensor_max[XS3])); - } - else - { - encodeB(b_max, 4 + head_offset, 2048); // 0 - encodeA(b_max, 6 + head_offset, 2048); // 0 - encodeB(b_max, 7 + head_offset, 2048); // 0 - - encodeB(b_max, 40 + head_offset, 2048); - encodeA(b_max, 42 + head_offset, 2048); - encodeB(b_max, 43 + head_offset, 2048); - - encodeA(b_max, 48 + head_offset, 2048); -// encodeB(b_max, 49 + head_offset, 2048); - } + if (failureMode != FAIL_PAYLOAD) { + if (sensor_min[TEMP] != 1000.0) // make sure values are valid + { + if (failureMode != FAIL_MPU) { + encodeB(b_max, 4 + head_offset, (int)(sensor_max[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b_max, 6 + head_offset, (int)(sensor_max[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b_max, 7 + head_offset, (int)(sensor_max[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + encodeB(b_max, 40 + head_offset, (int)(sensor_max[GYRO_X] + 0.5) + 2048); + encodeA(b_max, 42 + head_offset, (int)(sensor_max[GYRO_Y] + 0.5) + 2048); + encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048); + } + else + { + encodeB(b_max, 4 + head_offset, 2048); // 0 + encodeA(b_max, 6 + head_offset, 2048); // 0 + encodeB(b_max, 7 + head_offset, 2048); // 0 + encodeB(b_max, 40 + head_offset, 2048); + encodeA(b_max, 42 + head_offset, 2048); + encodeB(b_max, 43 + head_offset, 2048); + } + if (failureMode != FAIL_BME) { + encodeA(b_max, 33 + head_offset, (int)(sensor_max[PRES] + 0.5)); // Pressure + encodeB(b_max, 34 + head_offset, (int)(sensor_max[ALT] * 10.0 + 0.5)); // Altitude + // encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048); + encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); + encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5)); + } + encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048); + + encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1])); + encodeA(b_max, 0 + head_offset, (int)(sensor_max[XS2])); + encodeB(b_max, 1 + head_offset, (int)(sensor_max[XS3])); + } + else + { + encodeB(b_max, 4 + head_offset, 2048); // 0 + encodeA(b_max, 6 + head_offset, 2048); // 0 + encodeB(b_max, 7 + head_offset, 2048); // 0 + encodeB(b_max, 40 + head_offset, 2048); + encodeA(b_max, 42 + head_offset, 2048); + encodeB(b_max, 43 + head_offset, 2048); + + encodeA(b_max, 48 + head_offset, 2048); + // encodeB(b_max, 49 + head_offset, 2048); + } + } encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100)); encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100)); encodeA(b_min, 15 + head_offset, (int)(voltage_min[map[PLUS_Z]] * 100)); @@ -1578,59 +1604,81 @@ void get_tlm_fox() { encodeB(b_min, 31 + head_offset, ((int)(other_min[SPIN] * 10)) + 2048); encodeB(b_min, 37 + head_offset, (int)(other_min[RSSI] + 0.5) + 2048); encodeA(b_min, 39 + head_offset, (int)(other_min[IHU_TEMP] * 10 + 0.5)); - - if (sensor_min[TEMP] != 1000.0) // make sure values are valid - { - encodeB(b_min, 4 + head_offset, (int)(sensor_min[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b_min, 6 + head_offset, (int)(sensor_min[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b_min, 7 + head_offset, (int)(sensor_min[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel - - encodeA(b_min, 33 + head_offset, (int)(sensor_min[PRES] + 0.5)); // Pressure - encodeB(b_min, 34 + head_offset, (int)(sensor_min[ALT] * 10.0 + 0.5)); // Altitude - encodeB(b_min, 40 + head_offset, (int)(sensor_min[GYRO_X] + 0.5) + 2048); - encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048); - encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048); - - encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048); -// encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048); - encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); - encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5)); - - encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1])); - encodeA(b_min, 0 + head_offset, (int)(sensor_min[XS2])); - encodeB(b_min, 1 + head_offset, (int)(sensor_min[XS3])); - } - else - { - encodeB(b_min, 4 + head_offset, 2048); // 0 - encodeA(b_min, 6 + head_offset, 2048); // 0 - encodeB(b_min, 7 + head_offset, 2048); // 0 - - encodeB(b_min, 40 + head_offset, 2048); - encodeA(b_min, 42 + head_offset, 2048); - encodeB(b_min, 43 + head_offset, 2048); - - encodeA(b_min, 48 + head_offset, 2048); -// encodeB(b_min, 49 + head_offset, 2048); - } + + if (failureMode != FAIL_PAYLOAD) { + if (sensor_min[TEMP] != 1000.0) // make sure values are valid + { + if (failureMode != FAIL_MPU) + { + encodeB(b_min, 4 + head_offset, (int)(sensor_min[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b_min, 6 + head_offset, (int)(sensor_min[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b_min, 7 + head_offset, (int)(sensor_min[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + encodeB(b_min, 40 + head_offset, (int)(sensor_min[GYRO_X] + 0.5) + 2048); + encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048); + encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048); + } + else + { + encodeB(b_min, 4 + head_offset, 2048); // 0 + encodeA(b_min, 6 + head_offset, 2048); // 0 + encodeB(b_min, 7 + head_offset, 2048); // 0 + encodeB(b_min, 40 + head_offset, 2048); + encodeA(b_min, 42 + head_offset, 2048); + encodeB(b_min, 43 + head_offset, 2048); + } + if (failureMode != FAIL_BME) { + encodeA(b_min, 33 + head_offset, (int)(sensor_min[PRES] + 0.5)); // Pressure + encodeB(b_min, 34 + head_offset, (int)(sensor_min[ALT] * 10.0 + 0.5)); // Altitude + encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); + encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5)); + } + encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048); + // encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048); + + + encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1])); + encodeA(b_min, 0 + head_offset, (int)(sensor_min[XS2])); + encodeB(b_min, 1 + head_offset, (int)(sensor_min[XS3])); + } + else + { + encodeB(b_min, 4 + head_offset, 2048); // 0 + encodeA(b_min, 6 + head_offset, 2048); // 0 + encodeB(b_min, 7 + head_offset, 2048); // 0 + + encodeB(b_min, 40 + head_offset, 2048); + encodeA(b_min, 42 + head_offset, 2048); + encodeB(b_min, 43 + head_offset, 2048); + + encodeA(b_min, 48 + head_offset, 2048); + // encodeB(b_min, 49 + head_offset, 2048); + } + } } encodeA(b, 30 + head_offset, BAT2Voltage); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); - - encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure - encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude - + if (failureMode != FAIL_BME) { + encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure + encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude + encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 + encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); + } encodeA(b, 36 + head_offset, Resets); encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048); - encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); - - encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048); - encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048); - encodeB(b, 43 + head_offset, (int)(sensor[GYRO_Z] + 0.5) + 2048); - encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 + if (failureMode != FAIL_MPU) { + encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048); + encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048); + encodeB(b, 43 + head_offset, (int)(sensor[GYRO_Z] + 0.5) + 2048); + } + else + { + encodeB(b, 40 + head_offset, 2048); + encodeA(b, 42 + head_offset, 2048); + encodeB(b, 43 + head_offset, 2048); + } encodeB(b, 46 + head_offset, BAT2Current); encodeA(b, 48 + head_offset, (int)(sensor[DTEMP] * 10 + 0.5) + 2048); From 26ff2a88caf7be3986daaf39089260f68a174911 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 17:07:39 -0400 Subject: [PATCH 025/295] Update main.c fix payload OK --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 04e1f4e9..d34676ca 100644 --- a/main.c +++ b/main.c @@ -1261,6 +1261,8 @@ void get_tlm_fox() { int posXi = 0, negXi = 0, posYi = 0, negYi = 0, posZi = 0, negZi = 0; int head_offset = 0; + STEMBoardFailure = 1; + short int buffer_test[bufLen]; int buffSize; buffSize = (int) sizeof(buffer_test); @@ -1466,7 +1468,7 @@ void get_tlm_fox() { encodeA(b, 3 + head_offset, batt_c_v); - if ((failureMode != FAIL_MPU) || (failureMode != FAIL_PAYLOAD)) { + if ((failureMode != FAIL_MPU) && (failureMode != FAIL_PAYLOAD)) { encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel From c16a1191ba1de0735759c9fd99caf5924091896c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 17:19:07 -0400 Subject: [PATCH 026/295] Update main.c payload failure --- main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.c b/main.c index d34676ca..cc57cf2a 100644 --- a/main.c +++ b/main.c @@ -1584,6 +1584,15 @@ void get_tlm_fox() { // encodeB(b_max, 49 + head_offset, 2048); } } + else + { + encodeB(b_max, 4 + head_offset, 2048); // 0 + encodeA(b_max, 6 + head_offset, 2048); // 0 + encodeB(b_max, 7 + head_offset, 2048); // 0 + encodeB(b_max, 40 + head_offset, 2048); + encodeA(b_max, 42 + head_offset, 2048); + encodeB(b_max, 43 + head_offset, 2048); + } encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100)); encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100)); encodeA(b_min, 15 + head_offset, (int)(voltage_min[map[PLUS_Z]] * 100)); From 0880257c3033f6d980bb4c2d6e1e570dee6541ba Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 17:31:24 -0400 Subject: [PATCH 027/295] Update main.c fix payload failure --- main.c | 80 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/main.c b/main.c index cc57cf2a..9ee7eb5f 100644 --- a/main.c +++ b/main.c @@ -1468,16 +1468,17 @@ void get_tlm_fox() { encodeA(b, 3 + head_offset, batt_c_v); - if ((failureMode != FAIL_MPU) && (failureMode != FAIL_PAYLOAD)) { - encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel - } - else + if ((failureMode == FAIL_MPU) || (failureMode == FAIL_PAYLOAD)) { encodeB(b, 4 + head_offset, 2048); // 0 encodeA(b, 6 + head_offset, 2048); // 0 - encodeB(b, 7 + head_offset, 2048); // 0 + encodeB(b, 7 + head_offset, 2048); // 0 + } + else + { + encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel } encodeA(b, 9 + head_offset, battCurr); @@ -1669,36 +1670,51 @@ void get_tlm_fox() { encodeA(b, 30 + head_offset, BAT2Voltage); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); - if (failureMode != FAIL_BME) { - encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure - encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude - encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 - encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); - } - encodeA(b, 36 + head_offset, Resets); - encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048); - - if (failureMode != FAIL_MPU) { - encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048); - encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048); - encodeB(b, 43 + head_offset, (int)(sensor[GYRO_Z] + 0.5) + 2048); - } + if (failureMode != FAIL_PAYLOAD) { + if (failureMode != FAIL_BME) { + encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure + encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude + encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 + encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); + } + encodeA(b, 36 + head_offset, Resets); + encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048); + + + if (failureMode != FAIL_MPU) { + encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048); + encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048); + encodeB(b, 43 + head_offset, (int)(sensor[GYRO_Z] + 0.5) + 2048); + } + else + { + encodeB(b, 40 + head_offset, 2048); + encodeA(b, 42 + head_offset, 2048); + encodeB(b, 43 + head_offset, 2048); + } + encodeA(b, 48 + head_offset, (int)(sensor[DTEMP] * 10 + 0.5) + 2048); + encodeB(b, 49 + head_offset, (int)(sensor[XS1])); + encodeA(b, 0 + head_offset, (int)(sensor[XS2])); + encodeB(b, 1 + head_offset, (int)(sensor[XS3])); + } else - { - encodeB(b, 40 + head_offset, 2048); - encodeA(b, 42 + head_offset, 2048); - encodeB(b, 43 + head_offset, 2048); - } - + { + encodeB(b_min, 4 + head_offset, 2048); // 0 + encodeA(b_min, 6 + head_offset, 2048); // 0 + encodeB(b_min, 7 + head_offset, 2048); // 0 + + encodeB(b_min, 40 + head_offset, 2048); + encodeA(b_min, 42 + head_offset, 2048); + encodeB(b_min, 43 + head_offset, 2048); + + encodeA(b_min, 48 + head_offset, 2048); +// encodeB(b_min, 49 + head_offset, 2048); + } encodeB(b, 46 + head_offset, BAT2Current); - encodeA(b, 48 + head_offset, (int)(sensor[DTEMP] * 10 + 0.5) + 2048); + // encodeB(b, 49 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048); - encodeB(b, 49 + head_offset, (int)(sensor[XS1])); - encodeA(b, 0 + head_offset, (int)(sensor[XS2])); - encodeB(b, 1 + head_offset, (int)(sensor[XS3])); - FILE * command_count_file = fopen("/home/pi/CubeSatSim/command_count.txt", "r"); if (command_count_file != NULL) { char count_string[10]; From c0bf3d130260a5f72b9eda1f7a3767bc30f96445 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 17:44:06 -0400 Subject: [PATCH 028/295] Update main.c fixing payload failure --- main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 9ee7eb5f..15bd421f 100644 --- a/main.c +++ b/main.c @@ -1593,6 +1593,7 @@ void get_tlm_fox() { encodeB(b_max, 40 + head_offset, 2048); encodeA(b_max, 42 + head_offset, 2048); encodeB(b_max, 43 + head_offset, 2048); + encodeA(b_max, 48 + head_offset, 2048); } encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100)); encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100)); @@ -1700,15 +1701,15 @@ void get_tlm_fox() { } else { - encodeB(b_min, 4 + head_offset, 2048); // 0 - encodeA(b_min, 6 + head_offset, 2048); // 0 - encodeB(b_min, 7 + head_offset, 2048); // 0 + encodeB(b, 4 + head_offset, 2048); // 0 + encodeA(b, 6 + head_offset, 2048); // 0 + encodeB(b, 7 + head_offset, 2048); // 0 - encodeB(b_min, 40 + head_offset, 2048); - encodeA(b_min, 42 + head_offset, 2048); - encodeB(b_min, 43 + head_offset, 2048); + encodeB(b, 40 + head_offset, 2048); + encodeA(b, 42 + head_offset, 2048); + encodeB(b, 43 + head_offset, 2048); - encodeA(b_min, 48 + head_offset, 2048); + encodeA(b, 48 + head_offset, 2048); // encodeB(b_min, 49 + head_offset, 2048); } encodeB(b, 46 + head_offset, BAT2Current); From 45d6939f34b12eaa1649f47b73de1dcdfdf2ded1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 17:47:46 -0400 Subject: [PATCH 029/295] Update main.c more payload failure changes --- main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.c b/main.c index 15bd421f..fb25e09d 100644 --- a/main.c +++ b/main.c @@ -1667,6 +1667,18 @@ void get_tlm_fox() { // encodeB(b_min, 49 + head_offset, 2048); } } + else + { + encodeB(b_min, 4 + head_offset, 2048); // 0 + encodeA(b_min, 6 + head_offset, 2048); // 0 + encodeB(b_min, 7 + head_offset, 2048); // 0 + + encodeB(b_min, 40 + head_offset, 2048); + encodeA(b_min, 42 + head_offset, 2048); + encodeB(b_min, 43 + head_offset, 2048); + + encodeA(b_min, 48 + head_offset, 2048); + } } encodeA(b, 30 + head_offset, BAT2Voltage); From 25495ef324f4862cffecf2db8b71cace848da93f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 17:56:03 -0400 Subject: [PATCH 030/295] Update main.c fix bme temp fail --- main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index fb25e09d..13cfd53a 100644 --- a/main.c +++ b/main.c @@ -1483,7 +1483,7 @@ void get_tlm_fox() { encodeA(b, 9 + head_offset, battCurr); - if (failureMode != FAIL_PAYLOAD) + if ((failureMode != FAIL_PAYLOAD) && (failureMode != FAIL_BME)) encodeB(b, 10 + head_offset, (int)(sensor[TEMP] * 10 + 0.5)); // Temp if (mode == FSK) { @@ -1689,7 +1689,7 @@ void get_tlm_fox() { encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 - encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); + encodeA(b, 39 + head_offset, (int)(other[TEMP] * 10 + 0.5)); } encodeA(b, 36 + head_offset, Resets); encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048); @@ -1725,7 +1725,8 @@ void get_tlm_fox() { // encodeB(b_min, 49 + head_offset, 2048); } encodeB(b, 46 + head_offset, BAT2Current); - + encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); + // encodeB(b, 49 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048); FILE * command_count_file = fopen("/home/pi/CubeSatSim/command_count.txt", "r"); From 394ced012e2364a000bf92e57e09b8ee4973cbf0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 23:08:10 -0400 Subject: [PATCH 031/295] Update transmit.py check for failure_mode 10 no FM audio --- transmit.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/transmit.py b/transmit.py index 10cee57d..7fc649f9 100644 --- a/transmit.py +++ b/transmit.py @@ -472,6 +472,16 @@ if __name__ == "__main__": print("Ready for next packet!") sleep(0.5) + try: + file = open("/home/pi/CubeSatSim/failure_mode.txt") + fail_mode = file.read(2) + if (fail_mode == "10"): + card = "Device" # Change audio so no FM audio plays + print("Failure mode no FM audio") + else: + print("Other failure mode") + except: + print("No failure mode") except: # command_control_check() sleep(1) From 886651080489832ad3211f3312f5661d07f99a8f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 23:08:57 -0400 Subject: [PATCH 032/295] Update main.h add FAIL_AUDIO mode --- main.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.h b/main.h index be6a11c9..ba7b3368 100644 --- a/main.h +++ b/main.h @@ -124,7 +124,7 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 -#define FAIL_COUNT 9 +#define FAIL_COUNT 10 #define FAIL_SOLAR 1 #define FAIL_DEGRADE 2 #define FAIL_SHORT 3 @@ -134,6 +134,7 @@ FILE *image_file; #define FAIL_PAYLOAD 7 #define FAIL_BME 8 #define FAIL_MPU 9 +#define FAIL_AUDIO 10 int transmitStatus = -1; From bead33ce3f7d16c043bb23caab037e031eb8d1a7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 23:20:51 -0400 Subject: [PATCH 033/295] Update config add -M failure_mode set --- config | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config b/config index 36192384..d5d87517 100755 --- a/config +++ b/config @@ -336,6 +336,11 @@ if [ "$1" = "" ]; then echo "Transmit beacon telemetry is ON" fi + echo + echo -n "Simulated failure mode is: " + cat /home/pi/CubeSatSim/failure_mode.txt + echo + echo echo -e "Current sim.cfg configuration file:" # echo @@ -1430,6 +1435,21 @@ elif [ "$1" = "-j" ]; then restart=1 # fi +elif [ "$1" = "-M" ]; then + + echo + echo "Set simulated failure mode" + echo + + echo "Enter the failure number to change: 0 - 10" + read MODE + + echo + echo -n "Setting simulated failure mode: " + echo $MODE + echo + echo $MODE > /home/pi/CubeSatSim/failure_mode.txt + elif [ "$1" = "-h" ]; then echo "config OPTION" @@ -1467,6 +1487,7 @@ elif [ "$1" = "-h" ]; then echo " -o Change telemetry beacon transmit state" echo " -L Change microphone level for command and control" echo " -g Reset configuration back to default settings" + echo " -M Set simulated failure mode" echo exit From 91f76f46039ee88fd052b879ff565cc333fada40 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 10:35:32 -0400 Subject: [PATCH 034/295] Update config changed failure print --- config | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/config b/config index d5d87517..93c3da75 100755 --- a/config +++ b/config @@ -276,6 +276,20 @@ if [ "$1" = "" ]; then fi echo + echo + FILE=/home/pi/CubeSatSim/failure_mode.txt + if [ -f "$FILE" ]; then + if [[ $(grep '0' $FILE) ]]; then + echo "No simulated failures." + else + echo -n "Simulated failure mode is: " + cat $FILE + fi + else + echo "No simulated failures." + fi + echo + if [ "$9" = "yes" ] || [ "$9" = "y" ]; then echo "Balloon mode is ON" else @@ -336,11 +350,6 @@ if [ "$1" = "" ]; then echo "Transmit beacon telemetry is ON" fi - echo - echo -n "Simulated failure mode is: " - cat /home/pi/CubeSatSim/failure_mode.txt - echo - echo echo -e "Current sim.cfg configuration file:" # echo From 3814d17450cba604a44ff684777ce8089d120af2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 10:36:11 -0400 Subject: [PATCH 035/295] Update main.h added FAIL_NONE --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index ba7b3368..080382f2 100644 --- a/main.h +++ b/main.h @@ -125,6 +125,7 @@ FILE *image_file; #define TXCOMMAND 12 #define FAIL_COUNT 10 +#define FAIL_NONE 0 #define FAIL_SOLAR 1 #define FAIL_DEGRADE 2 #define FAIL_SHORT 3 From e780c51b6c7cd8c698317f6309f398ff27a48212 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 10:39:41 -0400 Subject: [PATCH 036/295] Update main.c random is -1, off is 0 --- main.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index 13cfd53a..cfeb612c 100644 --- a/main.c +++ b/main.c @@ -1276,9 +1276,11 @@ void get_tlm_fox() { fclose(failure_mode_file); } } else - printf("No simulated failures!\n"); - - if (failureMode == 0) { + failureMode = FAIL_NONE; + + if (FAIL_NONE) { + printf("No Simulated Failure\n"); + if (failureMode == -1) { failureMode = (int) rnd_float(1, FAIL_COUNT); printf("Random Failure\n"); } @@ -1296,7 +1298,7 @@ void get_tlm_fox() { voltage[map[MINUS_Y]] = 0.0; printf("-Y Solar SC Simulated Failure!\n"); } - if (failureMode == FAIL_I2C1) { + if (FAIL_I2C1) { voltage[map[PLUS_X]] = 0.0; current[map[PLUS_X]] = 0.0; voltage[map[PLUS_Y]] = 0.0; @@ -1307,7 +1309,7 @@ void get_tlm_fox() { current[map[BAT2]] = 0.0; printf("I2C Bus 1 Simulated Failure!\n"); } - if (failureMode == FAIL_I2C3) { + if (FAIL_I2C3) { voltage[map[MINUS_X]] = 0.0; current[map[MINUS_X]] = 0.0; voltage[map[MINUS_Y]] = 0.0; @@ -1318,11 +1320,11 @@ void get_tlm_fox() { current[map[PLUS_Z]] = 0.0; printf("I2C Bus 3 Simulated Failure!\n"); } - if (failureMode == FAIL_CAMERA) { + if (FAIL_CAMERA) { camera = OFF; printf("Camera Simulated Failure!\n"); } - if (failureMode == FAIL_PAYLOAD) { + if (FAIL_PAYLOAD) { payload = OFF; printf("Payload Simulated Failure!\n"); } @@ -1468,7 +1470,7 @@ void get_tlm_fox() { encodeA(b, 3 + head_offset, batt_c_v); - if ((failureMode == FAIL_MPU) || (failureMode == FAIL_PAYLOAD)) + if ((FAIL_MPU) || (FAIL_PAYLOAD)) { encodeB(b, 4 + head_offset, 2048); // 0 encodeA(b, 6 + head_offset, 2048); // 0 @@ -1750,10 +1752,10 @@ void get_tlm_fox() { i2c_1 = i2c_bus1; i2c_3 = i2c_bus3; printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3); - if (failureMode == FAIL_I2C1) { + if (FAIL_I2C1) { i2c_1 = OFF; // printf("I2C Bus 1 Simulated Failure\n"); - } else if (failureMode == FAIL_I2C3) { + } else if (FAIL_I2C3) { i2c_3 = OFF; // printf("I2C Bus 3 Simulated Failure\n"); } From 4f42c97ff0701a9058641f347e9897ee671ef145 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 10:40:51 -0400 Subject: [PATCH 037/295] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index cfeb612c..93a18659 100644 --- a/main.c +++ b/main.c @@ -1278,7 +1278,7 @@ void get_tlm_fox() { } else failureMode = FAIL_NONE; - if (FAIL_NONE) { + if (failureMode == FAIL_NONE) printf("No Simulated Failure\n"); if (failureMode == -1) { failureMode = (int) rnd_float(1, FAIL_COUNT); From a3fbc3ec3725e727a75fb88bfaf70f1a53f414ac Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 10:43:05 -0400 Subject: [PATCH 038/295] Update config remove extra blank line --- config | 1 - 1 file changed, 1 deletion(-) diff --git a/config b/config index 93c3da75..c93c6778 100755 --- a/config +++ b/config @@ -276,7 +276,6 @@ if [ "$1" = "" ]; then fi echo - echo FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then if [[ $(grep '0' $FILE) ]]; then From 17e78ad949111239af6d1b63ef290934bae538a9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 10:46:31 -0400 Subject: [PATCH 039/295] Update main.c added missing == --- main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 93a18659..58e06c4e 100644 --- a/main.c +++ b/main.c @@ -1298,7 +1298,7 @@ void get_tlm_fox() { voltage[map[MINUS_Y]] = 0.0; printf("-Y Solar SC Simulated Failure!\n"); } - if (FAIL_I2C1) { + if (failureMode == FAIL_I2C1) { voltage[map[PLUS_X]] = 0.0; current[map[PLUS_X]] = 0.0; voltage[map[PLUS_Y]] = 0.0; @@ -1309,7 +1309,7 @@ void get_tlm_fox() { current[map[BAT2]] = 0.0; printf("I2C Bus 1 Simulated Failure!\n"); } - if (FAIL_I2C3) { + if (failureMode == FAIL_I2C3) { voltage[map[MINUS_X]] = 0.0; current[map[MINUS_X]] = 0.0; voltage[map[MINUS_Y]] = 0.0; @@ -1320,11 +1320,11 @@ void get_tlm_fox() { current[map[PLUS_Z]] = 0.0; printf("I2C Bus 3 Simulated Failure!\n"); } - if (FAIL_CAMERA) { + if (failureMode == FAIL_CAMERA) { camera = OFF; printf("Camera Simulated Failure!\n"); } - if (FAIL_PAYLOAD) { + if (failureMode == FAIL_PAYLOAD) { payload = OFF; printf("Payload Simulated Failure!\n"); } @@ -1470,7 +1470,7 @@ void get_tlm_fox() { encodeA(b, 3 + head_offset, batt_c_v); - if ((FAIL_MPU) || (FAIL_PAYLOAD)) + if ((failureMode == FAIL_MPU) || (failureMode == FAIL_PAYLOAD)) { encodeB(b, 4 + head_offset, 2048); // 0 encodeA(b, 6 + head_offset, 2048); // 0 From 0f8615f7e0622eda305f7c03537ec4f4cd65fd29 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 10:50:07 -0400 Subject: [PATCH 040/295] Update main.c fix i2c --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 58e06c4e..6748e732 100644 --- a/main.c +++ b/main.c @@ -1744,7 +1744,7 @@ void get_tlm_fox() { // printf("Command count: %d\n", groundCommandCount); int simulated; simulated = sim_mode; - if (failureMode != OFF) { + if (failureMode != FAIL_NONE) { simulated = TRUE; // printf("Showing Simulted in FoxTelem\n"); } @@ -1752,10 +1752,10 @@ void get_tlm_fox() { i2c_1 = i2c_bus1; i2c_3 = i2c_bus3; printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3); - if (FAIL_I2C1) { + if (failure_mode == FAIL_I2C1) { i2c_1 = OFF; // printf("I2C Bus 1 Simulated Failure\n"); - } else if (FAIL_I2C3) { + } else if (failure_mode == FAIL_I2C3) { i2c_3 = OFF; // printf("I2C Bus 3 Simulated Failure\n"); } From 7212c2994b586c49c7bbd8b7b8c3ec6ed874e986 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 14:54:15 -0400 Subject: [PATCH 041/295] Update main.c typo --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 6748e732..99b10c48 100644 --- a/main.c +++ b/main.c @@ -1752,10 +1752,10 @@ void get_tlm_fox() { i2c_1 = i2c_bus1; i2c_3 = i2c_bus3; printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3); - if (failure_mode == FAIL_I2C1) { + if (failureMode == FAIL_I2C1) { i2c_1 = OFF; // printf("I2C Bus 1 Simulated Failure\n"); - } else if (failure_mode == FAIL_I2C3) { + } else if (failureMode == FAIL_I2C3) { i2c_3 = OFF; // printf("I2C Bus 3 Simulated Failure\n"); } From 572a96e506920a34d04bfcc368bfafad9a39c7e4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 14:59:08 -0400 Subject: [PATCH 042/295] Update config print failure mode number --- config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config b/config index c93c6778..670732b0 100755 --- a/config +++ b/config @@ -281,8 +281,10 @@ if [ "$1" = "" ]; then if [[ $(grep '0' $FILE) ]]; then echo "No simulated failures." else + fail=$(<$FILE) echo -n "Simulated failure mode is: " - cat $FILE +# cat $FILE + echo $fail fi else echo "No simulated failures." From 8b7979c057a3cef2fd77486e835c0d4cbea89737 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:06:07 -0400 Subject: [PATCH 043/295] Update config added failure mode description --- config | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/config b/config index 670732b0..568442d8 100755 --- a/config +++ b/config @@ -274,7 +274,7 @@ if [ "$1" = "" ]; then # sim="no" echo "Simulated Telemetry is OFF" fi - echo +# echo FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then @@ -282,14 +282,48 @@ if [ "$1" = "" ]; then echo "No simulated failures." else fail=$(<$FILE) - echo -n "Simulated failure mode is: " + echo -n "Simulated " # cat $FILE - echo $fail + + case $fail in + + 1) + echo "+X Solar Panel Failure." + ;; + 2) + echo "-X Solar Panel Degredation." + ;; + 3) + echo "-Y Solar Panel Short Circuit." + ;; + 4) + echo "Failed I2C Bus 1." + ;; + 5) + echo "Failed I2C Bus 3." + ;; + 6) + echo "Failed Camera." + ;; + 7) + echo "Failed Payload." + ;; + 8) + echo "Failed BME Sensor." + ;; + 9) + echo "Failed MPU Sensor." + ;; + *) + echo "Unknown Failure." + ;; + esac +# echo $fail fi else echo "No simulated failures." fi - echo +# echo if [ "$9" = "yes" ] || [ "$9" = "y" ]; then echo "Balloon mode is ON" @@ -297,10 +331,10 @@ if [ "$1" = "" ]; then echo "Balloon mode is OFF" fi - echo +# echo echo -n "Current command count is: " cat /home/pi/CubeSatSim/command_count.txt - echo +# echo # echo # echo "Current beacon transmit mode is:" # cat /home/pi/CubeSatSim/command_tx @@ -308,7 +342,7 @@ if [ "$1" = "" ]; then echo -n "Squelch level is: " echo $6 - echo +# echo FILE=/home/pi/CubeSatSim/command_control if [ -f "$FILE" ]; then @@ -327,14 +361,14 @@ if [ "$1" = "" ]; then echo "Radio command and control is OFF" fi - echo +# echo echo -n "RX PL code is: " echo -n ${10} # echo echo -n " TX PL code is: " echo ${11} - echo +# echo FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then @@ -343,7 +377,7 @@ if [ "$1" = "" ]; then echo "Battery saver mode is OFF" fi - echo +# echo FILE=/home/pi/CubeSatSim/beacon_off if [ -f "$FILE" ]; then echo "Transmit beacon telemetry is OFF" From f18640942d4875d41e69b2049b2da4808c7ef277 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:09:49 -0400 Subject: [PATCH 044/295] Update config list failure modes in -M --- config | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/config b/config index 568442d8..28f62215 100755 --- a/config +++ b/config @@ -288,34 +288,34 @@ if [ "$1" = "" ]; then case $fail in 1) - echo "+X Solar Panel Failure." + echo "+X Solar Panel Failure" ;; 2) - echo "-X Solar Panel Degredation." + echo "-X Solar Panel Degredation" ;; 3) - echo "-Y Solar Panel Short Circuit." + echo "-Y Solar Panel Short Circuit" ;; 4) - echo "Failed I2C Bus 1." + echo "Failed I2C Bus 1" ;; 5) - echo "Failed I2C Bus 3." + echo "Failed I2C Bus 3" ;; 6) - echo "Failed Camera." + echo "Failed Camera" ;; 7) - echo "Failed Payload." + echo "Failed Payload" ;; 8) - echo "Failed BME Sensor." + echo "Failed BME Sensor" ;; 9) - echo "Failed MPU Sensor." + echo "Failed MPU Sensor" ;; *) - echo "Unknown Failure." + echo "Unknown Failure" ;; esac # echo $fail @@ -1485,7 +1485,18 @@ elif [ "$1" = "-M" ]; then echo "Set simulated failure mode" echo - echo "Enter the failure number to change: 0 - 10" + echo "1 +X Solar Panel Failure" + echo "2 -X Solar Panel Degredation" + echo "3 -Y Solar Panel Short Circuit" + echo "4 Failed I2C Bus 1" + echo "5 Failed I2C Bus 3" + echo "6 Failed Camera" + echo "7 Failed Payload" + echo "8 Failed BME Sensor" + echo "9 Failed MPU Sensor" + echo + + echo "Enter the failure number to change: 0 - 9" read MODE echo From 0b1e06cd848567960541852f8f51adf521edcf58 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:15:02 -0400 Subject: [PATCH 045/295] Update config print result --- config | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/config b/config index 28f62215..4849022b 100755 --- a/config +++ b/config @@ -1485,6 +1485,7 @@ elif [ "$1" = "-M" ]; then echo "Set simulated failure mode" echo + echo "0 No Failure (turn OFF)" echo "1 +X Solar Panel Failure" echo "2 -X Solar Panel Degredation" echo "3 -Y Solar Panel Short Circuit" @@ -1496,12 +1497,51 @@ elif [ "$1" = "-M" ]; then echo "9 Failed MPU Sensor" echo - echo "Enter the failure number to change: 0 - 9" + echo "Enter the failure number to set: 0 - 9" read MODE echo - echo -n "Setting simulated failure mode: " - echo $MODE + if [ "$MODE" = "0" ]; then + echo "Setting No Simulated Failure" + else + echo -n "Setting Simulated " + + case $MODE in + + 1) + echo "+X Solar Panel Failure" + ;; + 2) + echo "-X Solar Panel Degredation" + ;; + 3) + echo "-Y Solar Panel Short Circuit" + ;; + 4) + echo "Failed I2C Bus 1" + ;; + 5) + echo "Failed I2C Bus 3" + ;; + 6) + echo "Failed Camera" + ;; + 7) + echo "Failed Payload" + ;; + 8) + echo "Failed BME Sensor" + ;; + 9) + echo "Failed MPU Sensor" + ;; + *) + echo "Unknown Failure" + ;; + esac + fi + +# echo $MODE echo echo $MODE > /home/pi/CubeSatSim/failure_mode.txt From 06c2b5eeb13cdf6074dbbf3f4d55400f4a9f7c90 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:16:43 -0400 Subject: [PATCH 046/295] Update config extra space --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 4849022b..75d14d4b 100755 --- a/config +++ b/config @@ -1481,7 +1481,7 @@ elif [ "$1" = "-j" ]; then elif [ "$1" = "-M" ]; then - echo +# echo echo "Set simulated failure mode" echo From 8e00fc2596682f131b9824696b4708afc1f38629 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:17:45 -0400 Subject: [PATCH 047/295] Update config remove periods --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index 75d14d4b..7b89d612 100755 --- a/config +++ b/config @@ -279,7 +279,7 @@ if [ "$1" = "" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then if [[ $(grep '0' $FILE) ]]; then - echo "No simulated failures." + echo "No simulated failure." else fail=$(<$FILE) echo -n "Simulated " @@ -321,7 +321,7 @@ if [ "$1" = "" ]; then # echo $fail fi else - echo "No simulated failures." + echo "No simulated failure." fi # echo From e97d06833644da28c62e7aac70a79dc6a64f2b55 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:21:46 -0400 Subject: [PATCH 048/295] Update main.c sim mode random failure --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 99b10c48..87750270 100644 --- a/main.c +++ b/main.c @@ -1277,7 +1277,11 @@ void get_tlm_fox() { } } else failureMode = FAIL_NONE; - + + if (sim_mode && (loop % 10 == 0) { + failureMode = (int) rnd_float(1, FAIL_COUNT); + printf("Sim Mode Random Failure Change\n"); + if (failureMode == FAIL_NONE) printf("No Simulated Failure\n"); if (failureMode == -1) { From 347ce1812341727f0f75448f916db0317367f54b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:22:49 -0400 Subject: [PATCH 049/295] Update main.c typo --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 87750270..bcbc80fc 100644 --- a/main.c +++ b/main.c @@ -1278,10 +1278,11 @@ void get_tlm_fox() { } else failureMode = FAIL_NONE; - if (sim_mode && (loop % 10 == 0) { + if (sim_mode && (loop % 10 == 0)) { failureMode = (int) rnd_float(1, FAIL_COUNT); printf("Sim Mode Random Failure Change\n"); - + } + if (failureMode == FAIL_NONE) printf("No Simulated Failure\n"); if (failureMode == -1) { From fad75038a20be824f6f36dc13e66847543266a30 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:25:31 -0400 Subject: [PATCH 050/295] Update config remove periods --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index 7b89d612..3951c06c 100755 --- a/config +++ b/config @@ -279,7 +279,7 @@ if [ "$1" = "" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then if [[ $(grep '0' $FILE) ]]; then - echo "No simulated failure." + echo "No simulated failure" else fail=$(<$FILE) echo -n "Simulated " @@ -321,7 +321,7 @@ if [ "$1" = "" ]; then # echo $fail fi else - echo "No simulated failure." + echo "No simulated failure" fi # echo From b8b0cc104e851f8c5ffe7a78784d53cf2d95ca0c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:32:54 -0400 Subject: [PATCH 051/295] Update main.h def failureMode --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index 080382f2..ff35b344 100644 --- a/main.h +++ b/main.h @@ -136,6 +136,7 @@ FILE *image_file; #define FAIL_BME 8 #define FAIL_MPU 9 #define FAIL_AUDIO 10 +int failureMode = FAIL_NONE; int transmitStatus = -1; From c63a79cf5f9137b041c2e8d0f6b4a7f8f42be923 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 15:35:54 -0400 Subject: [PATCH 052/295] Update main.c write random failure to file --- main.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index bcbc80fc..1f19c062 100644 --- a/main.c +++ b/main.c @@ -1267,21 +1267,29 @@ void get_tlm_fox() { int buffSize; buffSize = (int) sizeof(buffer_test); - int failureMode = OFF; - FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); - if (failure_mode_file != NULL) { - char failure_string[10]; - if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) { - failureMode = atoi(failure_string); - fclose(failure_mode_file); - } - } else - failureMode = FAIL_NONE; - - if (sim_mode && (loop % 10 == 0)) { + if (sim_mode) { + if (loop % 10 == 0) { failureMode = (int) rnd_float(1, FAIL_COUNT); printf("Sim Mode Random Failure Change\n"); + FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w"); + fprintf(failure_mode_file, "%d", failureMode); + fclose(failure_mode_file); + } + } + else + { + failureMode = OFF; + FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); + if (failure_mode_file != NULL) { + char failure_string[10]; + if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) { + failureMode = atoi(failure_string); + fclose(failure_mode_file); + } + } else + failureMode = FAIL_NONE; } + if (failureMode == FAIL_NONE) printf("No Simulated Failure\n"); @@ -1756,7 +1764,7 @@ void get_tlm_fox() { int i2c_1, i2c_3; i2c_1 = i2c_bus1; i2c_3 = i2c_bus3; - printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3); +// printf("Bus1: %d Bus2: %d \n", i2c_1, i2c_3); if (failureMode == FAIL_I2C1) { i2c_1 = OFF; // printf("I2C Bus 1 Simulated Failure\n"); From 955e24c350aca774eb232738e8230040429c3175 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 18:12:11 -0400 Subject: [PATCH 053/295] Update main.c payload failures at sensor --- main.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 1f19c062..1e1d692c 100644 --- a/main.c +++ b/main.c @@ -684,6 +684,9 @@ int main(int argc, char * argv[]) { fprintf(telem_file, "%s %s %s\n", timeStampNoNl, bat_string, sensor_payload); // write telemetry string to telem.txt file fclose(telem_file); + + if (failureMode == FAIL_PAYLOAD) + sensor_payload[0] = 'X'); // This will cause the payload to not be processed. if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { @@ -701,7 +704,7 @@ int main(int argc, char * argv[]) { // #endif token = strtok(NULL, space); } - } + } printf("\n"); // if (sensor[GPS1] != 0) { @@ -731,7 +734,23 @@ int main(int argc, char * argv[]) { // printf("GPS Location with Rnd: APRS %07.2f, %08.2f \n", toAprsFormat(latitude), toAprsFormat(longitude)); newGpsTime = millis(); } - + + if (failureMode == FAIL_BME) { + sensor[TEMP] = 0.0; + sensor[PRES] = 0.0; + sensor[HUMI] = 0.0; + sensor[ALT] = 0.0; + } + + if (failureMode == FAIL_MPU) { + sensor[ACCEL_X] = 0.0; + sensor[ACCEL_Y] = 0.0; + sensor[ACCEL_Z] = 0.0; + sensor[GYRO_X] = 0.0; + sensor[GYRO_Y] = 0.0; + sensor[GYRO_Z] = 0.0; + } + if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { if (sensor[count1] < sensor_min[count1]) From 179be7789bd54edc2fedcbdaab233288475b2ea7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 18:14:29 -0400 Subject: [PATCH 054/295] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 1e1d692c..bd14fa56 100644 --- a/main.c +++ b/main.c @@ -686,7 +686,7 @@ int main(int argc, char * argv[]) { fclose(telem_file); if (failureMode == FAIL_PAYLOAD) - sensor_payload[0] = 'X'); // This will cause the payload to not be processed. + sensor_payload[0] = 'X'; // This will cause the payload to not be processed. if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { From 44ccfa81c13473e14d7e3f703beb38eb0ea8e09d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 18:24:52 -0400 Subject: [PATCH 055/295] Update main.c move failure set mode out of get_fox_tlm --- main.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/main.c b/main.c index bd14fa56..d0b951d9 100644 --- a/main.c +++ b/main.c @@ -605,6 +605,29 @@ int main(int argc, char * argv[]) { // #endif fclose(uptime_file); + if (sim_mode) { + if (loop % 10 == 0) { + failureMode = (int) rnd_float(1, FAIL_COUNT); + printf("Sim Mode Random Failure Change\n"); + FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w"); + fprintf(failure_mode_file, "%d", failureMode); + fclose(failure_mode_file); + } + } + else + { + failureMode = OFF; + FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); + if (failure_mode_file != NULL) { + char failure_string[10]; + if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) { + failureMode = atoi(failure_string); + fclose(failure_mode_file); + } + } else + failureMode = FAIL_NONE; + } + { int count1; char * token; @@ -1285,30 +1308,6 @@ void get_tlm_fox() { short int buffer_test[bufLen]; int buffSize; buffSize = (int) sizeof(buffer_test); - - if (sim_mode) { - if (loop % 10 == 0) { - failureMode = (int) rnd_float(1, FAIL_COUNT); - printf("Sim Mode Random Failure Change\n"); - FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w"); - fprintf(failure_mode_file, "%d", failureMode); - fclose(failure_mode_file); - } - } - else - { - failureMode = OFF; - FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); - if (failure_mode_file != NULL) { - char failure_string[10]; - if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) { - failureMode = atoi(failure_string); - fclose(failure_mode_file); - } - } else - failureMode = FAIL_NONE; - } - if (failureMode == FAIL_NONE) printf("No Simulated Failure\n"); From 0bc8e6a9c0636f67c7db19afcedfbccc34d9383e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 18:30:32 -0400 Subject: [PATCH 056/295] Update main.c add prints --- main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index d0b951d9..075878af 100644 --- a/main.c +++ b/main.c @@ -623,9 +623,12 @@ int main(int argc, char * argv[]) { if ( (fgets(failure_string, 10, failure_mode_file)) != NULL) { failureMode = atoi(failure_string); fclose(failure_mode_file); + printf("Failure mode: %d\n", failureMode); } - } else + } else { failureMode = FAIL_NONE; + printf("No simulated failure."); + } } { @@ -708,8 +711,10 @@ int main(int argc, char * argv[]) { fprintf(telem_file, "%s %s %s\n", timeStampNoNl, bat_string, sensor_payload); // write telemetry string to telem.txt file fclose(telem_file); - if (failureMode == FAIL_PAYLOAD) + if (failureMode == FAIL_PAYLOAD) { sensor_payload[0] = 'X'; // This will cause the payload to not be processed. + printf("Simulated Payload Failure.\n"); + } if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { @@ -762,7 +767,8 @@ int main(int argc, char * argv[]) { sensor[TEMP] = 0.0; sensor[PRES] = 0.0; sensor[HUMI] = 0.0; - sensor[ALT] = 0.0; + sensor[ALT] = 0.0; + printf("Simulated BME Failure.\n"); } if (failureMode == FAIL_MPU) { @@ -772,6 +778,7 @@ int main(int argc, char * argv[]) { sensor[GYRO_X] = 0.0; sensor[GYRO_Y] = 0.0; sensor[GYRO_Z] = 0.0; + printf("Simulated MPU Failure.\n"); } if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { From 450bcc165736e7a6d6c2ee83e9d589ca3fe8d1a2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 18:44:25 -0400 Subject: [PATCH 057/295] Update main.c add prints --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 075878af..b20a5965 100644 --- a/main.c +++ b/main.c @@ -768,7 +768,7 @@ int main(int argc, char * argv[]) { sensor[PRES] = 0.0; sensor[HUMI] = 0.0; sensor[ALT] = 0.0; - printf("Simulated BME Failure.\n"); + printf("Simulated BME Failure!\n"); } if (failureMode == FAIL_MPU) { @@ -778,10 +778,11 @@ int main(int argc, char * argv[]) { sensor[GYRO_X] = 0.0; sensor[GYRO_Y] = 0.0; sensor[GYRO_Z] = 0.0; - printf("Simulated MPU Failure.\n"); + printf("Simulated MPU Failure!\n"); } if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { + printf("Valid Payload!!\n"); for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { if (sensor[count1] < sensor_min[count1]) sensor_min[count1] = sensor[count1]; From c0f5de40ecbd665bd56c20c662eb7d9346c5e48b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 18:49:20 -0400 Subject: [PATCH 058/295] Update main.c more prints --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index b20a5965..19b59ab5 100644 --- a/main.c +++ b/main.c @@ -718,6 +718,7 @@ int main(int argc, char * argv[]) { if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { + printf("Valid Payload!!\n"); int count1; char * token; From d07eda80b0ea3a8994b9928252ccf1f0efbf2add Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 20:50:45 -0400 Subject: [PATCH 059/295] Update main.c try null --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 19b59ab5..cd0ce95f 100644 --- a/main.c +++ b/main.c @@ -712,7 +712,7 @@ int main(int argc, char * argv[]) { fclose(telem_file); if (failureMode == FAIL_PAYLOAD) { - sensor_payload[0] = 'X'; // This will cause the payload to not be processed. + sensor_payload[0] = '\0'; // This will cause the payload to not be processed. printf("Simulated Payload Failure.\n"); } @@ -1116,6 +1116,7 @@ void get_tlm(void) { // char footer_str[] = "-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by transmit.py char footer_str[] = " && echo 'AMSAT-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by transmit.py char footer_str2[] = " && touch /home/pi/CubeSatSim/ready"; + char zero[] = "0.0"; if (ax5043) { strcpy(str, header_str); From 81794efe36ec9d198dda438af3e9dc5f3da05d5d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 8 Aug 2025 21:00:01 -0400 Subject: [PATCH 060/295] Update main.c remove 2nd get_payload --- main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index cd0ce95f..682fdc7e 100644 --- a/main.c +++ b/main.c @@ -685,12 +685,16 @@ int main(int argc, char * argv[]) { if (!ax5043) { // if ((payload == ON) && (mode != BPSK)) { // moved to here // STEMBoardFailure = 0; + +/**** payload = get_payload_serial(FALSE); printf("get_payload_status: %d \n", payload); // not debug fflush(stdout); // printf("String: %s\n", buffer2); fflush(stdout); - strcpy(sensor_payload, buffer2); + strcpy(sensor_payload, buffer2); +****/ + // printf(" Response from STEM Payload board: %s\n", sensor_payload); telem_file = fopen("/home/pi/CubeSatSim/telem.txt", "a"); @@ -1255,7 +1259,7 @@ void get_tlm(void) { else strcat(str, footer_str2); - fprintf(stderr, "String to execute: %s\n", str); + fprintf(stderr, "APRS String to execute: %s\n", str); printf("\n\nTelemetry string is %s \n\n", str); From b22faca333605a5f8fc8ff75ba9f611d8966cc78 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:06:57 -0400 Subject: [PATCH 061/295] Update main.c remove ax5043 --- main.c | 124 +++++++-------------------------------------------------- 1 file changed, 14 insertions(+), 110 deletions(-) diff --git a/main.c b/main.c index 682fdc7e..ddca91aa 100644 --- a/main.c +++ b/main.c @@ -272,43 +272,7 @@ int main(int argc, char * argv[]) { /**/ fflush(stderr); - - if (mode == AFSK) - { - // Check for SPI and AX-5043 Digital Transceiver Board - FILE * file = popen("sudo raspi-config nonint get_spi", "r"); -// printf("getc: %c \n", fgetc(file)); - if (fgetc(file) == 48) { - printf("SPI is enabled!\n"); - - FILE * file2 = popen("ls /dev/spidev0.* 2>&1", "r"); - printf("Result getc: %c \n", getc(file2)); - - if (fgetc(file2) != 'l') { - printf("SPI devices present!\n"); - // } - - setSpiChannel(SPI_CHANNEL); - setSpiSpeed(SPI_SPEED); - initializeSpi(); - ax25_init( & hax25, (uint8_t * ) dest_addr, 11, (uint8_t * ) call, 11, AX25_PREAMBLE_LEN, AX25_POSTAMBLE_LEN); - if (init_rf()) { - printf("AX5043 successfully initialized!\n"); - ax5043 = TRUE; - cw_id = OFF; -// mode = AFSK; - // cycle = OFF; - printf("Mode AFSK with AX5043\n"); - transmit = TRUE; -// sleep(10); // just in case CW ID is sent - } else - printf("AX5043 not present!\n"); - pclose(file2); - } - } - pclose(file); - } - + txLed = 2; txLedOn = HIGH; txLedOff = LOW; @@ -331,29 +295,12 @@ int main(int argc, char * argv[]) { fclose(config_file); config_file = fopen("sim.cfg", "r"); - if (vB4) { - map[BAT] = BAT2; - map[BAT2] = BAT; - snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); - } else if (vB5) { - map[MINUS_X] = MINUS_Y; - map[PLUS_Z] = MINUS_X; - map[MINUS_Y] = PLUS_Z; - - if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present - printf("/dev/i2c-11 is present\n\n"); - snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(11)); - } else { - snprintf(busStr, 10, "%d %d", i2c_bus1, i2c_bus3); - } - } else { - map[BAT2] = MINUS_Z; - map[BAT] = BAT2; - map[PLUS_Z] = BAT; - map[MINUS_Z] = PLUS_Z; - snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); - voltageThreshold = 8.0; - } + map[BAT2] = MINUS_Z; + map[BAT] = BAT2; + map[PLUS_Z] = BAT; + map[MINUS_Z] = PLUS_Z; + snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); + voltageThreshold = 8.0; // check for camera // char cmdbuffer1[1000]; @@ -373,8 +320,7 @@ int main(int argc, char * argv[]) { //file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1", "r"); pclose(file5); - if (!ax5043) // don't test for payload if AX5043 is present - { + payload = OFF; fprintf(stderr,"Opening serial\n"); if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600 @@ -386,7 +332,7 @@ int main(int argc, char * argv[]) { } else { fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno)); } - } + if ((i2c_bus3 == OFF) || (sim_mode == TRUE)) { @@ -682,7 +628,7 @@ int main(int argc, char * argv[]) { } // if (payload == ON) { // moved to here - if (!ax5043) { + // if ((payload == ON) && (mode != BPSK)) { // moved to here // STEMBoardFailure = 0; @@ -759,7 +705,7 @@ int main(int argc, char * argv[]) { } 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 latitude += rnd_float(-0.05, 0.05) / 100.0; @@ -1044,20 +990,6 @@ int upper_digit(int number) { return digit; } -static int init_rf() { - int ret; - fprintf(stderr, "Initializing AX5043\n"); - - ret = ax5043_init( & hax5043, XTAL_FREQ_HZ, VCO_INTERNAL); - if (ret != PQWS_SUCCESS) { - fprintf(stderr, - "ERROR: Failed to initialize AX5043 with error code %d\n", ret); - // exit(EXIT_FAILURE); - return (0); - } - return (1); -} - void get_tlm(void) { FILE * txResult; @@ -1122,16 +1054,14 @@ void get_tlm(void) { char footer_str2[] = " && touch /home/pi/CubeSatSim/ready"; char zero[] = "0.0"; - if (ax5043) { - strcpy(str, header_str); - } else { + strcpy(str, header_str3); // } if (mode == AFSK) { strcat(str, call); strcat(str, header_str2); } - } + // printf("Str: %s \n", str); if (mode != CW) { // sprintf(header_str2b, "=%7.2f%c%c%c%08.2f%cShi hi ",4003.79,'N',0x5c,0x5c,07534.33,'W'); // add APRS lat and long @@ -1144,9 +1074,6 @@ void get_tlm(void) { else sprintf(header_long, "%08.2f%c",toAprsFormat( longitude) * (-1.0), 'W'); // long - if (ax5043) - sprintf(header_str2b, "=%s%c%sShi hi ", header_lat, 0x5c, header_long); // add APRS lat and long - else //#ifdef HAB if (hab_mode) sprintf(header_str2b, "=%s%c%sOhi hi ", header_lat, 0x2f, header_long); // add APRS lat and long with Balloon HAB icon @@ -1227,30 +1154,7 @@ void get_tlm(void) { sleep(5); } } - else if (ax5043) { - digitalWrite(txLed, txLedOn); - fprintf(stderr, "INFO: Transmitting X.25 packet using AX5043\n"); - memcpy(data, str, strnlen(str, 256)); - printf("data: %s \n", data); - int ret = ax25_tx_frame( & hax25, & hax5043, data, strnlen(str, 256)); - if (ret) { - fprintf(stderr, - "ERROR: Failed to transmit AX.25 frame with error code %d\n", - ret); - exit(EXIT_FAILURE); - } - ax5043_wait_for_transmit(); - digitalWrite(txLed, txLedOff); - - if (ret) { - fprintf(stderr, - "ERROR: Failed to transmit entire AX.25 frame with error code %d\n", - ret); - exit(EXIT_FAILURE); - } - sleep(4); // was 2 - - } else { // APRS using transmit + else { // APRS using transmit strcat(str, footer_str1); // strcat(str, call); From b5d2e688c48f871446146b25ae6d6d0d74319d38 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:08:16 -0400 Subject: [PATCH 062/295] Update main.h remove ax5043 --- main.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.h b/main.h index ff35b344..f46c8537 100644 --- a/main.h +++ b/main.h @@ -73,9 +73,6 @@ uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint8_t data[1024]; uint32_t tx_channel = 0; -ax5043_conf_t hax5043; -ax25_conf_t hax25; - int twosToInt(int val, int len); float toAprsFormat(float input); float rnd_float(double min, double max); @@ -172,7 +169,7 @@ float sleepTime; unsigned int sampleTime = 0; int frames_sent = 0; int cw_id = ON; -int vB4 = FALSE, vB5 = FALSE, vB3 = FALSE, ax5043 = FALSE, transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF; +int vB4 = FALSE, vB5 = FALSE, vB3 = FALSE, transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF; // float voltageThreshold = 3.6, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100; float voltageThreshold = 3.5, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100; float latitude = 39.027702f, longitude = -77.078064f; From 3a1fbb85d71f34d5399201f82185bc35deea864c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:18:31 -0400 Subject: [PATCH 063/295] Update main.c --- main.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/main.c b/main.c index ddca91aa..66ee8ad1 100644 --- a/main.c +++ b/main.c @@ -320,7 +320,6 @@ int main(int argc, char * argv[]) { //file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1", "r"); pclose(file5); - payload = OFF; fprintf(stderr,"Opening serial\n"); if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600 @@ -333,7 +332,6 @@ 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)); } - if ((i2c_bus3 == OFF) || (sim_mode == TRUE)) { sim_mode = TRUE; @@ -627,22 +625,6 @@ int main(int argc, char * argv[]) { } -// if (payload == ON) { // moved to here - -// if ((payload == ON) && (mode != BPSK)) { // moved to here -// STEMBoardFailure = 0; - -/**** - payload = get_payload_serial(FALSE); - printf("get_payload_status: %d \n", payload); // not debug - fflush(stdout); -// printf("String: %s\n", buffer2); - fflush(stdout); - strcpy(sensor_payload, buffer2); -****/ - -// printf(" Response from STEM Payload board: %s\n", sensor_payload); - telem_file = fopen("/home/pi/CubeSatSim/telem.txt", "a"); // printf("Writing payload string\n"); time_t timeStamp; From ede1ef220906d79163aa4fe12a5dcbeb9f23e4ad Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:25:47 -0400 Subject: [PATCH 064/295] Update main.c put back in payload read --- main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 66ee8ad1..723acc6f 100644 --- a/main.c +++ b/main.c @@ -625,6 +625,15 @@ int main(int argc, char * argv[]) { } + payload = get_payload_serial(FALSE); + printf("get_payload_status: %d \n", payload); // not debug + fflush(stdout); +// printf("String: %s\n", buffer2); + fflush(stdout); + strcpy(sensor_payload, buffer2); + + printf(" Response from STEM Payload board: %s\n", sensor_payload); + telem_file = fopen("/home/pi/CubeSatSim/telem.txt", "a"); // printf("Writing payload string\n"); time_t timeStamp; @@ -1111,8 +1120,9 @@ void get_tlm(void) { strcat(str, tlm_str); } - strcpy(sensor_payload, buffer2); - printf(" Response from STEM Payload board:: %s\n", sensor_payload); + +// strcpy(sensor_payload, buffer2); +// printf(" Response from STEM Payload board:: %s\n", sensor_payload); // printf(" Str so far: %s\n", str); if (mode != CW) From 32b9a8f4aa5c273422529bb2adc78ac94d1a08d2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:34:58 -0400 Subject: [PATCH 065/295] Update main.c --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 723acc6f..4bb09e0d 100644 --- a/main.c +++ b/main.c @@ -659,7 +659,7 @@ int main(int argc, char * argv[]) { if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { - printf("Valid Payload!!\n"); + printf("Valid Payload!\n"); int count1; char * token; From fc00d66a4417201ba278683f3260fbe32888403c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:38:13 -0400 Subject: [PATCH 066/295] Update main.c print sensor_payload --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 4bb09e0d..003253b9 100644 --- a/main.c +++ b/main.c @@ -1122,7 +1122,7 @@ void get_tlm(void) { } // strcpy(sensor_payload, buffer2); -// printf(" Response from STEM Payload board:: %s\n", sensor_payload); + printf(" sensor_payload: %s\n", sensor_payload); // printf(" Str so far: %s\n", str); if (mode != CW) From 57ccbbd3f91d1f7e5a12f76c335ad27981660fac Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:48:46 -0400 Subject: [PATCH 067/295] Update main.c restore sensor_payload --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 003253b9..0e44ab71 100644 --- a/main.c +++ b/main.c @@ -675,7 +675,7 @@ int main(int argc, char * argv[]) { token = strtok(NULL, space); } } - + strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation printf("\n"); // if (sensor[GPS1] != 0) { if ((sensor[GPS1] > -90.0) && (sensor[GPS1] < 90.0) && (sensor[GPS1] != 0.0)) { From 73a7c8ba3920606a01ef57570716d28a02ee7854 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 09:59:01 -0400 Subject: [PATCH 068/295] Update main.c recreate sensor_string --- main.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 0e44ab71..34b6910d 100644 --- a/main.c +++ b/main.c @@ -674,8 +674,8 @@ int main(int argc, char * argv[]) { // #endif token = strtok(NULL, space); } - } - strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation + } + printf("\n"); // if (sensor[GPS1] != 0) { if ((sensor[GPS1] > -90.0) && (sensor[GPS1] < 90.0) && (sensor[GPS1] != 0.0)) { @@ -723,6 +723,23 @@ int main(int argc, char * argv[]) { printf("Simulated MPU Failure!\n"); } + if (failureMode == FAIL_BME) { // recreaate sensor_payload string + sensor_payload[0] = 0; + for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { + strcat(sensor_payload, sensor[count1]); +// if (token != NULL) { +// sensor[count1] = (float) atof(token); +// #ifdef DEBUG_LOGGING +// printf("sensor: %f ", sensor[count1]); // print sensor data +// #endif + // token = strtok(NULL, space); + } +// } + printf("New Sensor String: %s\n", sensor_payload); + } + else + strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation + if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { printf("Valid Payload!!\n"); for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { From f000d2f3c499b549da35c64a0b89163449fbd0e0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:08:41 -0400 Subject: [PATCH 069/295] Update main.c add sensor_string --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 34b6910d..22f4a0da 100644 --- a/main.c +++ b/main.c @@ -669,8 +669,10 @@ int main(int argc, char * argv[]) { for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { if (token != NULL) { sensor[count1] = (float) atof(token); + strcpy(sensor_string[count1], token); // #ifdef DEBUG_LOGGING // printf("sensor: %f ", sensor[count1]); // print sensor data + printf("Sensor String %d is %s\n",count1, sensor_string[count1]); // #endif token = strtok(NULL, space); } @@ -724,9 +726,9 @@ int main(int argc, char * argv[]) { } if (failureMode == FAIL_BME) { // recreaate sensor_payload string - sensor_payload[0] = 0; + sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { - strcat(sensor_payload, sensor[count1]); + strcat(sensor_payload, sensor_string[count1]); // if (token != NULL) { // sensor[count1] = (float) atof(token); // #ifdef DEBUG_LOGGING From bf011469ccfafcbdfbea583f8977ea0eaa840c62 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:12:02 -0400 Subject: [PATCH 070/295] Update main.h add sensor_string --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index f46c8537..439032fc 100644 --- a/main.h +++ b/main.h @@ -186,6 +186,7 @@ double eclipse_time; float voltage[9], current[9], sensor[SENSOR_FIELDS], other[3]; char sensor_payload[500]; +char sensor_strings[SENSOR_FIELDS][32]; int test_i2c_bus(int bus); From e45d677bb15fdf3ba6795eefe32a9bde4a803e30 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:15:46 -0400 Subject: [PATCH 071/295] Update main.c fix dimension --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 22f4a0da..3d078f40 100644 --- a/main.c +++ b/main.c @@ -669,10 +669,10 @@ int main(int argc, char * argv[]) { for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { if (token != NULL) { sensor[count1] = (float) atof(token); - strcpy(sensor_string[count1], token); + strcpy(sensor_string[count1][], token); // #ifdef DEBUG_LOGGING // printf("sensor: %f ", sensor[count1]); // print sensor data - printf("Sensor String %d is %s\n",count1, sensor_string[count1]); + printf("Sensor String %d is %s\n",count1, sensor_string[count1][]); // #endif token = strtok(NULL, space); } @@ -728,7 +728,7 @@ int main(int argc, char * argv[]) { if (failureMode == FAIL_BME) { // recreaate sensor_payload string sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { - strcat(sensor_payload, sensor_string[count1]); + strcat(sensor_payload, sensor_string[count1][]); // if (token != NULL) { // sensor[count1] = (float) atof(token); // #ifdef DEBUG_LOGGING From f8d3ab2fc195e417f9e65bb7ab3292010509e1bc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:17:41 -0400 Subject: [PATCH 072/295] Update main.h fix sensor_string --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index 439032fc..10c263d0 100644 --- a/main.h +++ b/main.h @@ -186,7 +186,7 @@ double eclipse_time; float voltage[9], current[9], sensor[SENSOR_FIELDS], other[3]; char sensor_payload[500]; -char sensor_strings[SENSOR_FIELDS][32]; +char sensor_string[SENSOR_FIELDS][32]; int test_i2c_bus(int bus); From 73c45fc9f59d9935ac871db34ba9a9ef15b79796 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:18:12 -0400 Subject: [PATCH 073/295] Update main.c fix sensor_string --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 3d078f40..22f4a0da 100644 --- a/main.c +++ b/main.c @@ -669,10 +669,10 @@ int main(int argc, char * argv[]) { for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { if (token != NULL) { sensor[count1] = (float) atof(token); - strcpy(sensor_string[count1][], token); + strcpy(sensor_string[count1], token); // #ifdef DEBUG_LOGGING // printf("sensor: %f ", sensor[count1]); // print sensor data - printf("Sensor String %d is %s\n",count1, sensor_string[count1][]); + printf("Sensor String %d is %s\n",count1, sensor_string[count1]); // #endif token = strtok(NULL, space); } @@ -728,7 +728,7 @@ int main(int argc, char * argv[]) { if (failureMode == FAIL_BME) { // recreaate sensor_payload string sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { - strcat(sensor_payload, sensor_string[count1][]); + strcat(sensor_payload, sensor_string[count1]); // if (token != NULL) { // sensor[count1] = (float) atof(token); // #ifdef DEBUG_LOGGING From f6c9c3f588b9892a9c25bb272f87cc54ff973713 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:21:33 -0400 Subject: [PATCH 074/295] Update main.c copy 0.0 for failure --- main.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index 22f4a0da..448019ad 100644 --- a/main.c +++ b/main.c @@ -709,9 +709,13 @@ int main(int argc, char * argv[]) { if (failureMode == FAIL_BME) { sensor[TEMP] = 0.0; + strcpy(sensor[TEMP], "0.0"); sensor[PRES] = 0.0; - sensor[HUMI] = 0.0; - sensor[ALT] = 0.0; + strcpy(sensor[PRES], "0.0"); + sensor[HUMI] = 0.0; + strcpy(sensor[HUMI], "0.0"); + sensor[ALT] = 0.0; + strcpy(sensor[ALT], "0.0"); printf("Simulated BME Failure!\n"); } @@ -729,15 +733,8 @@ int main(int argc, char * argv[]) { sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { strcat(sensor_payload, sensor_string[count1]); -// if (token != NULL) { -// sensor[count1] = (float) atof(token); -// #ifdef DEBUG_LOGGING -// printf("sensor: %f ", sensor[count1]); // print sensor data -// #endif - // token = strtok(NULL, space); } -// } - printf("New Sensor String: %s\n", sensor_payload); +// printf("New Sensor String: %s\n", sensor_payload); } else strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation From c2d7cfa1c9b50b627572ca7afc1c1ada15533a0b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:22:19 -0400 Subject: [PATCH 075/295] Update main.c do sensor_string copy --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 448019ad..cec5bf29 100644 --- a/main.c +++ b/main.c @@ -709,13 +709,13 @@ int main(int argc, char * argv[]) { if (failureMode == FAIL_BME) { sensor[TEMP] = 0.0; - strcpy(sensor[TEMP], "0.0"); + strcpy(sensor_string[TEMP], "0.0"); sensor[PRES] = 0.0; - strcpy(sensor[PRES], "0.0"); + strcpy(sensor_string[PRES], "0.0"); sensor[HUMI] = 0.0; - strcpy(sensor[HUMI], "0.0"); + strcpy(sensor_string[HUMI], "0.0"); sensor[ALT] = 0.0; - strcpy(sensor[ALT], "0.0"); + strcpy(sensor_string[ALT], "0.0"); printf("Simulated BME Failure!\n"); } From c7a971405eb480fb71655cd832cde64b032654c6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:26:26 -0400 Subject: [PATCH 076/295] Update main.c add spaces between --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index cec5bf29..656cccf2 100644 --- a/main.c +++ b/main.c @@ -729,10 +729,11 @@ int main(int argc, char * argv[]) { printf("Simulated MPU Failure!\n"); } - if (failureMode == FAIL_BME) { // recreaate sensor_payload string + if (failureMode == FAIL_BME) { // recreaate sensor_payload string sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { strcat(sensor_payload, sensor_string[count1]); + strcat(sensor_payload, " "); } // printf("New Sensor String: %s\n", sensor_payload); } From 3fed63e6e5b9da2846339e8a65ab03766acb5a6a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:27:09 -0400 Subject: [PATCH 077/295] Update main.c comment on sensor_string print --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 656cccf2..f6273585 100644 --- a/main.c +++ b/main.c @@ -672,7 +672,7 @@ int main(int argc, char * argv[]) { strcpy(sensor_string[count1], token); // #ifdef DEBUG_LOGGING // printf("sensor: %f ", sensor[count1]); // print sensor data - printf("Sensor String %d is %s\n",count1, sensor_string[count1]); +// printf("Sensor String %d is %s\n",count1, sensor_string[count1]); // #endif token = strtok(NULL, space); } From 9daa2d89dbfd8c09251308f49e5c806414ad7164 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:32:12 -0400 Subject: [PATCH 078/295] Update main.c add MPU fail --- main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index f6273585..b529578a 100644 --- a/main.c +++ b/main.c @@ -721,15 +721,21 @@ int main(int argc, char * argv[]) { if (failureMode == FAIL_MPU) { sensor[ACCEL_X] = 0.0; - sensor[ACCEL_Y] = 0.0; + strcpy(sensor_string[ACCEL_X], "0.0"); + sensor[ACCEL_Y] = 0.0; + strcpy(sensor_string[ACCEL_Y], "0.0"); sensor[ACCEL_Z] = 0.0; + strcpy(sensor_string[ACCEL_Z], "0.0"); sensor[GYRO_X] = 0.0; + strcpy(sensor_string[GYRO_X], "0.0"); sensor[GYRO_Y] = 0.0; - sensor[GYRO_Z] = 0.0; + strcpy(sensor_string[GYRO_Y], "0.0"); + sensor[GYRO_Z] = 0.0; + strcpy(sensor_string[GYRO_Z], "0.0"); printf("Simulated MPU Failure!\n"); } - if (failureMode == FAIL_BME) { // recreaate sensor_payload string + if ((failureMode == FAIL_BME) || (failureMode == FAIL_MPU)) { // recreaate sensor_payload string sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { strcat(sensor_payload, sensor_string[count1]); From bb81401c88a9fea8880240ee53c7e9ea41118226 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:39:18 -0400 Subject: [PATCH 079/295] Update main.c don't recreate string if payload fail --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index b529578a..14ebee33 100644 --- a/main.c +++ b/main.c @@ -743,7 +743,7 @@ int main(int argc, char * argv[]) { } // printf("New Sensor String: %s\n", sensor_payload); } - else + else (failureMode != FAIL_PAYLOAD) strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { From a6d23cdcd750e97b3537ca5dbd25664b74970410 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:40:35 -0400 Subject: [PATCH 080/295] Update main.c --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 14ebee33..fccfccb2 100644 --- a/main.c +++ b/main.c @@ -735,7 +735,8 @@ 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)) // recreaate sensor_payload string + { sensor_payload[0] = 0; for (count1 = 0; count1 < SENSOR_FIELDS; count1++) { strcat(sensor_payload, sensor_string[count1]); @@ -743,7 +744,7 @@ int main(int argc, char * argv[]) { } // printf("New Sensor String: %s\n", sensor_payload); } - else (failureMode != FAIL_PAYLOAD) + else if (failureMode != FAIL_PAYLOAD) strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { From b9e1933e2b0b1af04a8357ac7b55c55474251922 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:52:36 -0400 Subject: [PATCH 081/295] Update main.c remove extra fail ifs --- main.c | 116 +++++---------------------------------------------------- 1 file changed, 9 insertions(+), 107 deletions(-) diff --git a/main.c b/main.c index fccfccb2..e0df490a 100644 --- a/main.c +++ b/main.c @@ -1434,25 +1434,12 @@ void get_tlm_fox() { // encodeB(b, 1 + head_offset, batt_b_v); encodeA(b, 3 + head_offset, batt_c_v); - - if ((failureMode == FAIL_MPU) || (failureMode == FAIL_PAYLOAD)) - { - encodeB(b, 4 + head_offset, 2048); // 0 - encodeA(b, 6 + head_offset, 2048); // 0 - encodeB(b, 7 + head_offset, 2048); // 0 - } - else - { encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel - } encodeA(b, 9 + head_offset, battCurr); - if ((failureMode != FAIL_PAYLOAD) && (failureMode != FAIL_BME)) - encodeB(b, 10 + head_offset, (int)(sensor[TEMP] * 10 + 0.5)); // Temp - if (mode == FSK) { encodeA(b, 12 + head_offset, posXv); encodeB(b, 13 + head_offset, negXv); @@ -1506,39 +1493,22 @@ void get_tlm_fox() { encodeA(b_max, 39 + head_offset, (int)(other_max[IHU_TEMP] * 10 + 0.5)); encodeB(b_max, 31 + head_offset, ((int)(other_max[SPIN] * 10)) + 2048); - if (failureMode != FAIL_PAYLOAD) { if (sensor_min[TEMP] != 1000.0) // make sure values are valid { - if (failureMode != FAIL_MPU) { - encodeB(b_max, 4 + head_offset, (int)(sensor_max[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b_max, 6 + head_offset, (int)(sensor_max[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b_max, 7 + head_offset, (int)(sensor_max[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel - encodeB(b_max, 40 + head_offset, (int)(sensor_max[GYRO_X] + 0.5) + 2048); - encodeA(b_max, 42 + head_offset, (int)(sensor_max[GYRO_Y] + 0.5) + 2048); - encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048); - } - else - { + encodeB(b_max, 4 + head_offset, 2048); // 0 encodeA(b_max, 6 + head_offset, 2048); // 0 encodeB(b_max, 7 + head_offset, 2048); // 0 encodeB(b_max, 40 + head_offset, 2048); encodeA(b_max, 42 + head_offset, 2048); encodeB(b_max, 43 + head_offset, 2048); - } - if (failureMode != FAIL_BME) { - encodeA(b_max, 33 + head_offset, (int)(sensor_max[PRES] + 0.5)); // Pressure - encodeB(b_max, 34 + head_offset, (int)(sensor_max[ALT] * 10.0 + 0.5)); // Altitude - // encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048); - encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); - encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5)); - } + encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048); encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1])); encodeA(b_max, 0 + head_offset, (int)(sensor_max[XS2])); encodeB(b_max, 1 + head_offset, (int)(sensor_max[XS3])); - } + else { encodeB(b_max, 4 + head_offset, 2048); // 0 @@ -1551,17 +1521,7 @@ void get_tlm_fox() { encodeA(b_max, 48 + head_offset, 2048); // encodeB(b_max, 49 + head_offset, 2048); } - } - else - { - encodeB(b_max, 4 + head_offset, 2048); // 0 - encodeA(b_max, 6 + head_offset, 2048); // 0 - encodeB(b_max, 7 + head_offset, 2048); // 0 - encodeB(b_max, 40 + head_offset, 2048); - encodeA(b_max, 42 + head_offset, 2048); - encodeB(b_max, 43 + head_offset, 2048); - encodeA(b_max, 48 + head_offset, 2048); - } + encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100)); encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100)); encodeA(b_min, 15 + head_offset, (int)(voltage_min[map[PLUS_Z]] * 100)); @@ -1585,33 +1545,16 @@ void get_tlm_fox() { encodeB(b_min, 37 + head_offset, (int)(other_min[RSSI] + 0.5) + 2048); encodeA(b_min, 39 + head_offset, (int)(other_min[IHU_TEMP] * 10 + 0.5)); - if (failureMode != FAIL_PAYLOAD) { if (sensor_min[TEMP] != 1000.0) // make sure values are valid { - if (failureMode != FAIL_MPU) - { - encodeB(b_min, 4 + head_offset, (int)(sensor_min[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b_min, 6 + head_offset, (int)(sensor_min[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b_min, 7 + head_offset, (int)(sensor_min[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel - encodeB(b_min, 40 + head_offset, (int)(sensor_min[GYRO_X] + 0.5) + 2048); - encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048); - encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048); - } - else - { encodeB(b_min, 4 + head_offset, 2048); // 0 encodeA(b_min, 6 + head_offset, 2048); // 0 encodeB(b_min, 7 + head_offset, 2048); // 0 encodeB(b_min, 40 + head_offset, 2048); encodeA(b_min, 42 + head_offset, 2048); encodeB(b_min, 43 + head_offset, 2048); - } - if (failureMode != FAIL_BME) { - encodeA(b_min, 33 + head_offset, (int)(sensor_min[PRES] + 0.5)); // Pressure - encodeB(b_min, 34 + head_offset, (int)(sensor_min[ALT] * 10.0 + 0.5)); // Altitude - encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); - encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5)); - } + + encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048); // encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048); @@ -1633,64 +1576,23 @@ void get_tlm_fox() { encodeA(b_min, 48 + head_offset, 2048); // encodeB(b_min, 49 + head_offset, 2048); } - } - else - { - encodeB(b_min, 4 + head_offset, 2048); // 0 - encodeA(b_min, 6 + head_offset, 2048); // 0 - encodeB(b_min, 7 + head_offset, 2048); // 0 - - encodeB(b_min, 40 + head_offset, 2048); - encodeA(b_min, 42 + head_offset, 2048); - encodeB(b_min, 43 + head_offset, 2048); - - encodeA(b_min, 48 + head_offset, 2048); - } - } +// } encodeA(b, 30 + head_offset, BAT2Voltage); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); - - if (failureMode != FAIL_PAYLOAD) { - if (failureMode != FAIL_BME) { - encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure - encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude - encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 - encodeA(b, 39 + head_offset, (int)(other[TEMP] * 10 + 0.5)); - } + encodeA(b, 36 + head_offset, Resets); encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048); - if (failureMode != FAIL_MPU) { encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048); encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048); encodeB(b, 43 + head_offset, (int)(sensor[GYRO_Z] + 0.5) + 2048); - } - else - { - encodeB(b, 40 + head_offset, 2048); - encodeA(b, 42 + head_offset, 2048); - encodeB(b, 43 + head_offset, 2048); - } encodeA(b, 48 + head_offset, (int)(sensor[DTEMP] * 10 + 0.5) + 2048); encodeB(b, 49 + head_offset, (int)(sensor[XS1])); encodeA(b, 0 + head_offset, (int)(sensor[XS2])); encodeB(b, 1 + head_offset, (int)(sensor[XS3])); - } - else - { - encodeB(b, 4 + head_offset, 2048); // 0 - encodeA(b, 6 + head_offset, 2048); // 0 - encodeB(b, 7 + head_offset, 2048); // 0 - - encodeB(b, 40 + head_offset, 2048); - encodeA(b, 42 + head_offset, 2048); - encodeB(b, 43 + head_offset, 2048); - - encodeA(b, 48 + head_offset, 2048); -// encodeB(b_min, 49 + head_offset, 2048); - } + encodeB(b, 46 + head_offset, BAT2Current); encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); From 04ed97c829686f15d86bf75691d089ccee081a13 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:53:46 -0400 Subject: [PATCH 082/295] Update main.c fix missing } --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index e0df490a..7a8c9efb 100644 --- a/main.c +++ b/main.c @@ -1576,7 +1576,7 @@ void get_tlm_fox() { encodeA(b_min, 48 + head_offset, 2048); // encodeB(b_min, 49 + head_offset, 2048); } -// } + } encodeA(b, 30 + head_offset, BAT2Voltage); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); From ae419945fcba1fa02d5279606fcadd8674b57e88 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 10:57:50 -0400 Subject: [PATCH 083/295] Update main.c missing } --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 7a8c9efb..a337952f 100644 --- a/main.c +++ b/main.c @@ -1508,7 +1508,7 @@ void get_tlm_fox() { encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1])); encodeA(b_max, 0 + head_offset, (int)(sensor_max[XS2])); encodeB(b_max, 1 + head_offset, (int)(sensor_max[XS3])); - + } else { encodeB(b_max, 4 + head_offset, 2048); // 0 From f44893cee7966aad23fe771c34d14328cff6cefa Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 11:06:45 -0400 Subject: [PATCH 084/295] Update main.c fix extra zeros --- main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index a337952f..98c12eeb 100644 --- a/main.c +++ b/main.c @@ -1496,12 +1496,12 @@ void get_tlm_fox() { if (sensor_min[TEMP] != 1000.0) // make sure values are valid { - encodeB(b_max, 4 + head_offset, 2048); // 0 - encodeA(b_max, 6 + head_offset, 2048); // 0 - encodeB(b_max, 7 + head_offset, 2048); // 0 - encodeB(b_max, 40 + head_offset, 2048); - encodeA(b_max, 42 + head_offset, 2048); - encodeB(b_max, 43 + head_offset, 2048); + encodeB(b_max, 4 + head_offset, (int)(sensor_max[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b_max, 6 + head_offset, (int)(sensor_max[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b_max, 7 + head_offset, (int)(sensor_max[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + encodeB(b_max, 40 + head_offset, (int)(sensor_max[GYRO_X] + 0.5) + 2048); + encodeA(b_max, 42 + head_offset, (int)(sensor_max[GYRO_Y] + 0.5) + 2048); + encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048); encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048); @@ -1547,12 +1547,12 @@ void get_tlm_fox() { if (sensor_min[TEMP] != 1000.0) // make sure values are valid { - encodeB(b_min, 4 + head_offset, 2048); // 0 - encodeA(b_min, 6 + head_offset, 2048); // 0 - encodeB(b_min, 7 + head_offset, 2048); // 0 - encodeB(b_min, 40 + head_offset, 2048); - encodeA(b_min, 42 + head_offset, 2048); - encodeB(b_min, 43 + head_offset, 2048); + encodeB(b_min, 4 + head_offset, (int)(sensor_min[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b_min, 6 + head_offset, (int)(sensor_min[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b_min, 7 + head_offset, (int)(sensor_min[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + encodeB(b_min, 40 + head_offset, (int)(sensor_min[GYRO_X] + 0.5) + 2048); + encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048); + encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048); encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048); From b9b440f6681ba04c273f3e8cb1dd3de5ddf9620f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 11:16:51 -0400 Subject: [PATCH 085/295] Update main.c added BME back --- main.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 98c12eeb..ff1a955a 100644 --- a/main.c +++ b/main.c @@ -1434,12 +1434,14 @@ void get_tlm_fox() { // encodeB(b, 1 + head_offset, batt_b_v); encodeA(b, 3 + head_offset, batt_c_v); - encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + encodeB(b, 4 + head_offset, (int)(sensor[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b, 6 + head_offset, (int)(sensor[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b, 7 + head_offset, (int)(sensor[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel encodeA(b, 9 + head_offset, battCurr); + encodeB(b, 10 + head_offset, (int)(sensor[TEMP] * 10 + 0.5)); // Temp + if (mode == FSK) { encodeA(b, 12 + head_offset, posXv); encodeB(b, 13 + head_offset, negXv); @@ -1520,7 +1522,13 @@ void get_tlm_fox() { encodeA(b_max, 48 + head_offset, 2048); // encodeB(b_max, 49 + head_offset, 2048); - } + } + + encodeA(b_max, 33 + head_offset, (int)(sensor_max[PRES] + 0.5)); // Pressure + encodeB(b_max, 34 + head_offset, (int)(sensor_max[ALT] * 10.0 + 0.5)); // Altitude + // encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048); + encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); + encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5)); encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100)); encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100)); @@ -1576,10 +1584,19 @@ void get_tlm_fox() { encodeA(b_min, 48 + head_offset, 2048); // encodeB(b_min, 49 + head_offset, 2048); } + encodeA(b_min, 33 + head_offset, (int)(sensor_min[PRES] + 0.5)); // Pressure + encodeB(b_min, 34 + head_offset, (int)(sensor_min[ALT] * 10.0 + 0.5)); // Altitude + encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); + encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5)); } encodeA(b, 30 + head_offset, BAT2Voltage); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); + + encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure + encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude + encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 + encodeA(b, 39 + head_offset, (int)(other[TEMP] * 10 + 0.5)); encodeA(b, 36 + head_offset, Resets); encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048); From e7fe85856ac278c7201d938edc4cb1ddff420031 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 12:07:25 -0400 Subject: [PATCH 086/295] Update main.c cleanup --- main.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/main.c b/main.c index ff1a955a..443423e0 100644 --- a/main.c +++ b/main.c @@ -1504,7 +1504,12 @@ void get_tlm_fox() { encodeB(b_max, 40 + head_offset, (int)(sensor_max[GYRO_X] + 0.5) + 2048); encodeA(b_max, 42 + head_offset, (int)(sensor_max[GYRO_Y] + 0.5) + 2048); encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048); - + + encodeA(b_max, 33 + head_offset, (int)(sensor_max[PRES] + 0.5)); // Pressure + encodeB(b_max, 34 + head_offset, (int)(sensor_max[ALT] * 10.0 + 0.5)); // Altitude + // encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048); + encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); + encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5)); encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048); encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1])); @@ -1524,12 +1529,6 @@ void get_tlm_fox() { // encodeB(b_max, 49 + head_offset, 2048); } - encodeA(b_max, 33 + head_offset, (int)(sensor_max[PRES] + 0.5)); // Pressure - encodeB(b_max, 34 + head_offset, (int)(sensor_max[ALT] * 10.0 + 0.5)); // Altitude - // encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048); - encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); - encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5)); - encodeA(b_min, 12 + head_offset, (int)(voltage_min[map[PLUS_X]] * 100)); encodeB(b_min, 13 + head_offset, (int)(voltage_min[map[PLUS_Y]] * 100)); encodeA(b_min, 15 + head_offset, (int)(voltage_min[map[PLUS_Z]] * 100)); @@ -1555,14 +1554,17 @@ void get_tlm_fox() { if (sensor_min[TEMP] != 1000.0) // make sure values are valid { - encodeB(b_min, 4 + head_offset, (int)(sensor_min[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel - encodeA(b_min, 6 + head_offset, (int)(sensor_min[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel - encodeB(b_min, 7 + head_offset, (int)(sensor_min[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel - encodeB(b_min, 40 + head_offset, (int)(sensor_min[GYRO_X] + 0.5) + 2048); - encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048); - encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048); + encodeB(b_min, 4 + head_offset, (int)(sensor_min[ACCEL_X] * 100 + 0.5) + 2048); // Xaccel + encodeA(b_min, 6 + head_offset, (int)(sensor_min[ACCEL_Y] * 100 + 0.5) + 2048); // Yaccel + encodeB(b_min, 7 + head_offset, (int)(sensor_min[ACCEL_Z] * 100 + 0.5) + 2048); // Zaccel + encodeB(b_min, 40 + head_offset, (int)(sensor_min[GYRO_X] + 0.5) + 2048); + encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048); + encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048); - + encodeA(b_min, 33 + head_offset, (int)(sensor_min[PRES] + 0.5)); // Pressure + encodeB(b_min, 34 + head_offset, (int)(sensor_min[ALT] * 10.0 + 0.5)); // Altitude + encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); + encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5)); encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048); // encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048); @@ -1584,10 +1586,7 @@ void get_tlm_fox() { encodeA(b_min, 48 + head_offset, 2048); // encodeB(b_min, 49 + head_offset, 2048); } - encodeA(b_min, 33 + head_offset, (int)(sensor_min[PRES] + 0.5)); // Pressure - encodeB(b_min, 34 + head_offset, (int)(sensor_min[ALT] * 10.0 + 0.5)); // Altitude - encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); - encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5)); + } encodeA(b, 30 + head_offset, BAT2Voltage); From 59afdf38533dab307d0acf4c233e135e1deab911 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 14:30:38 -0400 Subject: [PATCH 087/295] Update main.c battery prints --- main.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index 443423e0..3e26914b 100644 --- a/main.c +++ b/main.c @@ -299,7 +299,7 @@ int main(int argc, char * argv[]) { map[BAT] = BAT2; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); + snprintf(busStr, 10, "Bus test: %d %d", i2c_bus1, test_i2c_bus(0)); voltageThreshold = 8.0; // check for camera @@ -591,7 +591,7 @@ int main(int argc, char * argv[]) { if (token != NULL) { voltage[count1] = (float) atof(token); #ifdef DEBUG_LOGGING -// printf("voltage: %f ", voltage[count1]); + printf("voltage: %f ", voltage[count1]); #endif token = strtok(NULL, space); if (token != NULL) { @@ -605,22 +605,22 @@ int main(int argc, char * argv[]) { } } if (voltage[map[BAT]] == 0.0) // No BAT Board - if (voltage[map[BAT2]] == 0.0) // No BAT2 Board - batteryVoltage = 4.5; - else { - batteryVoltage = voltage[map[BAT2]]; // only BAT2 Board present + if (voltage[map[BAT2]] == 0.0) // No BAT2 Board + batteryVoltage = 4.5; + else { + batteryVoltage = voltage[map[BAT2]]; // only BAT2 Board present + if (sim_mode && !sim_config) { // if Voltage sensor on Battery board is present, exit simulated telemetry mode + sim_mode = FALSE; + fprintf(stderr, "Turning off sim_mode since battery sensor 2 is present\n"); + } + } + else { + batteryVoltage = voltage[map[BAT]]; // BAT Board present if (sim_mode && !sim_config) { // if Voltage sensor on Battery board is present, exit simulated telemetry mode sim_mode = FALSE; - fprintf(stderr, "Turning off sim_mode since battery sensor 2 is present\n"); + fprintf(stderr, "Turning off sim_mode since battery sensor is present\n"); } } - else { - batteryVoltage = voltage[map[BAT]]; // BAT Board present - if (sim_mode && !sim_config) { // if Voltage sensor on Battery board is present, exit simulated telemetry mode - sim_mode = FALSE; - fprintf(stderr, "Turning off sim_mode since battery sensor is present\n"); - } - } batteryCurrent = current[map[BAT]] + current[map[BAT2]]; // Sum BAT and BAT2 currents } From f871bd162a0151c05fade9a44cb3c560e063a3b0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 14:38:33 -0400 Subject: [PATCH 088/295] Update main.c remove string --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 3e26914b..5c59764f 100644 --- a/main.c +++ b/main.c @@ -299,7 +299,7 @@ int main(int argc, char * argv[]) { map[BAT] = BAT2; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - snprintf(busStr, 10, "Bus test: %d %d", i2c_bus1, test_i2c_bus(0)); + snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); voltageThreshold = 8.0; // check for camera @@ -560,7 +560,7 @@ int main(int argc, char * argv[]) { } else { - failureMode = OFF; +// failureMode = OFF; FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); if (failure_mode_file != NULL) { char failure_string[10]; @@ -571,7 +571,7 @@ int main(int argc, char * argv[]) { } } else { failureMode = FAIL_NONE; - printf("No simulated failure."); + printf("No simulated failure.\n"); } } From 6cebaea2dabdc65e17636f4947ade07fe768d4a2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 14:42:45 -0400 Subject: [PATCH 089/295] Update main.c manually set bus string --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 5c59764f..681d3b9b 100644 --- a/main.c +++ b/main.c @@ -299,7 +299,8 @@ int main(int argc, char * argv[]) { map[BAT] = BAT2; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); +// snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); + strcpy(busStr,"1 3"); voltageThreshold = 8.0; // check for camera From 6ad6f5ce0c4b57b59ef5d947719af83cee5ef0ed Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 14:48:28 -0400 Subject: [PATCH 090/295] Update main.c revert VB4 and 5 code --- main.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 681d3b9b..5df9ddb2 100644 --- a/main.c +++ b/main.c @@ -295,13 +295,29 @@ int main(int argc, char * argv[]) { fclose(config_file); config_file = fopen("sim.cfg", "r"); - map[BAT2] = MINUS_Z; - map[BAT] = BAT2; - map[PLUS_Z] = BAT; - map[MINUS_Z] = PLUS_Z; -// snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); - strcpy(busStr,"1 3"); - voltageThreshold = 8.0; +if (vB4) { + map[BAT] = BAT2; + map[BAT2] = BAT; + snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); + } else if (vB5) { + map[MINUS_X] = MINUS_Y; + map[PLUS_Z] = MINUS_X; + map[MINUS_Y] = PLUS_Z; + + if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present + printf("/dev/i2c-11 is present\n\n"); + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(11)); + } else { + snprintf(busStr, 10, "%d %d", i2c_bus1, i2c_bus3); + } + } else { + map[BAT2] = MINUS_Z; + map[BAT] = BAT2; + map[PLUS_Z] = BAT; + map[MINUS_Z] = PLUS_Z; + snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); + voltageThreshold = 8.0; + } // check for camera // char cmdbuffer1[1000]; From 8315483e6248721f8a3fea772420c58cd336c676 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 14:51:46 -0400 Subject: [PATCH 091/295] Update main.c remove VB5 --- main.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/main.c b/main.c index 5df9ddb2..4f16a486 100644 --- a/main.c +++ b/main.c @@ -276,7 +276,6 @@ int main(int argc, char * argv[]) { txLed = 2; txLedOn = HIGH; txLedOff = LOW; - vB5 = TRUE; onLed = 27; onLedOn = HIGH; onLedOff = LOW; @@ -295,29 +294,17 @@ int main(int argc, char * argv[]) { fclose(config_file); config_file = fopen("sim.cfg", "r"); -if (vB4) { - map[BAT] = BAT2; - map[BAT2] = BAT; - snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); - } else if (vB5) { - map[MINUS_X] = MINUS_Y; - map[PLUS_Z] = MINUS_X; - map[MINUS_Y] = PLUS_Z; + map[MINUS_X] = MINUS_Y; + map[PLUS_Z] = MINUS_X; + map[MINUS_Y] = PLUS_Z; - if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present + if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present printf("/dev/i2c-11 is present\n\n"); snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(11)); - } else { - snprintf(busStr, 10, "%d %d", i2c_bus1, i2c_bus3); - } } else { - map[BAT2] = MINUS_Z; - map[BAT] = BAT2; - map[PLUS_Z] = BAT; - map[MINUS_Z] = PLUS_Z; - snprintf(busStr, 10, "%d %d", i2c_bus1, test_i2c_bus(0)); - voltageThreshold = 8.0; + snprintf(busStr, 10, "%d %d", i2c_bus1, i2c_bus3); } + // check for camera // char cmdbuffer1[1000]; From 505a4c4b3e6296ea38ab6fdb9d260b292afd6e11 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 14:52:34 -0400 Subject: [PATCH 092/295] Update main.h remove VB 3, 4, and 5 --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index 10c263d0..b0f9ca91 100644 --- a/main.h +++ b/main.h @@ -169,7 +169,7 @@ float sleepTime; unsigned int sampleTime = 0; int frames_sent = 0; int cw_id = ON; -int vB4 = FALSE, vB5 = FALSE, vB3 = FALSE, transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF; +int transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF; // float voltageThreshold = 3.6, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100; float voltageThreshold = 3.5, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100; float latitude = 39.027702f, longitude = -77.078064f; From c4a83c1136148b762fdd93d7715029a95ceab44e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:02:48 -0400 Subject: [PATCH 093/295] Update main.c fix deg --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 4f16a486..1b7e7b03 100644 --- a/main.c +++ b/main.c @@ -1259,8 +1259,8 @@ void get_tlm_fox() { printf("+X Solar Simulated Failure\n"); } if (failureMode == FAIL_DEGRADE) { - voltage[map[MINUS_X]] = voltage[MINUS_X] * 0.5; - current[map[MINUS_X]] = current[MINUS_X] * 0.5; + voltage[map[MINUS_X]] = voltage[map[MINUS_X]] * 0.5; + current[map[MINUS_X]] = current[map[MINUS_X]] * 0.5; printf("-X Solar Deg Simulated Failure\n"); } if (failureMode == FAIL_SHORT) { From 28fe1af15fa0a97a73f21b05039f7f0be6add45f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:19:04 -0400 Subject: [PATCH 094/295] Update main.c cleanup --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 1b7e7b03..1f4a8e4e 100644 --- a/main.c +++ b/main.c @@ -595,7 +595,7 @@ int main(int argc, char * argv[]) { if (token != NULL) { voltage[count1] = (float) atof(token); #ifdef DEBUG_LOGGING - printf("voltage: %f ", voltage[count1]); +// printf("voltage: %f ", voltage[count1]); #endif token = strtok(NULL, space); if (token != NULL) { @@ -663,7 +663,7 @@ int main(int argc, char * argv[]) { if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { - printf("Valid Payload!\n"); +// printf("Valid Payload!\n"); int count1; char * token; @@ -752,7 +752,7 @@ int main(int argc, char * argv[]) { strcpy(sensor_payload, buffer2); // restore sensor_payload after strtok operation if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { - printf("Valid Payload!!\n"); +// printf("Valid Payload!!\n"); for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { if (sensor[count1] < sensor_min[count1]) sensor_min[count1] = sensor[count1]; From 2e4dd784be4327928de446f67e4c0fdc697005ab Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:24:01 -0400 Subject: [PATCH 095/295] Update config print sim fail mode with -M --- config | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/config b/config index 3951c06c..dd3dd279 100755 --- a/config +++ b/config @@ -1482,6 +1482,53 @@ elif [ "$1" = "-j" ]; then elif [ "$1" = "-M" ]; then # echo + + echo + FILE=/home/pi/CubeSatSim/failure_mode.txt + if [ -f "$FILE" ]; then + if [[ $(grep '0' $FILE) ]]; then + echo "Currently, no simulated failure" + else + fail=$(<$FILE) + echo -n "Currenly, simulated " + case $fail in + + 1) + echo "+X Solar Panel Failure" + ;; + 2) + echo "-X Solar Panel Degredation" + ;; + 3) + echo "-Y Solar Panel Short Circuit" + ;; + 4) + echo "Failed I2C Bus 1" + ;; + 5) + echo "Failed I2C Bus 3" + ;; + 6) + echo "Failed Camera" + ;; + 7) + echo "Failed Payload" + ;; + 8) + echo "Failed BME Sensor" + ;; + 9) + echo "Failed MPU Sensor" + ;; + *) + echo "Unknown Failure" + ;; + esac + else + echo "Currently, no simulated failure" + fi + + MODE=0 echo "Set simulated failure mode" echo From ab310aff50676618022d9619c319960d8bb11885 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:27:03 -0400 Subject: [PATCH 096/295] Update config --- config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config b/config index dd3dd279..f0b38bfc 100755 --- a/config +++ b/config @@ -1523,7 +1523,8 @@ elif [ "$1" = "-M" ]; then *) echo "Unknown Failure" ;; - esac + esac + fi else echo "Currently, no simulated failure" fi From 97b192a97637ac89dfeac1c184fa8f026d4d3c33 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:31:51 -0400 Subject: [PATCH 097/295] Update config fix return --- config | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/config b/config index f0b38bfc..ceea279a 100755 --- a/config +++ b/config @@ -1529,7 +1529,6 @@ elif [ "$1" = "-M" ]; then echo "Currently, no simulated failure" fi - MODE=0 echo "Set simulated failure mode" echo @@ -1551,40 +1550,39 @@ elif [ "$1" = "-M" ]; then echo if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" - else - echo -n "Setting Simulated " - + else case $MODE in 1) - echo "+X Solar Panel Failure" + echo "Setting Simulated +X Solar Panel Failure" ;; 2) - echo "-X Solar Panel Degredation" + echo "Setting Simulated -X Solar Panel Degredation" ;; 3) - echo "-Y Solar Panel Short Circuit" + echo "Setting Simulated -Y Solar Panel Short Circuit" ;; 4) - echo "Failed I2C Bus 1" + echo "Setting Simulated Failed I2C Bus 1" ;; 5) - echo "Failed I2C Bus 3" + echo "Setting Simulated Failed I2C Bus 3" ;; 6) - echo "Failed Camera" + echo "Setting Simulated Failed Camera" ;; 7) - echo "Failed Payload" + echo "Setting Simulated Failed Payload" ;; 8) - echo "Failed BME Sensor" + echo "Setting Simulated Failed BME Sensor" ;; 9) - echo "Failed MPU Sensor" + echo "Setting Simulated Failed MPU Sensor" ;; *) - echo "Unknown Failure" + echo "Setting No Simulated Failure" + MODE=0 ;; esac fi From b1e750eafe8a60d7e036c8a30b64c6b2d8f068c6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:32:51 -0400 Subject: [PATCH 098/295] Update config remove space --- config | 3 --- 1 file changed, 3 deletions(-) diff --git a/config b/config index ceea279a..59d99a6f 100755 --- a/config +++ b/config @@ -1481,9 +1481,6 @@ elif [ "$1" = "-j" ]; then elif [ "$1" = "-M" ]; then -# echo - - echo FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then if [[ $(grep '0' $FILE) ]]; then From af408a3996225cd36952033fb5a7b9730898786a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:34:11 -0400 Subject: [PATCH 099/295] Update config extra blank line --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 59d99a6f..2d44b72e 100755 --- a/config +++ b/config @@ -1526,6 +1526,7 @@ elif [ "$1" = "-M" ]; then echo "Currently, no simulated failure" fi + echo echo "Set simulated failure mode" echo From d6821ea90ed7fe06d478ee0841fb127e39161663 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:40:44 -0400 Subject: [PATCH 100/295] Update main.c create cam variable --- main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 1f4a8e4e..f8dfc146 100644 --- a/main.c +++ b/main.c @@ -1214,6 +1214,7 @@ void get_tlm_fox() { int i; long int sync = syncWord; + int cam = ON; smaller = (int) (S_RATE / (2 * freq_Hz)); @@ -1289,14 +1290,14 @@ void get_tlm_fox() { current[map[PLUS_Z]] = 0.0; printf("I2C Bus 3 Simulated Failure!\n"); } - if (failureMode == FAIL_CAMERA) { - camera = OFF; - printf("Camera Simulated Failure!\n"); - } if (failureMode == FAIL_PAYLOAD) { payload = OFF; printf("Payload Simulated Failure!\n"); } + if (failureMode == FAIL_CAMERA) { + cam = OFF; + printf("Camera Simulated Failure!\n"); + } if (mode == FSK) id = 7; @@ -1649,7 +1650,7 @@ void get_tlm_fox() { // int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + // (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + - (i2c_bus0 == OFF) * 16 + (i2c_1 == OFF) * 32 + (i2c_3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; + (i2c_bus0 == OFF) * 16 + (i2c_1 == OFF) * 32 + (i2c_3 == OFF) * 64 + (cam == OFF) * 128 + groundCommandCount * 256; encodeA(b, 51 + head_offset, status); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); From 0278d717202aa03866cb43950084b6000a258ed2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:43:04 -0400 Subject: [PATCH 101/295] Update config typo --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 2d44b72e..b42eeec5 100755 --- a/config +++ b/config @@ -1487,7 +1487,7 @@ elif [ "$1" = "-M" ]; then echo "Currently, no simulated failure" else fail=$(<$FILE) - echo -n "Currenly, simulated " + echo -n "Currently, simulated " case $fail in 1) From acd8bc60d6fc49dedfa12a47a94e88a7ef5395f6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:48:33 -0400 Subject: [PATCH 102/295] Update config add fail mode 10 --- config | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config b/config index b42eeec5..c8ee75d2 100755 --- a/config +++ b/config @@ -314,6 +314,9 @@ if [ "$1" = "" ]; then 9) echo "Failed MPU Sensor" ;; + 10) + echo "Failed FM Audio" + ;; *) echo "Unknown Failure" ;; @@ -1517,7 +1520,10 @@ elif [ "$1" = "-M" ]; then 9) echo "Failed MPU Sensor" ;; - *) + 10) + echo "Failed FM Audio" + ;; + *) echo "Unknown Failure" ;; esac @@ -1578,6 +1584,9 @@ elif [ "$1" = "-M" ]; then 9) echo "Setting Simulated Failed MPU Sensor" ;; + 10) + echo "Setting Failed FM Audio" + ;; *) echo "Setting No Simulated Failure" MODE=0 From 2594e5856a28f876c50fa6e3a6c9265598cc2fd8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:53:18 -0400 Subject: [PATCH 103/295] Update config fix 10 --- config | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/config b/config index c8ee75d2..99549453 100755 --- a/config +++ b/config @@ -1520,7 +1520,7 @@ elif [ "$1" = "-M" ]; then 9) echo "Failed MPU Sensor" ;; - 10) + "10") echo "Failed FM Audio" ;; *) @@ -1536,19 +1536,20 @@ elif [ "$1" = "-M" ]; then echo "Set simulated failure mode" echo - echo "0 No Failure (turn OFF)" - echo "1 +X Solar Panel Failure" - echo "2 -X Solar Panel Degredation" - echo "3 -Y Solar Panel Short Circuit" - echo "4 Failed I2C Bus 1" - echo "5 Failed I2C Bus 3" - echo "6 Failed Camera" - echo "7 Failed Payload" - echo "8 Failed BME Sensor" - echo "9 Failed MPU Sensor" + echo " 0 No Failure (turn OFF)" + echo " 1 +X Solar Panel Failure" + echo " 2 -X Solar Panel Degredation" + echo " 3 -Y Solar Panel Short Circuit" + echo " 4 Failed I2C Bus 1" + echo " 5 Failed I2C Bus 3" + echo " 6 Failed Camera" + echo " 7 Failed Payload" + echo " 8 Failed BME Sensor" + echo " 9 Failed MPU Sensor" + echo "10 Failed FM Audio" echo - echo "Enter the failure number to set: 0 - 9" + echo "Enter the failure number to set: 0 - 10" read MODE echo @@ -1584,7 +1585,7 @@ elif [ "$1" = "-M" ]; then 9) echo "Setting Simulated Failed MPU Sensor" ;; - 10) + "10") echo "Setting Failed FM Audio" ;; *) From a287b033ea6929bca31a143b46f7db10345f51d0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:54:20 -0400 Subject: [PATCH 104/295] Update config fix display 10 --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 99549453..9b695b2a 100755 --- a/config +++ b/config @@ -314,7 +314,7 @@ if [ "$1" = "" ]; then 9) echo "Failed MPU Sensor" ;; - 10) + "10") echo "Failed FM Audio" ;; *) From 1edc141f7ca82a26c8c850152afeb604623a2a09 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 15:58:41 -0400 Subject: [PATCH 105/295] Update main.h changed FAIL_NONE to -1 --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index b0f9ca91..6ce6b86a 100644 --- a/main.h +++ b/main.h @@ -122,7 +122,7 @@ FILE *image_file; #define TXCOMMAND 12 #define FAIL_COUNT 10 -#define FAIL_NONE 0 +#define FAIL_NONE -1 #define FAIL_SOLAR 1 #define FAIL_DEGRADE 2 #define FAIL_SHORT 3 From bfa666b1e18f30f0fbebb3d48e243e0dde423eaa Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:01:13 -0400 Subject: [PATCH 106/295] Update config changed fail sim off to -1 --- config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config b/config index 9b695b2a..0d1e1bdc 100755 --- a/config +++ b/config @@ -278,7 +278,7 @@ if [ "$1" = "" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then - if [[ $(grep '0' $FILE) ]]; then + if [[ $(grep '-1' $FILE) ]]; then echo "No simulated failure" else fail=$(<$FILE) @@ -1486,7 +1486,7 @@ elif [ "$1" = "-M" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then - if [[ $(grep '0' $FILE) ]]; then + if [[ $(grep '-1' $FILE) ]]; then echo "Currently, no simulated failure" else fail=$(<$FILE) @@ -1533,7 +1533,7 @@ elif [ "$1" = "-M" ]; then fi echo - echo "Set simulated failure mode" + echo "Set simulated failure mode (or Return to turn OFF)" echo echo " 0 No Failure (turn OFF)" @@ -1555,6 +1555,7 @@ elif [ "$1" = "-M" ]; then echo if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" + MODE="-1" else case $MODE in From 7b6a63f6719f3c3f5fbfb4bedb1793e6642af146 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:04:27 -0400 Subject: [PATCH 107/295] Update config change quotes --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 0d1e1bdc..c04165c4 100755 --- a/config +++ b/config @@ -278,7 +278,7 @@ if [ "$1" = "" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then - if [[ $(grep '-1' $FILE) ]]; then + if [[ $(grep "-1" $FILE) ]]; then echo "No simulated failure" else fail=$(<$FILE) From 76481ec17b3a67a01b98a4438a003295e3fb647e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:07:38 -0400 Subject: [PATCH 108/295] Update config fix -1 --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index c04165c4..a14293fb 100755 --- a/config +++ b/config @@ -278,7 +278,7 @@ if [ "$1" = "" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then - if [[ $(grep "-1" $FILE) ]]; then + if [[ $(grep "\-1" $FILE) ]]; then echo "No simulated failure" else fail=$(<$FILE) @@ -1486,7 +1486,7 @@ elif [ "$1" = "-M" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then - if [[ $(grep '-1' $FILE) ]]; then + if [[ $(grep "\-1" $FILE) ]]; then echo "Currently, no simulated failure" else fail=$(<$FILE) From fbb27f5df185300b8281159e01a8c89f09fd4ea5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:11:37 -0400 Subject: [PATCH 109/295] Update config fix -1 --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index a14293fb..ab3c27f7 100755 --- a/config +++ b/config @@ -1555,7 +1555,7 @@ elif [ "$1" = "-M" ]; then echo if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" - MODE="-1" + MODE=-1 else case $MODE in From bcd74c0e293d78246991403d962bd8d7e1d29db1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:13:24 -0400 Subject: [PATCH 110/295] Update config adding -1 --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index ab3c27f7..49aa572d 100755 --- a/config +++ b/config @@ -1591,7 +1591,7 @@ elif [ "$1" = "-M" ]; then ;; *) echo "Setting No Simulated Failure" - MODE=0 + MODE=-1 ;; esac fi From 3d5e8166aebcf1958e0de6103d1501e71ef44c67 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:23:22 -0400 Subject: [PATCH 111/295] Update transmit.py fix turn fail off --- transmit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/transmit.py b/transmit.py index 7fc649f9..fe91c69e 100644 --- a/transmit.py +++ b/transmit.py @@ -480,8 +480,10 @@ if __name__ == "__main__": print("Failure mode no FM audio") else: print("Other failure mode") + card = "Headphones" except: print("No failure mode") + card = "Headphones" except: # command_control_check() sleep(1) From 90e6793212192b520eeef3bd0780c71293513a73 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:37:16 -0400 Subject: [PATCH 112/295] Update transmit.py add sim_failure_check() --- transmit.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/transmit.py b/transmit.py index fe91c69e..51accf3a 100644 --- a/transmit.py +++ b/transmit.py @@ -12,6 +12,20 @@ from PIL import Image, ImageDraw, ImageFont, ImageColor import serial import random +def sim_failure_check(): + try: + file = open("/home/pi/CubeSatSim/failure_mode.txt") + fail_mode = file.read(2) + if (fail_mode == "10"): + card = "Device" # Change audio so no FM audio plays + print("Failure mode no FM audio") + else: + print("Other failure mode") + card = "Headphones" + except: + print("No failure mode") + card = "Headphones" + def battery_saver_check(): try: global txc @@ -446,6 +460,7 @@ if __name__ == "__main__": # # battery_saver_check() if (txc): + sim_failure_check() # output(pd, 1) sleep(0.1) # add delay before transmit output (ptt, 0) @@ -472,18 +487,7 @@ if __name__ == "__main__": print("Ready for next packet!") sleep(0.5) - try: - file = open("/home/pi/CubeSatSim/failure_mode.txt") - fail_mode = file.read(2) - if (fail_mode == "10"): - card = "Device" # Change audio so no FM audio plays - print("Failure mode no FM audio") - else: - print("Other failure mode") - card = "Headphones" - except: - print("No failure mode") - card = "Headphones" + except: # command_control_check() sleep(1) @@ -510,6 +514,7 @@ if __name__ == "__main__": output(txLed, txLedOn) if (txc): + sim_failure_check() # output (pd, 1) sleep(0.3) output (ptt, 0) @@ -571,6 +576,7 @@ if __name__ == "__main__": # battery_saver_check() if (txc): + sim_failure_check() # output(pd, 1) output (ptt, 0) system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav") @@ -631,6 +637,7 @@ if __name__ == "__main__": # battery_saver_check() if (txc): + sim_failure_check() # output(pd, 1) output (ptt, 0) system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav") @@ -668,6 +675,7 @@ if __name__ == "__main__": # battery_saver_check() if (txc): + sim_failure_check() # output(pd, 1) output (ptt, 0) system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") @@ -704,6 +712,7 @@ if __name__ == "__main__": # battery_saver_check() if (txc): + sim_failure_check() # output(pd, 1) output (ptt, 0) system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") @@ -735,6 +744,7 @@ if __name__ == "__main__": # battery_saver_check() if (txc): + sim_failure_check() # output(pd, 1) output (ptt, 0) system("aplay -D plughw:CARD=" + card + ",DEV=0 /home/pi/CubeSatSim/sstv.wav") From a471b113e866b85aa87aaa6de2638dc095d271e4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:38:37 -0400 Subject: [PATCH 113/295] Update transmit.py fix indent --- transmit.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/transmit.py b/transmit.py index 51accf3a..ad6a58b2 100644 --- a/transmit.py +++ b/transmit.py @@ -14,17 +14,17 @@ import random def sim_failure_check(): try: - file = open("/home/pi/CubeSatSim/failure_mode.txt") - fail_mode = file.read(2) - if (fail_mode == "10"): - card = "Device" # Change audio so no FM audio plays - print("Failure mode no FM audio") - else: - print("Other failure mode") - card = "Headphones" - except: - print("No failure mode") + file = open("/home/pi/CubeSatSim/failure_mode.txt") + fail_mode = file.read(2) + if (fail_mode == "10"): + card = "Device" # Change audio so no FM audio plays + print("Failure mode no FM audio") + else: + print("Other failure mode") card = "Headphones" + except: + print("No failure mode") + card = "Headphones" def battery_saver_check(): try: From a49d46c045acb290c2cd7b356094928b38b20f91 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:41:04 -0400 Subject: [PATCH 114/295] Update transmit.py fix global --- transmit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/transmit.py b/transmit.py index ad6a58b2..3862feb2 100644 --- a/transmit.py +++ b/transmit.py @@ -14,6 +14,7 @@ import random def sim_failure_check(): try: + global card file = open("/home/pi/CubeSatSim/failure_mode.txt") fail_mode = file.read(2) if (fail_mode == "10"): From e99f6b5e5f0f86d4b8e64daeb8ccb75cb720a9b3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:45:58 -0400 Subject: [PATCH 115/295] Update config remove 10 --- config | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/config b/config index 49aa572d..736dad41 100755 --- a/config +++ b/config @@ -314,9 +314,9 @@ if [ "$1" = "" ]; then 9) echo "Failed MPU Sensor" ;; - "10") - echo "Failed FM Audio" - ;; +# "10") +# echo "Failed FM Audio" +# ;; *) echo "Unknown Failure" ;; @@ -1520,9 +1520,9 @@ elif [ "$1" = "-M" ]; then 9) echo "Failed MPU Sensor" ;; - "10") - echo "Failed FM Audio" - ;; +# "10") +# echo "Failed FM Audio" +# ;; *) echo "Unknown Failure" ;; @@ -1546,10 +1546,11 @@ elif [ "$1" = "-M" ]; then echo " 7 Failed Payload" echo " 8 Failed BME Sensor" echo " 9 Failed MPU Sensor" - echo "10 Failed FM Audio" +# echo "10 Failed FM Audio" echo - echo "Enter the failure number to set: 0 - 10" +# echo "Enter the failure number to set: 0 - 10" # 10 sometimes gets stuck on carrier + echo "Enter the failure number to set: 0 - 9" read MODE echo @@ -1586,9 +1587,9 @@ elif [ "$1" = "-M" ]; then 9) echo "Setting Simulated Failed MPU Sensor" ;; - "10") - echo "Setting Failed FM Audio" - ;; +# "10") +# echo "Setting Failed FM Audio" +# ;; *) echo "Setting No Simulated Failure" MODE=-1 From f953ddd41341add39d91d01fe04fdcef04044278 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 16:49:26 -0400 Subject: [PATCH 116/295] Update main.c sim mode random only 1-9 --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index f8dfc146..9a18fa70 100644 --- a/main.c +++ b/main.c @@ -555,7 +555,8 @@ int main(int argc, char * argv[]) { if (sim_mode) { if (loop % 10 == 0) { - failureMode = (int) rnd_float(1, FAIL_COUNT); +// failureMode = (int) rnd_float(1, FAIL_COUNT); + failureMode = (int) rnd_float(1, 9); printf("Sim Mode Random Failure Change\n"); FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w"); fprintf(failure_mode_file, "%d", failureMode); From 7ee647cd57de56d7eede124101f1c0326579b7cd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 17:01:53 -0400 Subject: [PATCH 117/295] Update main.c --- main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 9a18fa70..fffaae77 100644 --- a/main.c +++ b/main.c @@ -78,7 +78,7 @@ int main(int argc, char * argv[]) { } if (strcmp(sim_yes, "yes") == 0) { - sim_mode = TRUE; + = TRUE; fprintf(stderr, "Sim mode is turned ON by configuration\n"); sim_config = TRUE; } @@ -336,9 +336,9 @@ 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)); } - if ((i2c_bus3 == OFF) || (sim_mode == TRUE)) { + if ((i2c_bus3 == OFF) || ( == TRUE)) { - sim_mode = TRUE; + = TRUE; fprintf(stderr, "Simulated telemetry mode!\n"); @@ -492,14 +492,14 @@ int main(int argc, char * argv[]) { memset(sensor, 0, sizeof(sensor)); memset(other, 0, sizeof(other)); - if (((mode == FSK) || (mode == BPSK))) // && !sim_mode) + if (((mode == FSK) || (mode == BPSK))) // && !) get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored - else if (((mode == FC))) // && !sim_mode) + else if (((mode == FC))) // && !) get_tlm_fc(); // fill transmit buffer with reset count 0 packets that will be ignored firstTime = 1; -// if (!sim_mode) // always read sensors, even in sim mode +// if (!) // always read sensors, even in sim mode { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); @@ -830,8 +830,7 @@ int main(int argc, char * argv[]) { // end of simulated telemetry } - else { - } + FILE * cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); if (cpuTempSensor) { // double cpuTemp; From 03f0b02fde90638e3f17e7e6f281aee41b41e6a3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 17:03:37 -0400 Subject: [PATCH 118/295] Update main.c revert --- main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index fffaae77..9a18fa70 100644 --- a/main.c +++ b/main.c @@ -78,7 +78,7 @@ int main(int argc, char * argv[]) { } if (strcmp(sim_yes, "yes") == 0) { - = TRUE; + sim_mode = TRUE; fprintf(stderr, "Sim mode is turned ON by configuration\n"); sim_config = TRUE; } @@ -336,9 +336,9 @@ 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)); } - if ((i2c_bus3 == OFF) || ( == TRUE)) { + if ((i2c_bus3 == OFF) || (sim_mode == TRUE)) { - = TRUE; + sim_mode = TRUE; fprintf(stderr, "Simulated telemetry mode!\n"); @@ -492,14 +492,14 @@ int main(int argc, char * argv[]) { memset(sensor, 0, sizeof(sensor)); memset(other, 0, sizeof(other)); - if (((mode == FSK) || (mode == BPSK))) // && !) + if (((mode == FSK) || (mode == BPSK))) // && !sim_mode) get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored - else if (((mode == FC))) // && !) + else if (((mode == FC))) // && !sim_mode) get_tlm_fc(); // fill transmit buffer with reset count 0 packets that will be ignored firstTime = 1; -// if (!) // always read sensors, even in sim mode +// if (!sim_mode) // always read sensors, even in sim mode { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); @@ -830,7 +830,8 @@ int main(int argc, char * argv[]) { // end of simulated telemetry } - + else { + } FILE * cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); if (cpuTempSensor) { // double cpuTemp; From e39437bd55ac215138b3bbc4e3b971292e097e31 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 17:04:35 -0400 Subject: [PATCH 119/295] Update main.c remove extra else --- main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.c b/main.c index 9a18fa70..5de8cf08 100644 --- a/main.c +++ b/main.c @@ -830,8 +830,7 @@ int main(int argc, char * argv[]) { // end of simulated telemetry } - else { - } + FILE * cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); if (cpuTempSensor) { // double cpuTemp; From 2b1ac62e901eb85fca9328238a729abad80d5aa2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:22:15 -0400 Subject: [PATCH 120/295] Update main.c read failure in sim_mode --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 5de8cf08..1ac35b14 100644 --- a/main.c +++ b/main.c @@ -563,8 +563,8 @@ int main(int argc, char * argv[]) { fclose(failure_mode_file); } } - else - { +// else +// { // failureMode = OFF; FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "r"); if (failure_mode_file != NULL) { @@ -578,7 +578,7 @@ int main(int argc, char * argv[]) { failureMode = FAIL_NONE; printf("No simulated failure.\n"); } - } +// } { int count1; From 757dd34699d52f2f0d9bd265f3776769be5c0aed Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:43:33 -0400 Subject: [PATCH 121/295] Update config print fail --- config | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config b/config index 736dad41..b4aa3ee3 100755 --- a/config +++ b/config @@ -220,7 +220,11 @@ sudo modprobe snd-aloop # if [ "$2" = "n" ] ; then if [ -z "$2" ] ; then - noreboot=0 + if [ "$2" = "n" ] ; then + noreboot=0 + else + fail=$2 + fi else noreboot=1 echo "Reboot disabled" @@ -1484,6 +1488,11 @@ elif [ "$1" = "-j" ]; then elif [ "$1" = "-M" ]; then + if [ -z $fail ] then + echo "$fail has a value!" + echo $fail + fi + FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then if [[ $(grep "\-1" $FILE) ]]; then From c7f42b34961f9f08f19c69c9fa6f8da200ca314c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:44:48 -0400 Subject: [PATCH 122/295] Update config missing ; --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index b4aa3ee3..f6e3e99e 100755 --- a/config +++ b/config @@ -1488,7 +1488,7 @@ elif [ "$1" = "-j" ]; then elif [ "$1" = "-M" ]; then - if [ -z $fail ] then + if [ -z $fail ]; then echo "$fail has a value!" echo $fail fi From 708f9359d0c034ab8e705ed70530770dfc447280 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:48:21 -0400 Subject: [PATCH 123/295] Update config more fail --- config | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/config b/config index f6e3e99e..4f2f51e5 100755 --- a/config +++ b/config @@ -220,14 +220,15 @@ sudo modprobe snd-aloop # if [ "$2" = "n" ] ; then if [ -z "$2" ] ; then + noreboot=0 +else if [ "$2" = "n" ] ; then - noreboot=0 + echo "Reboot disabled" + noreboot=1 else fail=$2 fi -else - noreboot=1 - echo "Reboot disabled" + fi # echo "No reboot" @@ -1488,8 +1489,8 @@ elif [ "$1" = "-j" ]; then elif [ "$1" = "-M" ]; then - if [ -z $fail ]; then - echo "$fail has a value!" + if [ $fail ]; then + echo "fail has a value!" echo $fail fi From 9c9eb24b8e884ad64eb136f5d9d8b10696ed5425 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:50:49 -0400 Subject: [PATCH 124/295] Update config set $2 to mode --- config | 136 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/config b/config index 4f2f51e5..fc042a8d 100755 --- a/config +++ b/config @@ -1490,79 +1490,79 @@ elif [ "$1" = "-j" ]; then elif [ "$1" = "-M" ]; then if [ $fail ]; then - echo "fail has a value!" - echo $fail - fi + MODE=$fail + else - FILE=/home/pi/CubeSatSim/failure_mode.txt - if [ -f "$FILE" ]; then - if [[ $(grep "\-1" $FILE) ]]; then - echo "Currently, no simulated failure" + FILE=/home/pi/CubeSatSim/failure_mode.txt + if [ -f "$FILE" ]; then + if [[ $(grep "\-1" $FILE) ]]; then + echo "Currently, no simulated failure" + else + fail=$(<$FILE) + echo -n "Currently, simulated " + case $fail in + + 1) + echo "+X Solar Panel Failure" + ;; + 2) + echo "-X Solar Panel Degredation" + ;; + 3) + echo "-Y Solar Panel Short Circuit" + ;; + 4) + echo "Failed I2C Bus 1" + ;; + 5) + echo "Failed I2C Bus 3" + ;; + 6) + echo "Failed Camera" + ;; + 7) + echo "Failed Payload" + ;; + 8) + echo "Failed BME Sensor" + ;; + 9) + echo "Failed MPU Sensor" + ;; + # "10") + # echo "Failed FM Audio" + # ;; + *) + echo "Unknown Failure" + ;; + esac + fi else - fail=$(<$FILE) - echo -n "Currently, simulated " - case $fail in - - 1) - echo "+X Solar Panel Failure" - ;; - 2) - echo "-X Solar Panel Degredation" - ;; - 3) - echo "-Y Solar Panel Short Circuit" - ;; - 4) - echo "Failed I2C Bus 1" - ;; - 5) - echo "Failed I2C Bus 3" - ;; - 6) - echo "Failed Camera" - ;; - 7) - echo "Failed Payload" - ;; - 8) - echo "Failed BME Sensor" - ;; - 9) - echo "Failed MPU Sensor" - ;; -# "10") -# echo "Failed FM Audio" -# ;; - *) - echo "Unknown Failure" - ;; - esac + echo "Currently, no simulated failure" fi - else - echo "Currently, no simulated failure" + + echo + echo "Set simulated failure mode (or Return to turn OFF)" + echo + + echo " 0 No Failure (turn OFF)" + echo " 1 +X Solar Panel Failure" + echo " 2 -X Solar Panel Degredation" + echo " 3 -Y Solar Panel Short Circuit" + echo " 4 Failed I2C Bus 1" + echo " 5 Failed I2C Bus 3" + echo " 6 Failed Camera" + echo " 7 Failed Payload" + echo " 8 Failed BME Sensor" + echo " 9 Failed MPU Sensor" + # echo "10 Failed FM Audio" + echo + + # echo "Enter the failure number to set: 0 - 10" # 10 sometimes gets stuck on carrier + echo "Enter the failure number to set: 0 - 9" + read MODE fi - echo - echo "Set simulated failure mode (or Return to turn OFF)" - echo - - echo " 0 No Failure (turn OFF)" - echo " 1 +X Solar Panel Failure" - echo " 2 -X Solar Panel Degredation" - echo " 3 -Y Solar Panel Short Circuit" - echo " 4 Failed I2C Bus 1" - echo " 5 Failed I2C Bus 3" - echo " 6 Failed Camera" - echo " 7 Failed Payload" - echo " 8 Failed BME Sensor" - echo " 9 Failed MPU Sensor" -# echo "10 Failed FM Audio" - echo - -# echo "Enter the failure number to set: 0 - 10" # 10 sometimes gets stuck on carrier - echo "Enter the failure number to set: 0 - 9" - read MODE - echo if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" From f06a4f5e7d13a855bde722f5b67f5d1ce17d3f36 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:51:55 -0400 Subject: [PATCH 125/295] Update config move echo --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index fc042a8d..014b06e2 100755 --- a/config +++ b/config @@ -1561,9 +1561,9 @@ elif [ "$1" = "-M" ]; then # echo "Enter the failure number to set: 0 - 10" # 10 sometimes gets stuck on carrier echo "Enter the failure number to set: 0 - 9" read MODE + echo fi - echo if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" MODE=-1 From 5f34c587ca26bd35bee0eab8ba5b12a1bd99b428 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:53:06 -0400 Subject: [PATCH 126/295] Update config extra blank line --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 014b06e2..72211f88 100755 --- a/config +++ b/config @@ -210,6 +210,7 @@ function transmit_command_beacon { exit } +echo echo "CubeSatSim v2.1 configuration tool" echo # echo $1 From ce268e99e59d3aed3f9d46a33e4bd5f4be3f5759 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:54:23 -0400 Subject: [PATCH 127/295] Update config v2.2 --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 72211f88..014ae111 100755 --- a/config +++ b/config @@ -211,7 +211,7 @@ function transmit_command_beacon { } echo -echo "CubeSatSim v2.1 configuration tool" +echo "CubeSatSim v2.2 configuration tool" echo # echo $1 # echo $2 From c08b57bfc18ba498b005065580869ea2de8672f7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:54:43 -0400 Subject: [PATCH 128/295] Update main.c v2.2 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 1ac35b14..cbb42105 100644 --- a/main.c +++ b/main.c @@ -25,7 +25,7 @@ int main(int argc, char * argv[]) { - printf("\n\nCubeSatSim v2.1 starting...\n\n"); + printf("\n\nCubeSatSim v2.2 starting...\n\n"); wiringPiSetup(); From e8686cc1e0042fc6631170b2c656a19708dab2a2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:55:11 -0400 Subject: [PATCH 129/295] Update install v2.2 --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index fc333a64..3de142d4 100755 --- a/install +++ b/install @@ -1,6 +1,6 @@ #!/bin/bash -echo -e "\ninstallation script for CubeSatSim v2.1\n" +echo -e "\ninstallation script for CubeSatSim v2.2\n" FILE=/home/pi/CubeSatSim/sim.cfg if [ -f "$FILE" ]; then From 5f3d2354792cd21a00758d4dd7cc851c37152486 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:55:46 -0400 Subject: [PATCH 130/295] Update transmit.py v2.2 --- transmit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index 3862feb2..a1da818f 100644 --- a/transmit.py +++ b/transmit.py @@ -145,7 +145,7 @@ def camera_photo(): draw.text((120, 10), telem_string, font=font2, fill='white') img.save(file) -print("CubeSatSim v2.1 transmit.py starting...") +print("CubeSatSim v2.2 transmit.py starting...") pd = 21 ptt = 20 From 3f2b3ad7b7d673e07622704c79be6fd33f5783a9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Aug 2025 23:56:27 -0400 Subject: [PATCH 131/295] Update telem.c v2.2 --- telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telem.c b/telem.c index 1fc534a5..ce4f14c3 100644 --- a/telem.c +++ b/telem.c @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) { } } - printf("CubeSatSim v2.1 INA219 Voltage and Current Telemetry\n"); + printf("CubeSatSim v2.2 INA219 Voltage and Current Telemetry\n"); map[MINUS_X] = MINUS_Y; map[PLUS_Z] = MINUS_X; map[MINUS_Y] = PLUS_Z; From 899a2927c603a4c082b4573f0c67712f5e727b27 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Aug 2025 15:35:29 -0400 Subject: [PATCH 132/295] Update transmit.py add fail camera mode check --- transmit.py | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/transmit.py b/transmit.py index a1da818f..063811d5 100644 --- a/transmit.py +++ b/transmit.py @@ -15,11 +15,16 @@ import random def sim_failure_check(): try: global card + global cam_fail + cam_fail = False file = open("/home/pi/CubeSatSim/failure_mode.txt") fail_mode = file.read(2) if (fail_mode == "10"): card = "Device" # Change audio so no FM audio plays print("Failure mode no FM audio") + else if (fail_mode == "6"): + cam_fail = True + print("Failure mode camera fail") else: print("Other failure mode") card = "Headphones" @@ -110,6 +115,7 @@ def increment_mode(): print("can't write to .mode file") def camera_photo(): + sim_failure_check() system("sudo rm /home/pi/CubeSatSim/camera_out.jpg") stored_image = False try: @@ -117,6 +123,10 @@ def camera_photo(): f = open("/home/pi/CubeSatSim/camera_out.jpg") f.close() print("Photo taken") + if (cam_fail == True): + system("cp /home/pi/CubeSatSim/sstv//sstv_image_2_320_x_256.jpeg /home/pi/CubeSatSim/camera_out.jpg") + print("Using stored image") + stored_image = True except: system("cp /home/pi/CubeSatSim/sstv//sstv_image_2_320_x_256.jpeg /home/pi/CubeSatSim/camera_out.jpg") print("Using stored image") @@ -596,35 +606,7 @@ if __name__ == "__main__": print("image 2 did not load - copy from CubeSatSim/sstv directory") while 1: # command_control_check() - camera_photo() -## system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") -## print("Photo taken") -## -## file='/home/pi/CubeSatSim/camera_out.jpg' -## font1 = ImageFont.truetype('DejaVuSerif.ttf', 20) -## font2 = ImageFont.truetype('DejaVuSerif-Bold.ttf', 16) -## -## try: -## filep = open("/home/pi/CubeSatSim/telem_string.txt") -## telem_string = filep.readline() -## except: -## telem_string = "" -## if (debug_mode == 1): -## print("Can't read telem_string.txt") -## print(telem_string) -## -## img = Image.open(file) -## draw = ImageDraw.Draw(img) -# draw.text((10, 10), callsign, font=font2, fill='white') -# draw.text((120, 10), telem_string, font=font2, fill='white') -## draw.text((12, 12), callsign, font=font1, fill='black') -## draw.text((10, 10), callsign, font=font1, fill='white') -## draw.text((122, 12), telem_string, font=font2, fill='black') -## draw.text((120, 10), telem_string, font=font2, fill='white') -## img.save(file) - -# command_control_check() - + camera_photo() system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg") system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") From 297c951506e45a9fe38245ee6196eed38bc50b01 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Aug 2025 15:40:07 -0400 Subject: [PATCH 133/295] Update transmit.py global cam_fail --- transmit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/transmit.py b/transmit.py index 063811d5..9d949580 100644 --- a/transmit.py +++ b/transmit.py @@ -115,6 +115,7 @@ def increment_mode(): print("can't write to .mode file") def camera_photo(): + global cam_fail sim_failure_check() system("sudo rm /home/pi/CubeSatSim/camera_out.jpg") stored_image = False From 1e33a5303515edd44027922e749c1059abebc17d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Aug 2025 15:41:10 -0400 Subject: [PATCH 134/295] Update transmit.py elif --- transmit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index 9d949580..3d54fbec 100644 --- a/transmit.py +++ b/transmit.py @@ -22,7 +22,7 @@ def sim_failure_check(): if (fail_mode == "10"): card = "Device" # Change audio so no FM audio plays print("Failure mode no FM audio") - else if (fail_mode == "6"): + elif (fail_mode == "6"): cam_fail = True print("Failure mode camera fail") else: From 9522edd7b12cd89d1b17ace8b56535fe9b59acdd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Aug 2025 15:45:18 -0400 Subject: [PATCH 135/295] Update transmit.py print fail mode --- transmit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/transmit.py b/transmit.py index 3d54fbec..5eecd919 100644 --- a/transmit.py +++ b/transmit.py @@ -19,6 +19,8 @@ def sim_failure_check(): cam_fail = False file = open("/home/pi/CubeSatSim/failure_mode.txt") fail_mode = file.read(2) + print("Fail_mode: ") + print(fail_mode) if (fail_mode == "10"): card = "Device" # Change audio so no FM audio plays print("Failure mode no FM audio") From 073da3962e6f9e360630f8bcd03d9a4f52154b98 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Aug 2025 15:47:37 -0400 Subject: [PATCH 136/295] Update transmit.py change fail_mode to int --- transmit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transmit.py b/transmit.py index 5eecd919..bd0fd8ce 100644 --- a/transmit.py +++ b/transmit.py @@ -18,13 +18,13 @@ def sim_failure_check(): global cam_fail cam_fail = False file = open("/home/pi/CubeSatSim/failure_mode.txt") - fail_mode = file.read(2) + fail_mode = int(file.read(2)) print("Fail_mode: ") print(fail_mode) - if (fail_mode == "10"): + if (fail_mode == 10): card = "Device" # Change audio so no FM audio plays print("Failure mode no FM audio") - elif (fail_mode == "6"): + elif (fail_mode == 6): cam_fail = True print("Failure mode camera fail") else: From 535ca7c6a0b4682d125e6db7f6a192608cfe5b94 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Aug 2025 15:57:10 -0400 Subject: [PATCH 137/295] Update transmit.py fix no failure mode --- transmit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index bd0fd8ce..fc745f45 100644 --- a/transmit.py +++ b/transmit.py @@ -19,14 +19,16 @@ def sim_failure_check(): cam_fail = False file = open("/home/pi/CubeSatSim/failure_mode.txt") fail_mode = int(file.read(2)) - print("Fail_mode: ") - print(fail_mode) +# print("Fail_mode: ") +# print(fail_mode) if (fail_mode == 10): card = "Device" # Change audio so no FM audio plays print("Failure mode no FM audio") elif (fail_mode == 6): cam_fail = True print("Failure mode camera fail") + elif (fail_mode == 0): + print("No failure mode") else: print("Other failure mode") card = "Headphones" From adce015667032eb25ac54a01fce0e3d07ced4e65 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 13 Aug 2025 16:15:41 -0400 Subject: [PATCH 138/295] Update main.c remove extra random --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index cbb42105..2c705223 100644 --- a/main.c +++ b/main.c @@ -1250,10 +1250,10 @@ void get_tlm_fox() { if (failureMode == FAIL_NONE) printf("No Simulated Failure\n"); - if (failureMode == -1) { - failureMode = (int) rnd_float(1, FAIL_COUNT); - printf("Random Failure\n"); - } +// if (failureMode == -1) { +// failureMode = (int) rnd_float(1, FAIL_COUNT); +// printf("Random Failure\n"); +// } if (failureMode == FAIL_SOLAR) { voltage[map[PLUS_X]] = 0.0; current[map[PLUS_X]] = 0.0; From d58f85163dbb7758cf644231dc1bd4a27f47ca83 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 14 Aug 2025 14:19:51 -0400 Subject: [PATCH 139/295] Update config turn of sim failure when turning off sim mode --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 014ae111..60e1a555 100755 --- a/config +++ b/config @@ -556,6 +556,7 @@ elif [ "$1" = "-t" ]; then else sim="no" echo "Simulated Telemetry is OFF" + echo "-1" > /home/pi/CubeSatSim/failure_mode.txt # make sure to turn off any simulated failures fi # echo From eff778ed11e754f52bfe5f56017f5252e20dea6b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 15 Aug 2025 10:48:59 -0400 Subject: [PATCH 140/295] Update config fix missing echo --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 60e1a555..ab01910e 100755 --- a/config +++ b/config @@ -343,7 +343,7 @@ if [ "$1" = "" ]; then # echo echo -n "Current command count is: " cat /home/pi/CubeSatSim/command_count.txt -# echo + echo # echo # echo "Current beacon transmit mode is:" # cat /home/pi/CubeSatSim/command_tx From 56918cbc152304239b25158cd07c674ddf2b51e7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 09:38:08 -0400 Subject: [PATCH 141/295] Update main.h added FAIL_UNPLUG --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index 6ce6b86a..4c83b32a 100644 --- a/main.h +++ b/main.h @@ -123,6 +123,7 @@ FILE *image_file; #define FAIL_COUNT 10 #define FAIL_NONE -1 +#define FAIL_UNPLUG 0 #define FAIL_SOLAR 1 #define FAIL_DEGRADE 2 #define FAIL_SHORT 3 From 8d1c26dbd7879096fb430104ad0a13c9d81789c3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 09:40:16 -0400 Subject: [PATCH 142/295] Update main.c adde FAIL_UNPLUG --- main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.c b/main.c index 2c705223..85849e2b 100644 --- a/main.c +++ b/main.c @@ -1254,6 +1254,11 @@ void get_tlm_fox() { // failureMode = (int) rnd_float(1, FAIL_COUNT); // printf("Random Failure\n"); // } + if (failureMode == FAIL_UNPLUG) { + voltage[map[PLUS_X]] = rnd_float(0.8, 0.95); + current[map[PLUS_X]] = 0.0; + printf("+X Solar Unplugged Failure\n"); + } if (failureMode == FAIL_SOLAR) { voltage[map[PLUS_X]] = 0.0; current[map[PLUS_X]] = 0.0; From bd3196ff96ee3c40ac12bd1a8e8af40dde312cb4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 09:46:01 -0400 Subject: [PATCH 143/295] Update config added FAIL_UNPLUG --- config | 79 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/config b/config index ab01910e..e2b5da93 100755 --- a/config +++ b/config @@ -292,37 +292,40 @@ if [ "$1" = "" ]; then # cat $FILE case $fail in - + 1) + echo "+X Solar Panel Unplugged" + ;; + 2) echo "+X Solar Panel Failure" ;; - 2) + 3) echo "-X Solar Panel Degredation" ;; - 3) + 4) echo "-Y Solar Panel Short Circuit" ;; - 4) + 5) echo "Failed I2C Bus 1" ;; - 5) + 6) echo "Failed I2C Bus 3" ;; - 6) + 7) echo "Failed Camera" ;; - 7) + 8) echo "Failed Payload" ;; - 8) + 9) echo "Failed BME Sensor" ;; - 9) + 10) echo "Failed MPU Sensor" ;; -# "10") -# echo "Failed FM Audio" -# ;; + "11") + echo "Failed FM Audio" + ;; *) echo "Unknown Failure" ;; @@ -1503,37 +1506,40 @@ elif [ "$1" = "-M" ]; then fail=$(<$FILE) echo -n "Currently, simulated " case $fail in - + 1) + echo "+X Solar Panel Unplugged" + ;; + 2) echo "+X Solar Panel Failure" ;; - 2) + 3) echo "-X Solar Panel Degredation" ;; - 3) + 4) echo "-Y Solar Panel Short Circuit" ;; - 4) + 5) echo "Failed I2C Bus 1" ;; - 5) + 6) echo "Failed I2C Bus 3" ;; - 6) + 7) echo "Failed Camera" ;; - 7) + 8) echo "Failed Payload" ;; - 8) + 9) echo "Failed BME Sensor" ;; - 9) + "10") echo "Failed MPU Sensor" ;; - # "10") - # echo "Failed FM Audio" - # ;; + "11") + echo "Failed FM Audio" + ;; *) echo "Unknown Failure" ;; @@ -1548,20 +1554,21 @@ elif [ "$1" = "-M" ]; then echo echo " 0 No Failure (turn OFF)" - echo " 1 +X Solar Panel Failure" - echo " 2 -X Solar Panel Degredation" - echo " 3 -Y Solar Panel Short Circuit" - echo " 4 Failed I2C Bus 1" - echo " 5 Failed I2C Bus 3" - echo " 6 Failed Camera" - echo " 7 Failed Payload" - echo " 8 Failed BME Sensor" - echo " 9 Failed MPU Sensor" - # echo "10 Failed FM Audio" + echo " 1 +Z Solar Panel Unplugged" + echo " 2 +X Solar Panel Failure" + echo " 3 -X Solar Panel Degredation" + echo " 4 -Y Solar Panel Short Circuit" + echo " 5 Failed I2C Bus 1" + echo " 6 Failed I2C Bus 3" + echo " 7 Failed Camera" + echo " 8 Failed Payload" + echo " 9 Failed BME Sensor" + echo "10 Failed MPU Sensor" + echo "11 Failed FM Audio" echo - # echo "Enter the failure number to set: 0 - 10" # 10 sometimes gets stuck on carrier - echo "Enter the failure number to set: 0 - 9" + echo "Enter the failure number to set: 0 - 11" + # echo "Enter the failure number to set: 0 - 9" read MODE echo fi From 0d2ed9ed7e670101f13de7166ff6135c7d92cc76 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 09:47:02 -0400 Subject: [PATCH 144/295] Update main.h update fail numbers --- main.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main.h b/main.h index 4c83b32a..bb7f25aa 100644 --- a/main.h +++ b/main.h @@ -121,19 +121,19 @@ FILE *image_file; #define REPEATER 7 #define TXCOMMAND 12 -#define FAIL_COUNT 10 +#define FAIL_COUNT 11 #define FAIL_NONE -1 -#define FAIL_UNPLUG 0 -#define FAIL_SOLAR 1 -#define FAIL_DEGRADE 2 -#define FAIL_SHORT 3 -#define FAIL_I2C1 4 -#define FAIL_I2C3 5 -#define FAIL_CAMERA 6 -#define FAIL_PAYLOAD 7 +#define FAIL_UNPLUG 1 +#define FAIL_SOLAR 2 +#define FAIL_DEGRADE 3 +#define FAIL_SHORT 4 +#define FAIL_I2C1 5 +#define FAIL_I2C3 6 +#define FAIL_CAMERA 7 +#define FAIL_PAYLOAD 8 #define FAIL_BME 8 -#define FAIL_MPU 9 -#define FAIL_AUDIO 10 +#define FAIL_MPU 10 +#define FAIL_AUDIO 11 int failureMode = FAIL_NONE; int transmitStatus = -1; From 5d276d5a22394d41cc513e2d9e6622fe977ab4b9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 09:58:53 -0400 Subject: [PATCH 145/295] Update main.c change unplugged to +Y --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 85849e2b..75198f0b 100644 --- a/main.c +++ b/main.c @@ -1255,9 +1255,9 @@ void get_tlm_fox() { // printf("Random Failure\n"); // } if (failureMode == FAIL_UNPLUG) { - voltage[map[PLUS_X]] = rnd_float(0.8, 0.95); - current[map[PLUS_X]] = 0.0; - printf("+X Solar Unplugged Failure\n"); + voltage[map[PLUS_Y]] = rnd_float(0.8, 0.95); + current[map[PLUS_Y]] = 0.0; + printf("+Y Solar Unplugged Failure\n"); } if (failureMode == FAIL_SOLAR) { voltage[map[PLUS_X]] = 0.0; From 370b5c717767b4444f91c2367f2688125d51456d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 10:00:55 -0400 Subject: [PATCH 146/295] Update config with +Y unplugged --- config | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/config b/config index e2b5da93..c62f4be8 100755 --- a/config +++ b/config @@ -294,7 +294,7 @@ if [ "$1" = "" ]; then case $fail in 1) - echo "+X Solar Panel Unplugged" + echo "+Y Solar Panel Unplugged" ;; 2) echo "+X Solar Panel Failure" @@ -1508,7 +1508,7 @@ elif [ "$1" = "-M" ]; then case $fail in 1) - echo "+X Solar Panel Unplugged" + echo "+Y Solar Panel Unplugged" ;; 2) echo "+X Solar Panel Failure" @@ -1554,7 +1554,7 @@ elif [ "$1" = "-M" ]; then echo echo " 0 No Failure (turn OFF)" - echo " 1 +Z Solar Panel Unplugged" + echo " 1 +Y Solar Panel Unplugged" echo " 2 +X Solar Panel Failure" echo " 3 -X Solar Panel Degredation" echo " 4 -Y Solar Panel Short Circuit" @@ -1578,37 +1578,39 @@ elif [ "$1" = "-M" ]; then MODE=-1 else case $MODE in - 1) + echo "+Y Solar Panel Unplugged" + ;; + 2) echo "Setting Simulated +X Solar Panel Failure" ;; - 2) + 3) echo "Setting Simulated -X Solar Panel Degredation" ;; - 3) + 4) echo "Setting Simulated -Y Solar Panel Short Circuit" ;; - 4) + 5) echo "Setting Simulated Failed I2C Bus 1" ;; - 5) + 6) echo "Setting Simulated Failed I2C Bus 3" ;; - 6) + 7) echo "Setting Simulated Failed Camera" ;; - 7) + 8) echo "Setting Simulated Failed Payload" ;; - 8) + 9) echo "Setting Simulated Failed BME Sensor" ;; - 9) + "10") echo "Setting Simulated Failed MPU Sensor" ;; -# "10") -# echo "Setting Failed FM Audio" -# ;; + "11") + echo "Setting Failed FM Audio" + ;; *) echo "Setting No Simulated Failure" MODE=-1 From 95040ec2beb34695e0175f15c3b4d15290288c2f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 10:01:35 -0400 Subject: [PATCH 147/295] Update update changed to v2.2 --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index 7c38b361..f5477ccd 100755 --- a/update +++ b/update @@ -1,6 +1,6 @@ #!/bin/bash -echo -e "\nupdate script for CubeSatSim v2.1\n" +echo -e "\nupdate script for CubeSatSim v2.2\n" FLAG=0 checkout=0 From 97165bbbea757cabf9803afeb74c235704871f9b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 10:13:06 -0400 Subject: [PATCH 148/295] Update main.c add secondTime --- main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 75198f0b..80fae692 100644 --- a/main.c +++ b/main.c @@ -496,8 +496,11 @@ int main(int argc, char * argv[]) { get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored else if (((mode == FC))) // && !sim_mode) get_tlm_fc(); // fill transmit buffer with reset count 0 packets that will be ignored - - firstTime = 1; + + if (firstTime == 0) + firstTime = 1; + if (firsTime == 1) && (secondTime == 0) + secondTime = 1; // if (!sim_mode) // always read sensors, even in sim mode { @@ -1312,7 +1315,7 @@ void get_tlm_fox() { // for (int frames = 0; frames < FRAME_CNT; frames++) for (int frames = 0; frames < frameCnt; frames++) { - if (firstTime != ON) { + if ((firstTime != ON) && (second_time != ON)) { // delay for sample period /**/ @@ -1330,7 +1333,7 @@ void get_tlm_fox() { sampleTime = (unsigned int) millis(); } else - printf("first time - no sleep\n"); + printf("first or second time - no sleep\n"); printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime)/1000.0); fflush(stdout); @@ -2781,4 +2784,5 @@ void socket_send(int length) { if (socket_open == 1) firstTime = 0; + secondTime = 0; } From f718a98d9234b1da3353e70b300aa34cbb23844b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 10:13:40 -0400 Subject: [PATCH 149/295] Update main.h add secondTime --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index bb7f25aa..8bece91e 100644 --- a/main.h +++ b/main.h @@ -98,6 +98,7 @@ int socket_open = 0; int sock = 0; int loop = -1, loop_count = 0; int firstTime = ON; // 0; +int secondTime = ON; long start; int testCount = 0; long time_start; From 3942d0e181af619bf2bdc8489c7f07a28a411748 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 10:17:04 -0400 Subject: [PATCH 150/295] Update main.c typos --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 80fae692..9d9ebd50 100644 --- a/main.c +++ b/main.c @@ -499,7 +499,7 @@ int main(int argc, char * argv[]) { if (firstTime == 0) firstTime = 1; - if (firsTime == 1) && (secondTime == 0) + if ((firstTime == 1) && (secondTime == 0)) secondTime = 1; // if (!sim_mode) // always read sensors, even in sim mode From 4def42b1b44cc19c663d6209b421877eb1ee7302 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 10:19:19 -0400 Subject: [PATCH 151/295] Update main.c another typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 9d9ebd50..eb96f13b 100644 --- a/main.c +++ b/main.c @@ -1315,7 +1315,7 @@ void get_tlm_fox() { // for (int frames = 0; frames < FRAME_CNT; frames++) for (int frames = 0; frames < frameCnt; frames++) { - if ((firstTime != ON) && (second_time != ON)) { + if ((firstTime != ON) && (secondTime != ON)) { // delay for sample period /**/ From b56684f3d60f058f2df4f9f473d2d1e1add50fcd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 14:52:04 -0400 Subject: [PATCH 152/295] Update main.c remove secondTime and short sleep on first time --- main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index eb96f13b..a6941782 100644 --- a/main.c +++ b/main.c @@ -499,8 +499,6 @@ int main(int argc, char * argv[]) { if (firstTime == 0) firstTime = 1; - if ((firstTime == 1) && (secondTime == 0)) - secondTime = 1; // if (!sim_mode) // always read sensors, even in sim mode { @@ -1315,7 +1313,8 @@ void get_tlm_fox() { // for (int frames = 0; frames < FRAME_CNT; frames++) for (int frames = 0; frames < frameCnt; frames++) { - if ((firstTime != ON) && (secondTime != ON)) { +// if (firstTime != ON) { + if (true) { // delay for sample period /**/ @@ -2784,5 +2783,4 @@ void socket_send(int length) { if (socket_open == 1) firstTime = 0; - secondTime = 0; } From c3a25e579e22fa042e52f9197009e52203aedb5a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 14:53:40 -0400 Subject: [PATCH 153/295] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index a6941782..3d03d5dc 100644 --- a/main.c +++ b/main.c @@ -1314,7 +1314,7 @@ void get_tlm_fox() { for (int frames = 0; frames < frameCnt; frames++) { // if (firstTime != ON) { - if (true) { + if (TRUE) { // delay for sample period /**/ From 6ff74af6d47e116f90c4298f309f38bc787edae2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:16:44 -0400 Subject: [PATCH 154/295] Update config with -N next mode --- config | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/config b/config index c62f4be8..5a328b00 100755 --- a/config +++ b/config @@ -1622,6 +1622,46 @@ elif [ "$1" = "-M" ]; then echo echo $MODE > /home/pi/CubeSatSim/failure_mode.txt +elif [ "$1" = "-N" ]; then + + echo "Next mode" + + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" = "a" ]; then + echo "Current mode is APRS" + echo "Next mode is FSK" + /home/pi/CubeSatSim/config -f + elif [ "$1" = "m" ]; then + echo "Current mode is CW" + echo "Next mode is FunCube" + /home/pi/CubeSatSim/config -j + elif [ "$1" = "f" ]; then + echo "Current mode is FSK" + echo "Next mode is BPSK" + /home/pi/CubeSatSim/config -b + elif [ "$1" = "b" ]; then + echo "Current mode is BPSK" + echo "Next mode is SSTV" + /home/pi/CubeSatSim/config -s + elif [ "$1" = "s" ]; then + echo "Current mode is SSTV" + echo "Next mode is CW" + /home/pi/CubeSatSim/config -m + elif [ "$1" = "e" ]; then + echo "Current mode is Repeater" + echo "Next mode is APRS" + /home/pi/CubeSatSim/config -a + elif [ "$1" = "j" ]; then + echo "Current mode is FUNcube" + echo "Next mode is Repeater" + /home/pi/CubeSatSim/config -e + else + echo "Unknown mode" + fi + elif [ "$1" = "-h" ]; then echo "config OPTION" @@ -1660,7 +1700,7 @@ elif [ "$1" = "-h" ]; then echo " -L Change microphone level for command and control" echo " -g Reset configuration back to default settings" echo " -M Set simulated failure mode" - + echo " -N Set next mode" echo exit From 282589ddaf154fe58c47652266f4c2803fd8d853 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:39:19 -0400 Subject: [PATCH 155/295] Update config -N check for fail mode --- config | 88 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/config b/config index 5a328b00..14205483 100755 --- a/config +++ b/config @@ -1624,42 +1624,60 @@ elif [ "$1" = "-M" ]; then elif [ "$1" = "-N" ]; then - echo "Next mode" - - value=`cat /home/pi/CubeSatSim/.mode` - echo "$value" > /dev/null - set -- $value + FILE=/home/pi/CubeSatSim/failure_mode.txt + if [ -f "$FILE" ]; then + if [[ $(grep "\-1" $FILE) ]]; then + echo "No simulated failure" + fail=0 + else + echo "Simulated failure mode" + fail=$(<$FILE) + echo $fail + else + echo "No simulated failure" + fail=0 + fi - if [ "$1" = "a" ]; then - echo "Current mode is APRS" - echo "Next mode is FSK" - /home/pi/CubeSatSim/config -f - elif [ "$1" = "m" ]; then - echo "Current mode is CW" - echo "Next mode is FunCube" - /home/pi/CubeSatSim/config -j - elif [ "$1" = "f" ]; then - echo "Current mode is FSK" - echo "Next mode is BPSK" - /home/pi/CubeSatSim/config -b - elif [ "$1" = "b" ]; then - echo "Current mode is BPSK" - echo "Next mode is SSTV" - /home/pi/CubeSatSim/config -s - elif [ "$1" = "s" ]; then - echo "Current mode is SSTV" - echo "Next mode is CW" - /home/pi/CubeSatSim/config -m - elif [ "$1" = "e" ]; then - echo "Current mode is Repeater" - echo "Next mode is APRS" - /home/pi/CubeSatSim/config -a - elif [ "$1" = "j" ]; then - echo "Current mode is FUNcube" - echo "Next mode is Repeater" - /home/pi/CubeSatSim/config -e - else - echo "Unknown mode" + if [ $fail == 0 ] then + echo "Changing to next mode" + + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" = "a" ]; then + echo "Current mode is APRS" + echo "Next mode is FSK" + /home/pi/CubeSatSim/config -f + elif [ "$1" = "m" ]; then + echo "Current mode is CW" + echo "Next mode is FunCube" + /home/pi/CubeSatSim/config -j + elif [ "$1" = "f" ]; then + echo "Current mode is FSK" + echo "Next mode is BPSK" + /home/pi/CubeSatSim/config -b + elif [ "$1" = "b" ]; then + echo "Current mode is BPSK" + echo "Next mode is SSTV" + /home/pi/CubeSatSim/config -s + elif [ "$1" = "s" ]; then + echo "Current mode is SSTV" + echo "Next mode is CW" + /home/pi/CubeSatSim/config -m + elif [ "$1" = "e" ]; then + echo "Current mode is Repeater" + echo "Next mode is APRS" + /home/pi/CubeSatSim/config -a + elif [ "$1" = "j" ]; then + echo "Current mode is FUNcube" + echo "Next mode is Repeater" + /home/pi/CubeSatSim/config -e + else + echo "Unknown mode" + fi + else + echo "Changing to next simulated failure mode" fi elif [ "$1" = "-h" ]; then From fae529b59ad407bdae25314a671135c2cdf93952 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:41:14 -0400 Subject: [PATCH 156/295] Update config missing fi --- config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config b/config index 14205483..47a6b3e8 100755 --- a/config +++ b/config @@ -54,7 +54,7 @@ function transmit_command_fsk { echo "Resuming command and control" sudo systemctl start command - else + STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=f" sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 @@ -89,7 +89,7 @@ function transmit_command_bpsk { echo "Resuming command and control" sudo systemctl start command - else + STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=b" sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 @@ -1633,6 +1633,7 @@ elif [ "$1" = "-N" ]; then echo "Simulated failure mode" fail=$(<$FILE) echo $fail + fi else echo "No simulated failure" fail=0 From 1c425461c757615b9535d547bb0740f8d03e54ef Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:42:59 -0400 Subject: [PATCH 157/295] Update config missing ; --- config | 78 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/config b/config index 47a6b3e8..3fa49a09 100755 --- a/config +++ b/config @@ -1639,46 +1639,46 @@ elif [ "$1" = "-N" ]; then fail=0 fi - if [ $fail == 0 ] then - echo "Changing to next mode" - - value=`cat /home/pi/CubeSatSim/.mode` - echo "$value" > /dev/null - set -- $value - - if [ "$1" = "a" ]; then - echo "Current mode is APRS" - echo "Next mode is FSK" - /home/pi/CubeSatSim/config -f - elif [ "$1" = "m" ]; then - echo "Current mode is CW" - echo "Next mode is FunCube" - /home/pi/CubeSatSim/config -j - elif [ "$1" = "f" ]; then - echo "Current mode is FSK" - echo "Next mode is BPSK" - /home/pi/CubeSatSim/config -b - elif [ "$1" = "b" ]; then - echo "Current mode is BPSK" - echo "Next mode is SSTV" - /home/pi/CubeSatSim/config -s - elif [ "$1" = "s" ]; then - echo "Current mode is SSTV" - echo "Next mode is CW" - /home/pi/CubeSatSim/config -m - elif [ "$1" = "e" ]; then - echo "Current mode is Repeater" - echo "Next mode is APRS" - /home/pi/CubeSatSim/config -a - elif [ "$1" = "j" ]; then - echo "Current mode is FUNcube" - echo "Next mode is Repeater" - /home/pi/CubeSatSim/config -e - else - echo "Unknown mode" - fi + if [ $fail == 0 ]; then + echo "Changing to next mode" + + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" = "a" ]; then + echo "Current mode is APRS" + echo "Next mode is FSK" + /home/pi/CubeSatSim/config -f + elif [ "$1" = "m" ]; then + echo "Current mode is CW" + echo "Next mode is FunCube" + /home/pi/CubeSatSim/config -j + elif [ "$1" = "f" ]; then + echo "Current mode is FSK" + echo "Next mode is BPSK" + /home/pi/CubeSatSim/config -b + elif [ "$1" = "b" ]; then + echo "Current mode is BPSK" + echo "Next mode is SSTV" + /home/pi/CubeSatSim/config -s + elif [ "$1" = "s" ]; then + echo "Current mode is SSTV" + echo "Next mode is CW" + /home/pi/CubeSatSim/config -m + elif [ "$1" = "e" ]; then + echo "Current mode is Repeater" + echo "Next mode is APRS" + /home/pi/CubeSatSim/config -a + elif [ "$1" = "j" ]; then + echo "Current mode is FUNcube" + echo "Next mode is Repeater" + /home/pi/CubeSatSim/config -e else - echo "Changing to next simulated failure mode" + echo "Unknown mode" + fi + else + echo "Changing to next simulated failure mode" fi elif [ "$1" = "-h" ]; then From 4304b504cb20675f1aa9caa1116ae5339f87af88 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:48:23 -0400 Subject: [PATCH 158/295] Update config increment fail --- config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config b/config index 3fa49a09..cdb98628 100755 --- a/config +++ b/config @@ -1679,6 +1679,9 @@ elif [ "$1" = "-N" ]; then fi else echo "Changing to next simulated failure mode" + fail=$((fail + 1)) + echo $fail + fi elif [ "$1" = "-h" ]; then From 24d0a943713d0689ff33c7565c8df5f3c0465af4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:51:31 -0400 Subject: [PATCH 159/295] Update config add modulo 11 --- config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config b/config index cdb98628..46deac7f 100755 --- a/config +++ b/config @@ -1680,6 +1680,8 @@ elif [ "$1" = "-N" ]; then else echo "Changing to next simulated failure mode" fail=$((fail + 1)) + if [ $fail == 12 ]; then + fail=1 echo $fail fi From e91b6ebac1d4cd100f333c75934774cc0c3fa116 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:52:21 -0400 Subject: [PATCH 160/295] Update config missing fi --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 46deac7f..731ddb53 100755 --- a/config +++ b/config @@ -1682,6 +1682,7 @@ elif [ "$1" = "-N" ]; then fail=$((fail + 1)) if [ $fail == 12 ]; then fail=1 + fi echo $fail fi From 201c2d9cb3fdcdf823e01b66689dee80ff50c0a9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:53:15 -0400 Subject: [PATCH 161/295] Update config change fail mode on -N --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 731ddb53..3c0edf0a 100755 --- a/config +++ b/config @@ -1684,6 +1684,7 @@ elif [ "$1" = "-N" ]; then fail=1 fi echo $fail + /home/pi/CubeSatSim/config -M $fail fi From cb458aeea0cd351fc26208feb755d86cc0dfc1ca Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 15:58:24 -0400 Subject: [PATCH 162/295] Update update add pi-power-button next branch --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index f5477ccd..e183c797 100755 --- a/update +++ b/update @@ -297,7 +297,7 @@ cd /home/pi/pi-power-button echo "updating pi-power-button." -# git checkout master + git checkout next # new next branch script/install From 178d3c5d3691dc5d301f9315e9deab01fe96cb01 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 16:01:43 -0400 Subject: [PATCH 163/295] Update update force pi-power-button to update --- update | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/update b/update index e183c797..2f72c779 100755 --- a/update +++ b/update @@ -288,24 +288,22 @@ fi cd /home/pi/pi-power-button - git checkout master - git pull --no-rebase > .updated_p - grep 'changed' /home/pi/pi-power-button/.updated_p - if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then + git checkout next + +# grep 'changed' /home/pi/pi-power-button/.updated_p +# if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then echo "updating pi-power-button." - - git checkout next # new next branch script/install FLAG=1 - else - echo "nothing to do for pi-power-button." - fi + # else + # echo "nothing to do for pi-power-button." + # fi cd /home/pi/ssdv From 5191fcd5f3fc7f08c4ad6bb7c4bc922ca684d623 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:34:25 -0400 Subject: [PATCH 164/295] Update main.h added fail_yes and fail_time --- main.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.h b/main.h index 8bece91e..0f0a1f6b 100644 --- a/main.h +++ b/main.h @@ -161,6 +161,8 @@ long int uptime; char call[5]; char sim_yes[10]; char hab_yes[10]; +char fail_yes[10]; +int fail_time = 60; int squelch = 3; // default squelch char rx[12], tx[12]; int tx_pl = 0; From 4a8671f43c0e5daf0cfb1fb4675d748f8fb93cee Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:36:57 -0400 Subject: [PATCH 165/295] Update main.h add fail_rnd_mode --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index 0f0a1f6b..d7adf62e 100644 --- a/main.h +++ b/main.h @@ -227,6 +227,7 @@ int pi_zero_2_offset = 0; int hab_mode = FALSE; +int fail_rnd_mode = FALSE; int battery_saver_mode = FALSE; long int loopTime; From 1f8c04e221e1fc5b1ff794828f3ed3c5db323bc7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:40:44 -0400 Subject: [PATCH 166/295] Update main.h added failTime --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index d7adf62e..0f990ea5 100644 --- a/main.h +++ b/main.h @@ -230,6 +230,7 @@ int hab_mode = FALSE; int fail_rnd_mode = FALSE; int battery_saver_mode = FALSE; long int loopTime; +long int failTime = 0; int error_count = 0; int groundCommandCount = 0; From 81d844266f1c829816a32f3f809083ced337e891 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:41:37 -0400 Subject: [PATCH 167/295] Update main.c added random sim fail to sim.cfg --- main.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 3d03d5dc..49e917b8 100644 --- a/main.c +++ b/main.c @@ -41,11 +41,11 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; - fscanf(config_file, "%s %d %f %f %s %d %s %s %s %d %d", - call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx, hab_yes, & rx_pl, & tx_pl); + fscanf(config_file, "%s %d %f %f %s %d %s %s %s %d %d %s %d", + call, &reset_count, &lat_file, &long_file, sim_yes, &squelch, tx, rx, hab_yes, &rx_pl, &tx_pl, fail_yes, &fail_time); fclose(config_file); - fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d\n", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl); + fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d %s %d\n", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); fprintf(stderr, "Transmit on %s MHz Receive on %s MHz\n", tx, rx); @@ -86,6 +86,10 @@ int main(int argc, char * argv[]) { hab_mode = TRUE; fprintf(stderr, "HAB mode is ON\n"); } + if (strcmp(fail_yes, "yes") == 0) { + fail_rnd_mode = TRUE; + fprintf(stderr, "Random fail mode is ON\n"); + } FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r"); if (command_file == NULL) { @@ -289,7 +293,8 @@ int main(int argc, char * argv[]) { } config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %s %d", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); @@ -554,14 +559,16 @@ int main(int argc, char * argv[]) { // #endif fclose(uptime_file); - if (sim_mode) { - if (loop % 10 == 0) { + if (fail_rnd_mode) { +// if (loop % 10 == 0) { + if ((loopTime - failTime) > fail_time * 1000) { // failureMode = (int) rnd_float(1, FAIL_COUNT); failureMode = (int) rnd_float(1, 9); printf("Sim Mode Random Failure Change\n"); FILE * failure_mode_file = fopen("/home/pi/CubeSatSim/failure_mode.txt", "w"); fprintf(failure_mode_file, "%d", failureMode); - fclose(failure_mode_file); + fclose(failure_mode_file); + failTime = loopTime; } } // else From dc29ecab0cf3474d58b7a06e79c868f4858ccb4b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:49:13 -0400 Subject: [PATCH 168/295] Update config add random fail mode --- config | 57 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/config b/config index 3c0edf0a..605fdedd 100755 --- a/config +++ b/config @@ -335,7 +335,12 @@ if [ "$1" = "" ]; then else echo "No simulated failure" fi -# echo + + if [ "${12}" = "y" ] || [ "${12}" = "yes" ] ; then + echo "Random Failure Mode is ON" + else + echo "Random Failure Mode is OFF" + fi if [ "$9" = "yes" ] || [ "$9" = "y" ]; then echo "Balloon mode is ON" @@ -401,7 +406,7 @@ if [ "$1" = "" ]; then echo -e "Current sim.cfg configuration file:" # echo - echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} echo echo "To change, include an OPTION" @@ -547,7 +552,7 @@ elif [ "$1" = "-t" ]; then echo -# $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} +# $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${12} ${13} echo "Do you want Simulated Telemetry ON (y/n) " read sim @@ -565,8 +570,8 @@ elif [ "$1" = "-t" ]; then # echo echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" # echo - echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} - echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} ${12} ${13} + echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg echo ## echo "Rebooting CubeSatSim with new configuration file" ## echo @@ -593,7 +598,7 @@ elif [ "$1" = "-c" ]; then echo $1 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${12} ${13} echo "Enter callsign in all capitals: " read callsign @@ -607,8 +612,8 @@ elif [ "$1" = "-c" ]; then echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} - echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg + echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} + echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -641,7 +646,7 @@ elif [ "$1" = "-r" ]; then echo $2 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} echo -e "Enter Reset Count (integer): " @@ -661,8 +666,8 @@ elif [ "$1" = "-r" ]; then echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} - echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -696,7 +701,7 @@ elif [ "$1" = "-l" ]; then echo $3 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} echo -e "Enter latitude (decimal degrees, positive is north): " @@ -738,8 +743,8 @@ elif [ "$1" = "-l" ]; then fi echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} - echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} + echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg if [ "$norestart" = "1" ]; then echo @@ -1031,7 +1036,7 @@ elif [ "$1" = "-q" ]; then echo $6 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} echo -e "Enter squelch (integer 1 - 8): " @@ -1053,8 +1058,8 @@ elif [ "$1" = "-q" ]; then # echo echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" # echo - echo $1 $2 $3 $4 $5 $sq $7 $8 $9 ${10} ${11} - echo $1 $2 $3 $4 $4 $sq $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $sq $7 $8 $9 ${10} ${11} ${12} ${13} + echo $1 $2 $3 $4 $4 $sq $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg echo echo "Restarting CubeSatSim with new configuration file" ## echo @@ -1090,7 +1095,7 @@ elif [ "$1" = "-P" ]; then echo ${11} echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} echo -e "Enter RX PL value integer 0: None, 01-38: CTCSS (analog, 39-121:CDCSS (digital)" @@ -1133,8 +1138,8 @@ elif [ "$1" = "-P" ]; then # echo echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" # echo - echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl - echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl ${12} ${13} + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $rxpl $txpl ${12} ${13} > /home/pi/CubeSatSim/sim.cfg echo ## echo "Rebooting CubeSatSim with new configuration file" ## echo @@ -1164,7 +1169,7 @@ elif [ "$1" = "-F" ]; then echo $8 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} echo "Enter tx frequency as 4XX.XXXX: " read tx @@ -1187,8 +1192,8 @@ elif [ "$1" = "-F" ]; then echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} - echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} ${12} ${13} + echo $1 $2 $3 $4 $5 $6 $tx $rx $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg # fi # if [ "$norestart" = "1" ]; then @@ -1270,7 +1275,7 @@ elif [ "$1" = "-H" ]; then echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} echo "Do you want Balloon mode ON (y/n) " read hab @@ -1287,8 +1292,8 @@ elif [ "$1" = "-H" ]; then # echo echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" # echo - echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11} - echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11} > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11} ${12} ${13} + echo $1 $2 $3 $4 $5 $6 $7 $8 $hab ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg echo ## echo "Rebooting CubeSatSim with new configuration file" ## echo From 1e90684751da5e7808839da09b454c3b953f3f4b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:52:35 -0400 Subject: [PATCH 169/295] Update main.c default fail_rnd to no --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 49e917b8..13187c81 100644 --- a/main.c +++ b/main.c @@ -292,6 +292,7 @@ int main(int argc, char * argv[]) { transmit = TRUE; } + strcpy(fail_yes, "no"); config_file = fopen("sim.cfg", "w"); fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %s %d", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); From 370f65ce830249780bffa9ac34c35d8a1e7ef8f2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:57:02 -0400 Subject: [PATCH 170/295] Update main.c swap order --- main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 13187c81..4fe621ad 100644 --- a/main.c +++ b/main.c @@ -42,10 +42,10 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; fscanf(config_file, "%s %d %f %f %s %d %s %s %s %d %d %s %d", - call, &reset_count, &lat_file, &long_file, sim_yes, &squelch, tx, rx, hab_yes, &rx_pl, &tx_pl, fail_yes, &fail_time); + call, &reset_count, &lat_file, &long_file, sim_yes, &squelch, tx, rx, hab_yes, &rx_pl, &tx_pl, &fail_time, fail_yes); fclose(config_file); - fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d %s %d\n", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); + fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d %s %s\n", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_time, fail_yes); fprintf(stderr, "Transmit on %s MHz Receive on %s MHz\n", tx, rx); @@ -294,8 +294,8 @@ int main(int argc, char * argv[]) { strcpy(fail_yes, "no"); config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %s %d", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %d %s", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_time, fail_yes); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); From a48df136345ce1995a6f9123cd6ea5ae6fc55a0c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 17:58:58 -0400 Subject: [PATCH 171/295] Update main.c revert --- main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 4fe621ad..13187c81 100644 --- a/main.c +++ b/main.c @@ -42,10 +42,10 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; fscanf(config_file, "%s %d %f %f %s %d %s %s %s %d %d %s %d", - call, &reset_count, &lat_file, &long_file, sim_yes, &squelch, tx, rx, hab_yes, &rx_pl, &tx_pl, &fail_time, fail_yes); + call, &reset_count, &lat_file, &long_file, sim_yes, &squelch, tx, rx, hab_yes, &rx_pl, &tx_pl, fail_yes, &fail_time); fclose(config_file); - fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d %s %s\n", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_time, fail_yes); + fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s %d %d %s %d\n", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); fprintf(stderr, "Transmit on %s MHz Receive on %s MHz\n", tx, rx); @@ -294,8 +294,8 @@ int main(int argc, char * argv[]) { strcpy(fail_yes, "no"); config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %d %s", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_time, fail_yes); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %s %d", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); From e9d8472804f608c5f5c351575b10ac27f81803ac Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 18:11:34 -0400 Subject: [PATCH 173/295] Update main.c move default no --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 13187c81..be581eda 100644 --- a/main.c +++ b/main.c @@ -28,7 +28,8 @@ int main(int argc, char * argv[]) { printf("\n\nCubeSatSim v2.2 starting...\n\n"); wiringPiSetup(); - + + strcpy(fail_yes, "no"); // Open configuration file with callsign and reset count FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); if (config_file == NULL) { @@ -292,7 +293,6 @@ int main(int argc, char * argv[]) { transmit = TRUE; } - strcpy(fail_yes, "no"); config_file = fopen("sim.cfg", "w"); fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s %d %d %s %d", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes, rx_pl, tx_pl, fail_yes, fail_time); From a00b92cd01933f5cbe43357e580f9548dbe1346d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 18:27:24 -0400 Subject: [PATCH 174/295] Update config set fail rnd time --- config | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/config b/config index 605fdedd..f6dda702 100755 --- a/config +++ b/config @@ -1570,9 +1570,10 @@ elif [ "$1" = "-M" ]; then echo " 9 Failed BME Sensor" echo "10 Failed MPU Sensor" echo "11 Failed FM Audio" + echo "12 Random Failure" echo - echo "Enter the failure number to set: 0 - 11" + echo "Enter the failure number to set: 0 - 12" # echo "Enter the failure number to set: 0 - 9" read MODE echo @@ -1581,6 +1582,57 @@ elif [ "$1" = "-M" ]; then if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" MODE=-1 + elseif [ "$MODE" = "12" ]; then + echo "Setting Random Simulated Failure" + + echo + echo "with a new random failure selected in seconds" + echo + echo "Return keeps current value." + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo + echo -n "Current value in seconds is" + echo ${13} + echo + + # echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} + + echo -e "Enter time in seconds (integer): " + + read time + + if [ -z $time ] ; then + time="${13}" + echo "Keeping value of" $time + fi + + if ! [[ $time =~ ^[0-9]+$ ]] ; then + echo "Error: not an integer!" + time="${13}" + echo "Keeping value of" $time + norestart=1 + else + + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" + + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg + fi + + if [ "$norestart" = "1" ]; then + echo + else + reboot=1 + fi + + + + + else case $MODE in 1) From 0d7e41b8f19ab0a5bbfac4f74148266d28b7bdbe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 18:28:21 -0400 Subject: [PATCH 175/295] Update config fix elif --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index f6dda702..1f75bffa 100755 --- a/config +++ b/config @@ -1582,7 +1582,7 @@ elif [ "$1" = "-M" ]; then if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" MODE=-1 - elseif [ "$MODE" = "12" ]; then + elif [ "$MODE" = "12" ]; then echo "Setting Random Simulated Failure" echo From d4b29ca3aeae584ab71b1aea2cc94c6211530882 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 18:29:39 -0400 Subject: [PATCH 176/295] Update config save time --- config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config b/config index 1f75bffa..9749b28d 100755 --- a/config +++ b/config @@ -1595,7 +1595,7 @@ elif [ "$1" = "-M" ]; then set -- $value echo - echo -n "Current value in seconds is" + echo -n "Current value in seconds is " echo ${13} echo @@ -1619,8 +1619,8 @@ elif [ "$1" = "-M" ]; then echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} - echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} > /home/pi/CubeSatSim/sim.cfg + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} $time + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} $time > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then From ac71bf2f914c2f892dba7d46e96a69ce85a448b3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 18:40:13 -0400 Subject: [PATCH 177/295] Update install added check for Bullseye --- install | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/install b/install index 3de142d4..b026c78e 100755 --- a/install +++ b/install @@ -2,6 +2,17 @@ echo -e "\ninstallation script for CubeSatSim v2.2\n" +cat | grep "11." + + if [[ $(grep '11.' /etc/debian_version) ]]; then + echo "Installing on Debian 11 (Bullseye)" + else + echo "This is not Debian 11 (Bullseye)!" + echo "Installation is not likely to work." + echo "Recommend you start with a Bullseye." + sleep 10 + fi + FILE=/home/pi/CubeSatSim/sim.cfg if [ -f "$FILE" ]; then echo "$FILE exists." From 14e6c3e0411206a6c7bf269c4037960b9978d359 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Aug 2025 18:41:44 -0400 Subject: [PATCH 178/295] Update install OS version check --- install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install b/install index b026c78e..2e590c3c 100755 --- a/install +++ b/install @@ -2,14 +2,13 @@ echo -e "\ninstallation script for CubeSatSim v2.2\n" -cat | grep "11." - if [[ $(grep '11.' /etc/debian_version) ]]; then echo "Installing on Debian 11 (Bullseye)" else echo "This is not Debian 11 (Bullseye)!" echo "Installation is not likely to work." echo "Recommend you start with a Bullseye." + echo sleep 10 fi From 6bebfdf42cf5f6cc60528c2456cbbdedb7577739 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 09:01:33 -0400 Subject: [PATCH 179/295] Update transmit.py fix no fail mode --- transmit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index fc745f45..44c8a107 100644 --- a/transmit.py +++ b/transmit.py @@ -27,7 +27,7 @@ def sim_failure_check(): elif (fail_mode == 6): cam_fail = True print("Failure mode camera fail") - elif (fail_mode == 0): + elif (fail_mode == -1): print("No failure mode") else: print("Other failure mode") From e7e965d7a1a817fbcd85442748088578756adcef Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 09:04:41 -0400 Subject: [PATCH 180/295] Update config add wall --- config | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/config b/config index 9749b28d..10d6989c 100755 --- a/config +++ b/config @@ -1629,10 +1629,6 @@ elif [ "$1" = "-M" ]; then reboot=1 fi - - - - else case $MODE in 1) @@ -1679,6 +1675,9 @@ elif [ "$1" = "-M" ]; then echo echo $MODE > /home/pi/CubeSatSim/failure_mode.txt + echo 'Changing simulated failure mode to $MODE' | wall + + elif [ "$1" = "-N" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt From e28708ab7dbdab6f071aaa9af1142b0fa6920e14 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 09:07:05 -0400 Subject: [PATCH 181/295] Update config wall mode --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 10d6989c..750d83fd 100755 --- a/config +++ b/config @@ -1675,7 +1675,7 @@ elif [ "$1" = "-M" ]; then echo echo $MODE > /home/pi/CubeSatSim/failure_mode.txt - echo 'Changing simulated failure mode to $MODE' | wall + echo 'Changing simulated failure mode to " $MODE | wall elif [ "$1" = "-N" ]; then From 465e3cd3f880bb39c24cf05dfbead1f977b035db Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 09:08:36 -0400 Subject: [PATCH 182/295] Update config fix wall --- config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config b/config index 750d83fd..f488be66 100755 --- a/config +++ b/config @@ -1675,7 +1675,8 @@ elif [ "$1" = "-M" ]; then echo echo $MODE > /home/pi/CubeSatSim/failure_mode.txt - echo 'Changing simulated failure mode to " $MODE | wall + echo -n "Changing simulated failure mode to " | wall + echo $MODE | wall elif [ "$1" = "-N" ]; then From 01770f5fd4cc4ec3b1d6f2d9bcc0d2221e6e1616 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 09:10:12 -0400 Subject: [PATCH 183/295] Update config include mode in wall msg --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index f488be66..8e2cb934 100755 --- a/config +++ b/config @@ -1675,8 +1675,8 @@ elif [ "$1" = "-M" ]; then echo echo $MODE > /home/pi/CubeSatSim/failure_mode.txt - echo -n "Changing simulated failure mode to " | wall - echo $MODE | wall + echo "Changing simulated failure mode to $MODE" | wall + elif [ "$1" = "-N" ]; then From a08222f7ea61cf4de483f577069ac80e58face40 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 09:24:00 -0400 Subject: [PATCH 184/295] Update config add -U to change random sim failure on off --- config | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/config b/config index 8e2cb934..15e9ea4d 100755 --- a/config +++ b/config @@ -1745,6 +1745,55 @@ elif [ "$1" = "-N" ]; then fi +elif [ "$1" = "-U" ]; then + + echo + echo "Changing the Random Simulated Failure setting in" + echo "the configuration file for CubeSatSim" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + if [ "${12}" = "yes" ] || [ "${12}" = "y" ]; then + echo "Random Simulated Failure is ON" + else + echo "Random Simulated Failure is OFF" + fi + + echo + +# $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${12} ${13} + + echo "Do you want Random Simulated Failure ON (y/n) " + read sim + echo + + if [ "$sim" = "y" ] || [ "$sim" = "yes" ] ; then + sim="yes" + echo "Random Simulated Failure is ON" + else + sim="no" + echo "Random Simulated Failure is OFF" +# echo "-1" > /home/pi/CubeSatSim/failure_mode.txt # make sure to turn off any simulated failures + fi + +# echo + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" +# echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim ${13} + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim ${13} > /home/pi/CubeSatSim/sim.cfg + echo +## echo "Rebooting CubeSatSim with new configuration file" +## echo + + reboot=1 +## sudo reboot now +# sudo restart cubesatsim + + + elif [ "$1" = "-h" ]; then echo "config OPTION" @@ -1783,7 +1832,8 @@ elif [ "$1" = "-h" ]; then echo " -L Change microphone level for command and control" echo " -g Reset configuration back to default settings" echo " -M Set simulated failure mode" - echo " -N Set next mode" + echo " -U Change the random failure mode setting" + echo " -N Set next mode or failure" echo exit From 93234b58438f83a44a5baec8f48aff65b2f0b62b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 09:56:41 -0400 Subject: [PATCH 185/295] Update config move random time to -U --- config | 75 ++++++++++++++++++++++------------------------------------ 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/config b/config index 15e9ea4d..f2600b5b 100755 --- a/config +++ b/config @@ -1582,52 +1582,13 @@ elif [ "$1" = "-M" ]; then if [ "$MODE" = "0" ]; then echo "Setting No Simulated Failure" MODE=-1 - elif [ "$MODE" = "12" ]; then - echo "Setting Random Simulated Failure" - - echo - echo "with a new random failure selected in seconds" - echo - echo "Return keeps current value." - - value=`cat /home/pi/CubeSatSim/sim.cfg` - echo "$value" > /dev/null - set -- $value - - echo - echo -n "Current value in seconds is " - echo ${13} - echo - - # echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} - - echo -e "Enter time in seconds (integer): " - - read time - - if [ -z $time ] ; then - time="${13}" - echo "Keeping value of" $time - fi - - if ! [[ $time =~ ^[0-9]+$ ]] ; then - echo "Error: not an integer!" - time="${13}" - echo "Keeping value of" $time - norestart=1 - else - - echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - - echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} $time - echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} $time > /home/pi/CubeSatSim/sim.cfg - fi +# elif [ "$MODE" = "12" ]; then - if [ "$norestart" = "1" ]; then - echo - else - reboot=1 - fi +# if [ "$norestart" = "1" ]; then +# echo +# else +# reboot=1 +# fi else case $MODE in @@ -1773,6 +1734,26 @@ elif [ "$1" = "-U" ]; then if [ "$sim" = "y" ] || [ "$sim" = "yes" ] ; then sim="yes" echo "Random Simulated Failure is ON" + echo + echo "A new random failure is selected every" + echo ${13} " seconds." + echo + echo "Enter a new value or Return keeps current value." + + echo "Enter time in seconds (integer): " + + read time + + if [ -z $time ] ; then + time="${13}" + echo "Keeping value of " $time " seconds" + fi + + if ! [[ $time =~ ^[0-9]+$ ]] ; then + echo "Error: not an integer!" + time="${13}" + echo "Keeping value of" $time +# norestart=1 else sim="no" echo "Random Simulated Failure is OFF" @@ -1782,8 +1763,8 @@ elif [ "$1" = "-U" ]; then # echo echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" # echo - echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim ${13} - echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim ${13} > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim $time + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim $time > /home/pi/CubeSatSim/sim.cfg echo ## echo "Rebooting CubeSatSim with new configuration file" ## echo From 31eaf7d360d30a72dbbe7fbb30c53398183a88d5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:02:17 -0400 Subject: [PATCH 186/295] Update config change to .gt --- config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config b/config index f2600b5b..c957f88a 100755 --- a/config +++ b/config @@ -1570,10 +1570,10 @@ elif [ "$1" = "-M" ]; then echo " 9 Failed BME Sensor" echo "10 Failed MPU Sensor" echo "11 Failed FM Audio" - echo "12 Random Failure" +# echo "12 Random Failure" echo - echo "Enter the failure number to set: 0 - 12" + echo "Enter the failure number to set: 0 - 11" # echo "Enter the failure number to set: 0 - 9" read MODE echo @@ -1698,7 +1698,8 @@ elif [ "$1" = "-N" ]; then else echo "Changing to next simulated failure mode" fail=$((fail + 1)) - if [ $fail == 12 ]; then +# if [ $fail == 12 ]; then + if [ "$fail" -ge "11" ]; then fail=1 fi echo $fail From f3dee164e98dfc426b731e719d1ee3e5ea949811 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:04:00 -0400 Subject: [PATCH 187/295] Update config missing fi --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index c957f88a..157cfda5 100755 --- a/config +++ b/config @@ -1755,6 +1755,8 @@ elif [ "$1" = "-U" ]; then time="${13}" echo "Keeping value of" $time # norestart=1 + fi + else sim="no" echo "Random Simulated Failure is OFF" @@ -1774,8 +1776,6 @@ elif [ "$1" = "-U" ]; then ## sudo reboot now # sudo restart cubesatsim - - elif [ "$1" = "-h" ]; then echo "config OPTION" From b3c1ebee9ece58c2f8a486d0bb5ef7295b30f830 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:09:42 -0400 Subject: [PATCH 188/295] Update config -U only reboot if changed --- config | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config b/config index 157cfda5..1eac704d 100755 --- a/config +++ b/config @@ -1769,12 +1769,10 @@ elif [ "$1" = "-U" ]; then echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim $time echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim $time > /home/pi/CubeSatSim/sim.cfg echo -## echo "Rebooting CubeSatSim with new configuration file" -## echo - reboot=1 -## sudo reboot now -# sudo restart cubesatsim + if [ "${12}" != "$sim" ]; then + reboot=1 + fi elif [ "$1" = "-h" ]; then From 2c7c3315908095566a240ed40f56e5ebd2b08c0b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:13:42 -0400 Subject: [PATCH 189/295] Update config reboot if fail seconds changed --- config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config b/config index 1eac704d..9cca4e40 100755 --- a/config +++ b/config @@ -1754,7 +1754,6 @@ elif [ "$1" = "-U" ]; then echo "Error: not an integer!" time="${13}" echo "Keeping value of" $time -# norestart=1 fi else @@ -1770,7 +1769,7 @@ elif [ "$1" = "-U" ]; then echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} $sim $time > /home/pi/CubeSatSim/sim.cfg echo - if [ "${12}" != "$sim" ]; then + if [ "${12}" != "$sim" ] || [ "${13}" != "$time" ] ; then reboot=1 fi From 883c5a891ab43e243460b02e951847a9c3d1daed Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:33:09 -0400 Subject: [PATCH 190/295] Update config keep time if random off --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 9cca4e40..739f28ae 100755 --- a/config +++ b/config @@ -1759,6 +1759,7 @@ elif [ "$1" = "-U" ]; then else sim="no" echo "Random Simulated Failure is OFF" + time="${13}" # echo "-1" > /home/pi/CubeSatSim/failure_mode.txt # make sure to turn off any simulated failures fi From 274586971a5ec565ea485f23014b92a857e865ba Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:47:28 -0400 Subject: [PATCH 191/295] Update config change to gt --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 739f28ae..b73a91db 100755 --- a/config +++ b/config @@ -1699,7 +1699,7 @@ elif [ "$1" = "-N" ]; then echo "Changing to next simulated failure mode" fail=$((fail + 1)) # if [ $fail == 12 ]; then - if [ "$fail" -ge "11" ]; then + if [ "$fail" -gt "11" ]; then fail=1 fi echo $fail From 39055026964de47f36271caa22ebc086dd1fae3d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:55:46 -0400 Subject: [PATCH 192/295] Update config add failure mode number --- config | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/config b/config index b73a91db..115bbc8f 100755 --- a/config +++ b/config @@ -1506,44 +1506,44 @@ elif [ "$1" = "-M" ]; then FILE=/home/pi/CubeSatSim/failure_mode.txt if [ -f "$FILE" ]; then if [[ $(grep "\-1" $FILE) ]]; then - echo "Currently, no simulated failure" + echo "Currently, no simulated failure (0)" else fail=$(<$FILE) echo -n "Currently, simulated " case $fail in 1) - echo "+Y Solar Panel Unplugged" + echo "+Y Solar Panel Unplugged (1)" ;; 2) - echo "+X Solar Panel Failure" + echo "+X Solar Panel Failure (2)" ;; 3) - echo "-X Solar Panel Degredation" + echo "-X Solar Panel Degredation (3)" ;; 4) - echo "-Y Solar Panel Short Circuit" + echo "-Y Solar Panel Short Circuit (4)" ;; 5) - echo "Failed I2C Bus 1" + echo "Failed I2C Bus 1 (5)" ;; 6) - echo "Failed I2C Bus 3" + echo "Failed I2C Bus 3 (6)" ;; 7) - echo "Failed Camera" + echo "Failed Camera (7)" ;; 8) - echo "Failed Payload" + echo "Failed Payload (8)" ;; 9) - echo "Failed BME Sensor" + echo "Failed BME Sensor (9)" ;; "10") - echo "Failed MPU Sensor" + echo "Failed MPU Sensor (10)" ;; "11") - echo "Failed FM Audio" + echo "Failed FM Audio (11)" ;; *) echo "Unknown Failure" @@ -1570,11 +1570,9 @@ elif [ "$1" = "-M" ]; then echo " 9 Failed BME Sensor" echo "10 Failed MPU Sensor" echo "11 Failed FM Audio" -# echo "12 Random Failure" echo echo "Enter the failure number to set: 0 - 11" - # echo "Enter the failure number to set: 0 - 9" read MODE echo fi From 2a7a7a6016e5e88b4c3bbbbf19159305d9c04b42 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 10:58:50 -0400 Subject: [PATCH 193/295] Update config show failure number and random time period --- config | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config b/config index 115bbc8f..91f33955 100755 --- a/config +++ b/config @@ -294,37 +294,37 @@ if [ "$1" = "" ]; then case $fail in 1) - echo "+Y Solar Panel Unplugged" + echo "+Y Solar Panel Unplugged (1)" ;; 2) - echo "+X Solar Panel Failure" + echo "+X Solar Panel Failure (2)" ;; 3) - echo "-X Solar Panel Degredation" + echo "-X Solar Panel Degredation (3)" ;; 4) - echo "-Y Solar Panel Short Circuit" + echo "-Y Solar Panel Short Circuit (4)" ;; 5) - echo "Failed I2C Bus 1" + echo "Failed I2C Bus 1 (5)" ;; 6) - echo "Failed I2C Bus 3" + echo "Failed I2C Bus 3 (6)" ;; 7) - echo "Failed Camera" + echo "Failed Camera (7)" ;; 8) - echo "Failed Payload" + echo "Failed Payload (8)" ;; 9) - echo "Failed BME Sensor" + echo "Failed BME Sensor (9)" ;; 10) - echo "Failed MPU Sensor" + echo "Failed MPU Sensor (10)" ;; "11") - echo "Failed FM Audio" + echo "Failed FM Audio (11)" ;; *) echo "Unknown Failure" @@ -337,7 +337,7 @@ if [ "$1" = "" ]; then fi if [ "${12}" = "y" ] || [ "${12}" = "yes" ] ; then - echo "Random Failure Mode is ON" + echo "Random Failure Mode is ON with time period " ${13} " seconds" else echo "Random Failure Mode is OFF" fi From 7de6ef2974b1e485b9ad759cc7bb25d4f9a3a624 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 11:01:44 -0400 Subject: [PATCH 194/295] Update config spacing --- config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config b/config index 91f33955..f36c9af8 100755 --- a/config +++ b/config @@ -337,7 +337,7 @@ if [ "$1" = "" ]; then fi if [ "${12}" = "y" ] || [ "${12}" = "yes" ] ; then - echo "Random Failure Mode is ON with time period " ${13} " seconds" + echo "Random Failure Mode is ON with time period" ${13} "seconds" else echo "Random Failure Mode is OFF" fi @@ -1081,7 +1081,7 @@ elif [ "$1" = "-P" ]; then echo echo "Editing the PL (Private Line) CTCSS/CDCSS setting in" - echo "the configuration file for CubeSatSim" + echo "the configuration file for CubeSatSim" echo value=`cat /home/pi/CubeSatSim/sim.cfg` @@ -1735,7 +1735,7 @@ elif [ "$1" = "-U" ]; then echo "Random Simulated Failure is ON" echo echo "A new random failure is selected every" - echo ${13} " seconds." + echo ${13} "seconds." echo echo "Enter a new value or Return keeps current value." From 685b6c0037132119fe1a62cbc7bb1092172ff9b1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 17 Aug 2025 11:44:47 -0400 Subject: [PATCH 195/295] Update install fix Bullseye text --- install | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install b/install index 2e590c3c..4049706e 100755 --- a/install +++ b/install @@ -5,9 +5,10 @@ echo -e "\ninstallation script for CubeSatSim v2.2\n" if [[ $(grep '11.' /etc/debian_version) ]]; then echo "Installing on Debian 11 (Bullseye)" else - echo "This is not Debian 11 (Bullseye)!" + echo "The OS is not Debian 11 (Bullseye)!" echo "Installation is not likely to work." - echo "Recommend you start with a Bullseye." + echo "It is recommended you start with" + echo "Bullseye as your OS." echo sleep 10 fi From 2a9161bc9e5e28f54f467c426a21f0a85ff0f76c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 21 Aug 2025 13:35:26 -0400 Subject: [PATCH 196/295] 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 197/295] 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 198/295] 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 199/295] 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 200/295] 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 201/295] 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 202/295] 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 203/295] 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 204/295] 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 205/295] 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 206/295] 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 207/295] 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 208/295] 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 209/295] 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 210/295] 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 211/295] 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 212/295] 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 213/295] 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 214/295] 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 215/295] 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 216/295] 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 217/295] 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 218/295] 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 219/295] 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 220/295] 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 221/295] 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 222/295] 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 223/295] 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 224/295] 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 225/295] 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 226/295] 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 227/295] 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 228/295] 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 229/295] 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 230/295] 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 231/295] 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 232/295] 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 233/295] 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 234/295] 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 235/295] 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 236/295] 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 237/295] 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 238/295] 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 239/295] 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 240/295] 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 241/295] 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 242/295] 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 243/295] 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 244/295] 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"); From 4b405fafcb326071dd9003f3d4f562bd6c9af380 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 28 Aug 2025 09:39:23 -0400 Subject: [PATCH 245/295] Update main.c add S for simulated telem in APRS and CW --- main.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index d3c1403d..a8cdb502 100644 --- a/main.c +++ b/main.c @@ -677,12 +677,17 @@ int main(int argc, char * argv[]) { char timeStampNoNl[31], bat_string[31]; snprintf(timeStampNoNl, 30, "%.24s", ctime(&timeStamp)); // printf("TimeStamp: %s\n", timeStampNoNl); - +/* if (c2cStatus == DISABLED) snprintf(bat_string, 30, "BAT %4.2f %5.1f", batteryVoltage, batteryCurrent); else snprintf(bat_string, 30, "BAT %4.2f %5.1f C", batteryVoltage, batteryCurrent); - + */ + snprintf(bat_string, 30, "BAT %4.2f %5.1f", batteryVoltage, batteryCurrent); + if (c2cStatus != DISABLED) + strcpy(bat_string," C"); + if (sim_mode || (failureMode != FAIL_NONE)) + strcpy(bat_string," S"); fprintf(telem_file, "%s %s %s\n", timeStampNoNl, bat_string, sensor_payload); // write telemetry string to telem.txt file fclose(telem_file); @@ -992,11 +997,21 @@ int main(int argc, char * argv[]) { FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); if (fp != NULL) { // printf("Writing telem_string.txt\n"); - if (batteryVoltage != 4.5) + if (batteryVoltage != 4.5) { +/* if (c2cStatus == DISABLED) fprintf(fp, "BAT %4.2fV %4.0fmA\n", batteryVoltage, batteryCurrent); else fprintf(fp, "BAT %4.2fV %4.0fmA C\n", batteryVoltage, batteryCurrent); // show command and control is on + */ + fprintf(fp, "BAT %4.2fV %4.0fmA", batteryVoltage, batteryCurrent); + if (c2cStatus != DISABLED) + fprintf(fp," C"); + if (sim_mode || (failureMode != FAIL_NONE)) + fprintf(fp," S\n"); + else + fprintf(fp,"\n"); + } else fprintf(fp, "\n"); // don't show voltage and current if it isn't a sensor value @@ -1233,13 +1248,19 @@ void get_tlm(void) { // fclose(file_append); // } } else { // APRS - +/* if (c2cStatus == 0) sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); else sprintf(tlm_str, "BAT %4.2f %5.1f C ", batteryVoltage, batteryCurrent); - - strcat(str, tlm_str); +*/ + snprintf(tlm_str, 30, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); + if (c2cStatus != DISABLED) + strcpy(tlm_str,"C "); + if (sim_mode || (failureMode != FAIL_NONE)) + strcpy(tlm_str,"S "); + + strcat(str, tlm_str); } // strcpy(sensor_payload, buffer2); From 4aa43f18eab57f87a4dc3a5a256e5317fd1dce01 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 28 Aug 2025 09:45:29 -0400 Subject: [PATCH 246/295] Update main.c copy to cat --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index a8cdb502..c41940cc 100644 --- a/main.c +++ b/main.c @@ -685,9 +685,9 @@ int main(int argc, char * argv[]) { */ snprintf(bat_string, 30, "BAT %4.2f %5.1f", batteryVoltage, batteryCurrent); if (c2cStatus != DISABLED) - strcpy(bat_string," C"); + strcat(bat_string," C"); if (sim_mode || (failureMode != FAIL_NONE)) - strcpy(bat_string," S"); + strcat(bat_string," S"); fprintf(telem_file, "%s %s %s\n", timeStampNoNl, bat_string, sensor_payload); // write telemetry string to telem.txt file fclose(telem_file); @@ -1256,9 +1256,9 @@ void get_tlm(void) { */ snprintf(tlm_str, 30, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); if (c2cStatus != DISABLED) - strcpy(tlm_str,"C "); + strcat(tlm_str,"C "); if (sim_mode || (failureMode != FAIL_NONE)) - strcpy(tlm_str,"S "); + strcat(tlm_str,"S "); strcat(str, tlm_str); } From 373d72f62678f231e6526a468c96ca3987eeab29 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 28 Aug 2025 09:50:55 -0400 Subject: [PATCH 247/295] Update main.c remove extra spaces --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index c41940cc..1bcd9a33 100644 --- a/main.c +++ b/main.c @@ -683,7 +683,7 @@ int main(int argc, char * argv[]) { else snprintf(bat_string, 30, "BAT %4.2f %5.1f C", batteryVoltage, batteryCurrent); */ - snprintf(bat_string, 30, "BAT %4.2f %5.1f", batteryVoltage, batteryCurrent); + snprintf(bat_string, 30, "BAT %.2f %.1f", batteryVoltage, batteryCurrent); if (c2cStatus != DISABLED) strcat(bat_string," C"); if (sim_mode || (failureMode != FAIL_NONE)) @@ -1004,7 +1004,7 @@ int main(int argc, char * argv[]) { else fprintf(fp, "BAT %4.2fV %4.0fmA C\n", batteryVoltage, batteryCurrent); // show command and control is on */ - fprintf(fp, "BAT %4.2fV %4.0fmA", batteryVoltage, batteryCurrent); + fprintf(fp, "BAT %.2fV %.0fmA", batteryVoltage, batteryCurrent); if (c2cStatus != DISABLED) fprintf(fp," C"); if (sim_mode || (failureMode != FAIL_NONE)) @@ -1254,7 +1254,7 @@ void get_tlm(void) { else sprintf(tlm_str, "BAT %4.2f %5.1f C ", batteryVoltage, batteryCurrent); */ - snprintf(tlm_str, 30, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); + snprintf(tlm_str, 30, "BAT %.2f %.1f ", batteryVoltage, batteryCurrent); if (c2cStatus != DISABLED) strcat(tlm_str,"C "); if (sim_mode || (failureMode != FAIL_NONE)) From 6f4c68d50dd14eb605bfaabf1b091e367306ae84 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 28 Aug 2025 10:26:09 -0400 Subject: [PATCH 248/295] Update main.c fix cw --- main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 1bcd9a33..887ab76b 100644 --- a/main.c +++ b/main.c @@ -1215,8 +1215,11 @@ void get_tlm(void) { strcat(str, header_str4); strcat(str, call); if (c2cStatus != DISABLED) { - strcat(str, header_c2c); + strcat(str, " C"); } + if (sim_mode || failureMode != FAIL_NONE) { + strcat(str, " S"); + } sprintf(tlm_str, "%s' > cw0.txt", &str); printf("CW string to execute: %s\n", &tlm_str); @@ -1259,8 +1262,8 @@ void get_tlm(void) { strcat(tlm_str,"C "); if (sim_mode || (failureMode != FAIL_NONE)) strcat(tlm_str,"S "); - - strcat(str, tlm_str); +// printf("tlm_str: %s\n", tlm_str); +// strcat(str, tlm_str); } // strcpy(sensor_payload, buffer2); From ef48e3f18ab745619dffa9a8862ed55fc497bdde Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 28 Aug 2025 10:57:24 -0400 Subject: [PATCH 249/295] Update main.c fix aprs --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 887ab76b..13b88a40 100644 --- a/main.c +++ b/main.c @@ -1263,7 +1263,7 @@ void get_tlm(void) { if (sim_mode || (failureMode != FAIL_NONE)) strcat(tlm_str,"S "); // printf("tlm_str: %s\n", tlm_str); -// strcat(str, tlm_str); +/ strcat(str, tlm_str); } // strcpy(sensor_payload, buffer2); From 33900a0266bb5a9a6bc44e57f433da4d62a55487 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 28 Aug 2025 10:58:09 -0400 Subject: [PATCH 250/295] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 13b88a40..6a27052c 100644 --- a/main.c +++ b/main.c @@ -1263,7 +1263,7 @@ void get_tlm(void) { if (sim_mode || (failureMode != FAIL_NONE)) strcat(tlm_str,"S "); // printf("tlm_str: %s\n", tlm_str); -/ strcat(str, tlm_str); + strcat(str, tlm_str); } // strcpy(sensor_payload, buffer2); From 72b32990eccdf25f434a8e009c3e547b95812c3f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 1 Sep 2025 10:02:47 -0400 Subject: [PATCH 251/295] Update update add .updated to branch change --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index 722a8fcb..b4a9824c 100755 --- a/update +++ b/update @@ -53,7 +53,7 @@ git pull --no-rebase > .updated if [ $checkout -eq 1 ]; then git checkout $branch - git pull --no-rebase + git pull --no-rebase > .updated fi make debug From 4dc302e155655a1965d3deb9efcf31f6f204dfa5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 1 Sep 2025 14:10:57 -0400 Subject: [PATCH 252/295] Update main.h change threshold to 3.55 V --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index e87ee936..95cbbf59 100644 --- a/main.h +++ b/main.h @@ -179,7 +179,7 @@ int frames_sent = 0; int cw_id = ON; int transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF; // float voltageThreshold = 3.6, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100; -float voltageThreshold = 3.5, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100; +float voltageThreshold = 3.55, batteryVoltage = 4.5, batteryCurrent = 0, currentThreshold = 100; float latitude = 39.027702f, longitude = -77.078064f; float lat_file, long_file; double cpuTemp; From 0e5331ed6aaf6f867cc28e79758b947e1da99b21 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 4 Sep 2025 10:26:30 -0400 Subject: [PATCH 253/295] Update update add MPU6050 Pi code --- update | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/update b/update index b4a9824c..76e5f309 100755 --- a/update +++ b/update @@ -275,11 +275,40 @@ elif [ ! -f "/home/pi/fctelem/v0.2" ]; then FLAG=1 fi +if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then + echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" + sudo apt-get install -y libi2c-dev + cd + git clone git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git + cd MPU6050-C-CPP-Library-for-Raspberry-Pi + sudo make install + make example + g++ mpu6050.o -o mpu6050 -lMPU6050 -pthread +fi + +cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi + + git checkout master + + git pull --no-rebase > .updated_p + +# grep 'changed' /home/pi/ssdv/.updated_p + if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then + + echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" + sudo make install + make example + g++ mpu6050.o -o mpu6050 -lMPU6050 -pthread + + else + echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." + fi + if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then echo "Installing fcdctl to set FUNcubeDongle Pro gain" sudo rm /var/lib/dpkg/info/python3-pip.list sudo apt install python3-pip --reinstall - sudo apt-get install -y python3-smbus libusb-1.0 -y + sudo apt-get install -y python3-smbus libusb-1.0 cd git clone https://github.com/csete/fcdctl.git cd fcdctl From 0d3eee64e51545fc42d59db6a9f72c4b720785cf Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 4 Sep 2025 10:28:50 -0400 Subject: [PATCH 254/295] Update update fix clone typo --- update | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/update b/update index 76e5f309..dbaa227c 100755 --- a/update +++ b/update @@ -279,7 +279,7 @@ if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" sudo apt-get install -y libi2c-dev cd - git clone git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git + git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git cd MPU6050-C-CPP-Library-for-Raspberry-Pi sudo make install make example @@ -287,10 +287,8 @@ if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then fi cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi - - git checkout master - - git pull --no-rebase > .updated_p +git checkout master +git pull --no-rebase > .updated_p # grep 'changed' /home/pi/ssdv/.updated_p if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then From e7bba7143f8b30bfac6509c26b4d6fefb316ca77 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 4 Sep 2025 10:30:15 -0400 Subject: [PATCH 255/295] Update update add .cpp --- update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update b/update index dbaa227c..0360fc0c 100755 --- a/update +++ b/update @@ -283,7 +283,7 @@ if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then cd MPU6050-C-CPP-Library-for-Raspberry-Pi sudo make install make example - g++ mpu6050.o -o mpu6050 -lMPU6050 -pthread + g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread fi cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi @@ -296,7 +296,7 @@ git pull --no-rebase > .updated_p echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" sudo make install make example - g++ mpu6050.o -o mpu6050 -lMPU6050 -pthread + g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread else echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." From ec7bfc097720c1a3396a98548dafcf166ac20d1a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 4 Sep 2025 10:40:02 -0400 Subject: [PATCH 256/295] Update update check for d not f --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index 0360fc0c..a0a3d90b 100755 --- a/update +++ b/update @@ -275,7 +275,7 @@ elif [ ! -f "/home/pi/fctelem/v0.2" ]; then FLAG=1 fi -if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then +if [ ! -d "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" sudo apt-get install -y libi2c-dev cd From cd9e66c7925ef260ee49ea75acb50c5353f8316a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 4 Sep 2025 11:35:58 -0400 Subject: [PATCH 257/295] Update update add bme280 --- update | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/update b/update index a0a3d90b..000752f2 100755 --- a/update +++ b/update @@ -290,17 +290,39 @@ cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi git checkout master git pull --no-rebase > .updated_p -# grep 'changed' /home/pi/ssdv/.updated_p - if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then - - echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" - sudo make install +if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then + + echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" + sudo make install make example g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread - else - echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." - fi +else + echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." +fi + +if [ ! -d "/home/pi/raspberry-pi-bme280" ]; then + echo "Installing raspberry-pi-bme280" + sudo apt-get install -y libi2c-dev + cd + git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git + cd MPU6050-C-CPP-Library-for-Raspberry-Pi + git checkout payload + make +fi + +cd /home/pi/raspberry-pi-bme280 +git checkout payload +git pull --no-rebase > .updated_p + +if [[ $(grep 'changed' /home/pi/raspberry-pi-bme280/.updated_p) ]]; then + + echo "updating raspberry-pi-bme280" + make + +else + echo "nothing to do for raspberry-pi-bme280." +fi if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then echo "Installing fcdctl to set FUNcubeDongle Pro gain" From a65fa98871aa905c3ab097bdafba5d0dfe95c31b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 4 Sep 2025 12:09:48 -0400 Subject: [PATCH 258/295] Update update add lib --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index 000752f2..9f0473a1 100755 --- a/update +++ b/update @@ -283,7 +283,7 @@ if [ ! -d "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then cd MPU6050-C-CPP-Library-for-Raspberry-Pi sudo make install make example - g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread + g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c fi cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi From 479e3348447c2f67cd40b4f05fb610e17d7f16ea Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 4 Sep 2025 12:17:26 -0400 Subject: [PATCH 259/295] Update update add lib --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index 9f0473a1..664ac0cc 100755 --- a/update +++ b/update @@ -295,7 +295,7 @@ if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_ echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" sudo make install make example - g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread + g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c else echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." From cd9a6111a07eef2b618cd994b685445db842843b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 07:55:19 -0400 Subject: [PATCH 260/295] Update main.c show sim_mode --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 6a27052c..02c2b383 100644 --- a/main.c +++ b/main.c @@ -1757,7 +1757,7 @@ void get_tlm_fox() { simulated = sim_mode; if (failureMode != FAIL_NONE) { simulated = TRUE; -// printf("Showing Simulted in FoxTelem\n"); + printf("Showing Simulted in FoxTelem\n"); } int i2c_1, i2c_3; i2c_1 = i2c_bus1; From a8bb3648ace94159e4b674e2f0a6589e998e774b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 08:12:12 -0400 Subject: [PATCH 261/295] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 02c2b383..20a770db 100644 --- a/main.c +++ b/main.c @@ -1757,7 +1757,7 @@ void get_tlm_fox() { simulated = sim_mode; if (failureMode != FAIL_NONE) { simulated = TRUE; - printf("Showing Simulted in FoxTelem\n"); + printf("Showing Simulated in FoxTelem\n"); } int i2c_1, i2c_3; i2c_1 = i2c_bus1; From 2ce445feb236e79837421bad85be7daa1eda570b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 08:17:29 -0400 Subject: [PATCH 262/295] Update sensor_extension.c read bme --- sensor_extension.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sensor_extension.c b/sensor_extension.c index a0494350..aea871cd 100644 --- a/sensor_extension.c +++ b/sensor_extension.c @@ -19,12 +19,17 @@ void sensor_setup() { // Very Important: only use print, not println!! int sensor_loop(char *sensor_buffer) { - int sensors = 3; // set to the number of sensor readings adding. + int sensors = 4; // set to the number of sensor readings adding. sensor_buffer[0] = 0; // make sure buffer is empty printf("Reading new sensors!\n"); + + FILE *sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present + fgets(sensor_buffer, 1000, sensor_read); +// fprintf(stderr, "result: %s\n", sensor_buffer); + fclose(sensor_read); - strcpy(sensor_buffer, "NEW 0.0 0.0 0.0"); +// strcpy(sensor_buffer, "NEW 0.0 0.0 0.0"); printf("New sensor string: %s\n", sensor_buffer); From 87f729aa178f7166f2af98b495821cee0eac7426 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 08:25:52 -0400 Subject: [PATCH 263/295] Update sensor_extension.c --- sensor_extension.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensor_extension.c b/sensor_extension.c index aea871cd..85d98db6 100644 --- a/sensor_extension.c +++ b/sensor_extension.c @@ -23,7 +23,7 @@ int sensor_loop(char *sensor_buffer) { sensor_buffer[0] = 0; // make sure buffer is empty printf("Reading new sensors!\n"); - + FILE *sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present fgets(sensor_buffer, 1000, sensor_read); // fprintf(stderr, "result: %s\n", sensor_buffer); From f7b4cf596e8b5029d6676486a07e5c7bf72eb047 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:33:16 -0400 Subject: [PATCH 264/295] Update sensor_extension.c remove extra --- sensor_extension.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sensor_extension.c b/sensor_extension.c index 85d98db6..5c958a5a 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!\n"); +// printf("Starting new sensor!\n"); } @@ -19,19 +19,15 @@ void sensor_setup() { // Very Important: only use print, not println!! int sensor_loop(char *sensor_buffer) { - int sensors = 4; // set to the number of sensor readings adding. + int sensors = 0; // set to the number of sensor readings adding. sensor_buffer[0] = 0; // make sure buffer is empty - printf("Reading new sensors!\n"); - - FILE *sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present - fgets(sensor_buffer, 1000, sensor_read); -// fprintf(stderr, "result: %s\n", sensor_buffer); - fclose(sensor_read); +// printf("Reading new sensors!\n"); +// sensors = 3; // strcpy(sensor_buffer, "NEW 0.0 0.0 0.0"); - printf("New sensor string: %s\n", sensor_buffer); +// printf("New sensor string: %s\n", sensor_buffer); return(sensors); From 2b73a277f51df0363b12fa928097e83aa7394309 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:37:38 -0400 Subject: [PATCH 265/295] Update main.h add pi_sensors --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index 95cbbf59..0ba9c824 100644 --- a/main.h +++ b/main.h @@ -247,6 +247,7 @@ int groundCommandCount = 0; void sensor_setup(); // defined in sensor_extension.c int sensor_loop(char *sensor_buffer); // defined in sensor_extension.c +int pi_sensors(char *buffer); // used to read BME and MPU sensor if connected to Pi // from funcubeLib/common/fecConstants.h From a794d178f9b2fccd4401b65f0ddae7b15e534f39 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:43:52 -0400 Subject: [PATCH 266/295] Update main.c add pi_sensors --- main.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 20a770db..4a06d713 100644 --- a/main.c +++ b/main.c @@ -647,13 +647,18 @@ int main(int argc, char * argv[]) { } - payload = get_payload_serial(FALSE); - printf("get_payload_status: %d \n", payload); // not debug +#ifdef PI_SENSORS + payload = pi_sensors(buffer2); + printf("pi_sensors status: %d \n", payload); +#else + payload = get_payload_serial(FALSE); // not debug + printf("get_payload_status: %d \n", payload); +#endif fflush(stdout); // printf("String: %s\n", buffer2); fflush(stdout); strcpy(sensor_payload, buffer2); - + printf(" Response from STEM Payload: %s\n", sensor_payload); char sensor_buffer[30]; @@ -2900,3 +2905,17 @@ void socket_send(int length) { if (socket_open == 1) firstTime = 0; } + +int pi_sensors(char *buffer) +{ + char sensor_buffer[1000]; + strcpy(buffer, "OK BME280 "); + + FILE *sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present + fgets(sensor_buffer, 1000, sensor_read); +// fprintf(stderr, "result: %s\n", sensor_buffer); + fclose(sensor_read); + strcpy(buffer, sensor_buffer); + + return (1); +} From b9bba186335615a638e7bf4146678828ae26dc72 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:46:42 -0400 Subject: [PATCH 267/295] Update main.c add PI_SENSORS flag --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 4a06d713..5c7c4065 100644 --- a/main.c +++ b/main.c @@ -19,6 +19,7 @@ * along with this program. If not, see . */ +#define PI_SENSORS #include "main.h" //#define HAB // uncomment to change APRS icon from Satellite to Balloon and only BAT telemetry From ac6bcfc1d6ffc9658d673212afac13cf85e86687 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:50:48 -0400 Subject: [PATCH 268/295] Update main.c add print --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 5c7c4065..104a7f22 100644 --- a/main.c +++ b/main.c @@ -2914,9 +2914,10 @@ int pi_sensors(char *buffer) FILE *sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present fgets(sensor_buffer, 1000, sensor_read); -// fprintf(stderr, "result: %s\n", sensor_buffer); + fprintf(stderr, "result: %s\n", sensor_buffer); fclose(sensor_read); - strcpy(buffer, sensor_buffer); + strcat(buffer, sensor_buffer); + fprintf(stderr, "pi_sensors string: %s\n", buffer); return (1); } From bd97aa6b20188f0a2de24207503fa69133eb809c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:54:05 -0400 Subject: [PATCH 269/295] Update main.c read MPU too --- main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.c b/main.c index 104a7f22..e8235c5d 100644 --- a/main.c +++ b/main.c @@ -2917,6 +2917,15 @@ int pi_sensors(char *buffer) fprintf(stderr, "result: %s\n", sensor_buffer); fclose(sensor_read); strcat(buffer, sensor_buffer); + + strcpy(buffer, "MPU6050 "); + + FILE *sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050"); // read MPU if present + fgets(sensor_buffer, 1000, sensor_read); + fprintf(stderr, "result: %s\n", sensor_buffer); + fclose(sensor_read); + strcat(buffer, sensor_buffer); + fprintf(stderr, "pi_sensors string: %s\n", buffer); return (1); From 952a2e6909bc480e8375200aba3a6c657a87ef6c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:55:14 -0400 Subject: [PATCH 270/295] Update main.c fix FILE --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index e8235c5d..20e17986 100644 --- a/main.c +++ b/main.c @@ -2910,9 +2910,11 @@ void socket_send(int length) { int pi_sensors(char *buffer) { char sensor_buffer[1000]; + FILE *sensor_read; + strcpy(buffer, "OK BME280 "); - FILE *sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present + sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present fgets(sensor_buffer, 1000, sensor_read); fprintf(stderr, "result: %s\n", sensor_buffer); fclose(sensor_read); @@ -2920,7 +2922,7 @@ int pi_sensors(char *buffer) strcpy(buffer, "MPU6050 "); - FILE *sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050"); // read MPU if present + sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050"); // read MPU if present fgets(sensor_buffer, 1000, sensor_read); fprintf(stderr, "result: %s\n", sensor_buffer); fclose(sensor_read); From 3907cfc2d0e433244597d092793aacd08e8b0ba6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 09:57:18 -0400 Subject: [PATCH 271/295] Update main.c cat not copy --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 20e17986..f5cf7273 100644 --- a/main.c +++ b/main.c @@ -2920,7 +2920,7 @@ int pi_sensors(char *buffer) fclose(sensor_read); strcat(buffer, sensor_buffer); - strcpy(buffer, "MPU6050 "); + strcat(buffer, "MPU6050 "); sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050"); // read MPU if present fgets(sensor_buffer, 1000, sensor_read); From fdc2b1fe742df3fc31385b9ccb21d344dd95bcb4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 10:00:02 -0400 Subject: [PATCH 272/295] Update main.c prints --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index f5cf7273..6d67d3f0 100644 --- a/main.c +++ b/main.c @@ -2916,7 +2916,7 @@ int pi_sensors(char *buffer) sensor_read = sopen("/home/pi/raspberry-pi-bme280/bme280"); // read BME if present fgets(sensor_buffer, 1000, sensor_read); - fprintf(stderr, "result: %s\n", sensor_buffer); + fprintf(stderr, "bme result: %s\n", sensor_buffer); fclose(sensor_read); strcat(buffer, sensor_buffer); @@ -2924,7 +2924,7 @@ int pi_sensors(char *buffer) sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050"); // read MPU if present fgets(sensor_buffer, 1000, sensor_read); - fprintf(stderr, "result: %s\n", sensor_buffer); + fprintf(stderr, "mpu result: %s\n", sensor_buffer); fclose(sensor_read); strcat(buffer, sensor_buffer); From ba0c337fdc2460474a557145f21a0a5a7c53b6df Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 10:12:24 -0400 Subject: [PATCH 273/295] Update main.c remove \n in bme --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 6d67d3f0..b9b6c788 100644 --- a/main.c +++ b/main.c @@ -2918,6 +2918,8 @@ int pi_sensors(char *buffer) fgets(sensor_buffer, 1000, sensor_read); fprintf(stderr, "bme result: %s\n", sensor_buffer); fclose(sensor_read); + if (sensor_buffer[strlen(sensor_buffer) - 1] == '\n') + sensor_buffer[strlen(sensor_buffer) - 1] = '\0'; // remove newline at end strcat(buffer, sensor_buffer); strcat(buffer, "MPU6050 "); @@ -2926,7 +2928,7 @@ int pi_sensors(char *buffer) fgets(sensor_buffer, 1000, sensor_read); fprintf(stderr, "mpu result: %s\n", sensor_buffer); fclose(sensor_read); - strcat(buffer, sensor_buffer); + strcat(buffer, sensor_buffer); // no need to remove newline at end fprintf(stderr, "pi_sensors string: %s\n", buffer); From a8b2c2e96ceb6fccd758863ed37a0b70ee0c4bd6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 10:17:50 -0400 Subject: [PATCH 274/295] Update main.c add space before MPU --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index b9b6c788..d9ca9bc7 100644 --- a/main.c +++ b/main.c @@ -2922,7 +2922,7 @@ int pi_sensors(char *buffer) sensor_buffer[strlen(sensor_buffer) - 1] = '\0'; // remove newline at end strcat(buffer, sensor_buffer); - strcat(buffer, "MPU6050 "); + strcat(buffer, " MPU6050 "); sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050"); // read MPU if present fgets(sensor_buffer, 1000, sensor_read); From e72cb298cc86960453d4b4a42ba9d6b1801e4b2a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 13:16:17 -0400 Subject: [PATCH 275/295] Update update make payload --- update | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/update b/update index 664ac0cc..becb390d 100755 --- a/update +++ b/update @@ -282,8 +282,8 @@ if [ ! -d "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git cd MPU6050-C-CPP-Library-for-Raspberry-Pi sudo make install - make example - g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c + make payload +// g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c fi cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi @@ -294,8 +294,8 @@ if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_ echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" sudo make install - make example - g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c + make payload +// g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c else echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." From dd9d7954c09f9158c665912319ebd76eb0c772c6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 13:24:13 -0400 Subject: [PATCH 276/295] Update update typo --- update | 3 --- 1 file changed, 3 deletions(-) diff --git a/update b/update index becb390d..40ff5393 100755 --- a/update +++ b/update @@ -283,7 +283,6 @@ if [ ! -d "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then cd MPU6050-C-CPP-Library-for-Raspberry-Pi sudo make install make payload -// g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c fi cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi @@ -295,8 +294,6 @@ if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_ echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" sudo make install make payload -// g++ mpu6050.cpp -o mpu6050 -lMPU6050 -pthread -li2c - else echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." fi From aca71a434e24966b0a1264fa393078377d3d1d12 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 14:27:55 -0400 Subject: [PATCH 277/295] Update main.c add pi_sensor payload --- main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.c b/main.c index d9ca9bc7..a420b67b 100644 --- a/main.c +++ b/main.c @@ -2927,6 +2927,19 @@ int pi_sensors(char *buffer) sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050"); // read MPU if present fgets(sensor_buffer, 1000, sensor_read); fprintf(stderr, "mpu result: %s\n", sensor_buffer); + fclose(sensor_read); + if (sensor_buffer[strlen(sensor_buffer) - 1] == '\n') + sensor_buffer[strlen(sensor_buffer) - 1] = '\0'; // remove newline at end + + fprintf(stderr, "pi_sensors string: %s\n", buffer); + + strcat(buffer, " GPS 0.0 0.0 0.0 TMP 0.0"); // place holders for GPS and diode temp + + strcat(buffer, " YPR "); + + sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/ypr"); // read MPU if present + fgets(sensor_buffer, 1000, sensor_read); + fprintf(stderr, "mpu result: %s\n", sensor_buffer); fclose(sensor_read); strcat(buffer, sensor_buffer); // no need to remove newline at end From b3153a55c2aaeb532075006f512dd9adb7e2a904 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 14:31:43 -0400 Subject: [PATCH 278/295] Update main.c include mpu sensor --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index a420b67b..35c907b0 100644 --- a/main.c +++ b/main.c @@ -2930,6 +2930,7 @@ int pi_sensors(char *buffer) fclose(sensor_read); if (sensor_buffer[strlen(sensor_buffer) - 1] == '\n') sensor_buffer[strlen(sensor_buffer) - 1] = '\0'; // remove newline at end + strcat(buffer, sensor_buffer); fprintf(stderr, "pi_sensors string: %s\n", buffer); From f6149850488e193984590394d55a31c5903f8508 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 5 Sep 2025 14:39:46 -0400 Subject: [PATCH 279/295] Update main.c remove /n at end --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index 35c907b0..9e9541ce 100644 --- a/main.c +++ b/main.c @@ -2942,6 +2942,8 @@ int pi_sensors(char *buffer) fgets(sensor_buffer, 1000, sensor_read); fprintf(stderr, "mpu result: %s\n", sensor_buffer); fclose(sensor_read); + if (sensor_buffer[strlen(sensor_buffer) - 1] == '\n') + sensor_buffer[strlen(sensor_buffer) - 1] = '\0'; // remove newline at end strcat(buffer, sensor_buffer); // no need to remove newline at end fprintf(stderr, "pi_sensors string: %s\n", buffer); From 7d80b3e6f7cfd3ad795ad23dfdc5dababe7334e5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 9 Sep 2025 14:50:02 -0400 Subject: [PATCH 280/295] Update update change to check for mpu and bme binaries --- update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update b/update index 40ff5393..dfc6940e 100755 --- a/update +++ b/update @@ -275,7 +275,7 @@ elif [ ! -f "/home/pi/fctelem/v0.2" ]; then FLAG=1 fi -if [ ! -d "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi" ]; then +if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050" ]; then echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" sudo apt-get install -y libi2c-dev cd @@ -298,7 +298,7 @@ else echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." fi -if [ ! -d "/home/pi/raspberry-pi-bme280" ]; then +if [ ! -f "/home/pi/raspberry-pi-bme280/bme280" ]; then echo "Installing raspberry-pi-bme280" sudo apt-get install -y libi2c-dev cd From 3d4995b3c2e3a63cba31edfc5118c46f8974fbf0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 9 Sep 2025 14:53:17 -0400 Subject: [PATCH 281/295] Update update fix typo in bme install --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index dfc6940e..28ea9157 100755 --- a/update +++ b/update @@ -303,7 +303,7 @@ if [ ! -f "/home/pi/raspberry-pi-bme280/bme280" ]; then sudo apt-get install -y libi2c-dev cd git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git - cd MPU6050-C-CPP-Library-for-Raspberry-Pi + cd raspberry-pi-bme280 git checkout payload make fi From f65b291f75ce9089998de485b01d17e58e816891 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 10 Sep 2025 09:44:43 -0400 Subject: [PATCH 282/295] Update transmit.py fix no fm --- transmit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index 44c8a107..13201891 100644 --- a/transmit.py +++ b/transmit.py @@ -21,10 +21,10 @@ def sim_failure_check(): fail_mode = int(file.read(2)) # print("Fail_mode: ") # print(fail_mode) - if (fail_mode == 10): + if (fail_mode == 11): card = "Device" # Change audio so no FM audio plays print("Failure mode no FM audio") - elif (fail_mode == 6): + elif (fail_mode == 7): cam_fail = True print("Failure mode camera fail") elif (fail_mode == -1): From 2b418da08a23e237d5bdb79d3a3d09f49e277e22 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 10 Sep 2025 09:54:41 -0400 Subject: [PATCH 283/295] Update main.c show sim telem in sstv --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 9e9541ce..135829bc 100644 --- a/main.c +++ b/main.c @@ -1003,7 +1003,8 @@ int main(int argc, char * argv[]) { FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); if (fp != NULL) { // printf("Writing telem_string.txt\n"); - if (batteryVoltage != 4.5) { +// if (batteryVoltage != 4.5) { + if (true) { /* if (c2cStatus == DISABLED) fprintf(fp, "BAT %4.2fV %4.0fmA\n", batteryVoltage, batteryCurrent); From a3537e167bbb10d27244ddc0dc4f11592304008e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 10 Sep 2025 09:59:07 -0400 Subject: [PATCH 284/295] Update main.c fix typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 135829bc..71624557 100644 --- a/main.c +++ b/main.c @@ -1004,7 +1004,7 @@ int main(int argc, char * argv[]) { if (fp != NULL) { // printf("Writing telem_string.txt\n"); // if (batteryVoltage != 4.5) { - if (true) { + if (1) { /* if (c2cStatus == DISABLED) fprintf(fp, "BAT %4.2fV %4.0fmA\n", batteryVoltage, batteryCurrent); From 26c2d34d91519910ae8c473e80c7348098b97ea1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 10 Sep 2025 10:11:56 -0400 Subject: [PATCH 285/295] Update main.c show sim voltage and current in sstv --- main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 71624557..ae675938 100644 --- a/main.c +++ b/main.c @@ -1003,8 +1003,7 @@ int main(int argc, char * argv[]) { FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); if (fp != NULL) { // printf("Writing telem_string.txt\n"); -// if (batteryVoltage != 4.5) { - if (1) { + if (batteryVoltage != 4.5) { /* if (c2cStatus == DISABLED) fprintf(fp, "BAT %4.2fV %4.0fmA\n", batteryVoltage, batteryCurrent); @@ -1019,9 +1018,17 @@ int main(int argc, char * argv[]) { else fprintf(fp,"\n"); } - else - fprintf(fp, "\n"); // don't show voltage and current if it isn't a sensor value + else { + // 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"); From 37ba74ec1324a811e7d4dbd703011f1937e352e5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 10 Sep 2025 10:27:10 -0400 Subject: [PATCH 286/295] Update main.c add sim printf --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index ae675938..c23f1af5 100644 --- a/main.c +++ b/main.c @@ -1019,6 +1019,7 @@ int main(int argc, char * argv[]) { 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) From f8dea58560daa3750f5ad67a29355d6adfbf37f8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 10 Sep 2025 10:28:32 -0400 Subject: [PATCH 287/295] Update main.c missing ) --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index c23f1af5..c3d6e39a 100644 --- a/main.c +++ b/main.c @@ -1021,7 +1021,7 @@ int main(int argc, char * argv[]) { 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 + 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)) From 27722c6bece3914e738cbd39da21b0713474b2d0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 10 Sep 2025 10:47:12 -0400 Subject: [PATCH 288/295] Update transmit.py move string on sstv --- transmit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index 13201891..6ac1b713 100644 --- a/transmit.py +++ b/transmit.py @@ -156,8 +156,8 @@ def camera_photo(): # draw.text((120, 10), telem_string, font=font2, fill='white') draw.text((12, 12), callsign, font=font1, fill='black') draw.text((10, 10), callsign, font=font1, fill='white') - draw.text((122, 12), telem_string, font=font2, fill='black') - draw.text((120, 10), telem_string, font=font2, fill='white') + draw.text((112, 12), telem_string, font=font2, fill='black') # was 122 + draw.text((110, 10), telem_string, font=font2, fill='white') # was 120 img.save(file) print("CubeSatSim v2.2 transmit.py starting...") From 654bb84f92ec5fb7413c8ac4f2dcff3f0ecf237a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 20 Nov 2025 21:54:07 -0500 Subject: [PATCH 289/295] Update main.c pi_sensors if payload_serial fails --- main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index c3d6e39a..63d52af5 100644 --- a/main.c +++ b/main.c @@ -648,13 +648,16 @@ int main(int argc, char * argv[]) { } -#ifdef PI_SENSORS - payload = pi_sensors(buffer2); - printf("pi_sensors status: %d \n", payload); -#else + + + payload = get_payload_serial(FALSE); // not debug - printf("get_payload_status: %d \n", payload); -#endif + printf("get_payload_status: %d \n", payload); + if (payload == FALSE) { + payload = pi_sensors(buffer2); + printf("pi_sensors status: %d \n", payload); + } + fflush(stdout); // printf("String: %s\n", buffer2); fflush(stdout); From 6e5f2055cec50f345680c56ec050d70f92f77709 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 20 Nov 2025 22:04:38 -0500 Subject: [PATCH 290/295] Update main.c remove macro --- main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/main.c b/main.c index 63d52af5..a606d54c 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,6 @@ * along with this program. If not, see . */ -#define PI_SENSORS #include "main.h" //#define HAB // uncomment to change APRS icon from Satellite to Balloon and only BAT telemetry From 24c1287bacd9cb1a85a141a1a4834b99ec2a593e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 20 Nov 2025 22:06:07 -0500 Subject: [PATCH 291/295] Update update pushbutton back to master --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index 28ea9157..7d917ea6 100755 --- a/update +++ b/update @@ -336,7 +336,7 @@ cd /home/pi/pi-power-button git pull --no-rebase > .updated_p - git checkout next + git checkout master # grep 'changed' /home/pi/pi-power-button/.updated_p # if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then From f49d5d27352af1fb0e09372750657e1b8f24b184 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 20 Nov 2025 22:23:59 -0500 Subject: [PATCH 292/295] Update main.c don't sim payload if present --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index a606d54c..8fe22e65 100644 --- a/main.c +++ b/main.c @@ -757,7 +757,7 @@ int main(int argc, char * argv[]) { newGpsTime = millis(); } - if (sim_mode && (failureMode != FAIL_PAYLOAD)) { + if (sim_mode && (failureMode != FAIL_PAYLOAD) && !payload) { if (atmosphere == 0) { sensor[PRES] = 0; strcpy(sensor_string[PRES], "0.0"); From 06c979f8af485fd525a3e3b2133923561acd7933 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 20 Nov 2025 22:28:41 -0500 Subject: [PATCH 293/295] Update main.c remove if !sim_mode --- main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 8fe22e65..9dc4d137 100644 --- a/main.c +++ b/main.c @@ -704,7 +704,8 @@ int main(int argc, char * argv[]) { printf("Simulated Payload Failure.\n"); } - if (!sim_mode) { +//// if (!sim_mode) { + { if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { // printf("Valid Payload!\n"); @@ -757,12 +758,13 @@ int main(int argc, char * argv[]) { newGpsTime = millis(); } - if (sim_mode && (failureMode != FAIL_PAYLOAD) && !payload) { + if (sim_mode && (failureMode != FAIL_PAYLOAD) && !payload) { + printf("Generating simulated payload telemetry\n"); if (atmosphere == 0) { sensor[PRES] = 0; strcpy(sensor_string[PRES], "0.0"); sensor[ALT] = 400; - strcpy(sensor_string[ALT], "400"); + strcpy(sensor_string[ALT], "30000"); sensor[HUMI] = 0; strcpy(sensor_string[HUMI], "0.0"); sensor[TEMP] = 0; From 3eef68fc6c13911fe4e90772a1f1a56ec2e840b0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 20 Nov 2025 22:38:53 -0500 Subject: [PATCH 294/295] Update main.c pi_sensors returns 0 if nothing present --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 9dc4d137..a40fd11a 100644 --- a/main.c +++ b/main.c @@ -2961,5 +2961,8 @@ int pi_sensors(char *buffer) fprintf(stderr, "pi_sensors string: %s\n", buffer); - return (1); + if (strcmp(buffer, "OK BME280 0.0 0.0 0.0 0.0 MPU6050 0.0 0.0 0.0 0.0 0.0 0.0 GPS 0.0 0.0 0.0 TMP 0.0 YPR 0.0 0.0 0.0") == 0) + return (0); + else + return (1); } From 7a3586f924bbdf4c161d478f36ec263bb70c5684 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 21 Nov 2025 08:27:15 -0500 Subject: [PATCH 295/295] Update main.c remove YPR --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index a40fd11a..c2c96a2e 100644 --- a/main.c +++ b/main.c @@ -2948,7 +2948,7 @@ int pi_sensors(char *buffer) fprintf(stderr, "pi_sensors string: %s\n", buffer); strcat(buffer, " GPS 0.0 0.0 0.0 TMP 0.0"); // place holders for GPS and diode temp - +/* strcat(buffer, " YPR "); sensor_read = sopen("/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/ypr"); // read MPU if present @@ -2960,7 +2960,7 @@ int pi_sensors(char *buffer) strcat(buffer, sensor_buffer); // no need to remove newline at end fprintf(stderr, "pi_sensors string: %s\n", buffer); - +*/ if (strcmp(buffer, "OK BME280 0.0 0.0 0.0 0.0 MPU6050 0.0 0.0 0.0 0.0 0.0 0.0 GPS 0.0 0.0 0.0 TMP 0.0 YPR 0.0 0.0 0.0") == 0) return (0); else