From 717d8494a4869fa42845ffcd1eca77547c265059 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 7 Aug 2025 10:56:57 -0400 Subject: [PATCH 001/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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/395] 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 b3fceaaf41c7ce1702b8bb8694c3d9ee202535c8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:07:30 -0500 Subject: [PATCH 289/395] Update CubeSatSim_rttelemetry.csv add 10 bit ground commands count --- spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv index 556e73d3..5d0627de 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv @@ -1,4 +1,4 @@ -47,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION +48,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION 0,RT,Sensor 2,12,integer,1,Experiments,6,8,3,Sensor 2,STEM Payload Extra Sensor 2 1,RT,Sensor 3,12,integer,1,Experiments,6,9,3,Sensor 3,STEM Payload Extra Sensor 3 2,RT,BATT_V,12,V,cubesatsim_voltage|FLOAT2,Battery,4,1,3,Battery Voltage,INA219 Battery Voltage @@ -45,4 +45,6 @@ 43,RT,RXAntenna,1,-,16,Radio,1,3,0,RX Antenna,Receive antenna status 44,RT,TXAntenna,1,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status 45,RT,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status -46,RT,Pad,56,-,0,NONE,0,0,0,NONE,NONE +46,RT,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received +47,RT,Pad,46,-,0,NONE,0,0,0,NONE,NONE + From c50314af2b2c467e326a100258cc83221a2cf236 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:08:19 -0500 Subject: [PATCH 290/395] Update CubeSatSim_rttelemetry.csv remove old Ground Commands --- spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv index 5d0627de..c3a5ba3b 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv @@ -41,10 +41,11 @@ 39,RT,I2CBus1Failure,1,-,17,Computer Hardware,2,2,0,I2C Bus 1,I2C bus 1 failure indicator 40,RT,I2CBus3Failure,1,-,17,Computer Hardware,2,3,0,I2C Bus 3,I2C bus 3 failure indicator 41,RT,CameraFailure,1,-,17,Computer Hardware,2,4,0,Camera,Camera failure indicator -42,RT,GroundCommands,4,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received +42,RT,GroundCommands,4,-,1,Computer Software,0,0,0,Ground Commands,Number of ground commands received 43,RT,RXAntenna,1,-,16,Radio,1,3,0,RX Antenna,Receive antenna status 44,RT,TXAntenna,1,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status 45,RT,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status 46,RT,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received 47,RT,Pad,46,-,0,NONE,0,0,0,NONE,NONE + From c8da1ac6a2f8df8ba46adb2a17ba8858f9bcce34 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:16:24 -0500 Subject: [PATCH 291/395] Update main.c add 2nd groundCommandCount --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index fdfa7384..af213d10 100644 --- a/main.c +++ b/main.c @@ -1601,6 +1601,8 @@ void get_tlm_fox() { encodeA(b, 51 + head_offset, status); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); + encodeA(b, 54 + head_offset, groundCommandCount); + if (mode == BPSK) { encodeA(b_max, 51 + head_offset, status); encodeA(b_min, 51 + head_offset, status); From 93c4c90c2319b9c99c15d9150cf8d30261ee277e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:24:13 -0500 Subject: [PATCH 292/395] Update main.c change offset --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index af213d10..f5115e60 100644 --- a/main.c +++ b/main.c @@ -1601,7 +1601,7 @@ void get_tlm_fox() { encodeA(b, 51 + head_offset, status); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); - encodeA(b, 54 + head_offset, groundCommandCount); + encodeA(b, 53 + head_offset, groundCommandCount); if (mode == BPSK) { encodeA(b_max, 51 + head_offset, status); From 3714000a026d8a633c4c4664068a19a099bbbcd8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:28:04 -0500 Subject: [PATCH 293/395] Update CubeSatSim_PSK_rttelemetry.csv add groundCommandCount2 --- spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv index 2d34abc9..90735c39 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv @@ -1,4 +1,4 @@ -61,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION +62,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION 0,realTime,Sensor 2,12,integer,1,Experiments,6,8,3,Sensor 2,STEM Payload Extra Sensor 2 1,realTime,Sensor 3,12,integer,1,Experiments,6,9,3,Sensor 3,STEM Payload Extra Sensor 3 2,realTime,BATT_V,12,V,cubesatsim_voltage|FLOAT2,Battery,4,1,3,Battery Voltage,INA219 Battery Voltage @@ -41,7 +41,7 @@ 39,realTime,I2CBus1Failure,1,-,17,Computer Hardware,2,2,0,I2C Bus 1,I2C bus 1 failure indicator 40,realTime,I2CBus3Failure,1,-,17,Computer Hardware,2,3,0,I2C Bus 3,I2C bus 3 failure indicator 41,realTime,CameraFailure,1,-,17,Computer Hardware,2,4,0,Camera,Camera failure indicator -42,realTime,GroundCommands,4,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received +42,realTime,GroundCommands,4,-,1,NONE,0,0,0,Ground Commands,Number of ground commands received 43,realTime,RxAntenna,1,-,16,Radio,1,3,0,RX Antenna,Receive antenna status 44,realTime,TxAntenna,1,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status 45,realTime,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status @@ -59,4 +59,6 @@ 57,realTime,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information 58,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset 59,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset -60,realTime,pad2,27,-,0,NONE,0,0,0,NONE,Filler +60,realTime,GroundCommands,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received +61,realTime,pad2,27,-,0,NONE,0,0,0,NONE,Filler + From 99bdf193101ba2b4a0565834d2968e82e2ae9117 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:28:36 -0500 Subject: [PATCH 294/395] Update CubeSatSim_PSK_rttelemetry.csv reduce pad size --- spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv index 90735c39..67d1e57e 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv @@ -60,5 +60,6 @@ 58,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset 59,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset 60,realTime,GroundCommands,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received -61,realTime,pad2,27,-,0,NONE,0,0,0,NONE,Filler +61,realTime,pad2,17,-,0,NONE,0,0,0,NONE,Filler + From c5c518698ff83e346b366ef4ef11ca51e16ad785 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:29:59 -0500 Subject: [PATCH 295/395] Update CubeSatSim_PSK_rttelemetry.csv change name --- spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv index 67d1e57e..eed7d985 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv @@ -59,7 +59,8 @@ 57,realTime,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information 58,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset 59,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset -60,realTime,GroundCommands,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received +60,realTime,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received 61,realTime,pad2,17,-,0,NONE,0,0,0,NONE,Filler + From c63108f3bd98cdda3366f492701ccf83ae55df1c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:40:50 -0500 Subject: [PATCH 296/395] Update CubeSatSim_PSK_rttelemetry.csv move GroundCommands2 --- .../CubeSatSim_PSK_rttelemetry.csv | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv index eed7d985..bedd627b 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv @@ -45,22 +45,23 @@ 43,realTime,RxAntenna,1,-,16,Radio,1,3,0,RX Antenna,Receive antenna status 44,realTime,TxAntenna,1,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status 45,realTime,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status -46,realTime,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted -47,realTime,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V -48,realTime,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected -49,realTime,rf6,12,-,0,NONE,0,0,0,None,None -50,realTime,rf7,12,-,0,NONE,0,0,0,None,None -51,realTime,MuxTest,12,V,43,NONE,7,5,3,Sensor Power,Sensor Power Voltage at the ICR -52,realTime,LtVGACtl,12,V,42,NONE,1,4,3,VGA Control,Control Voltage to the Variable Gain Amplifier (VGA) -53,realTime,pad,4,-,34,NONE,0,0,0,None,Unused -54,realTime,IHUdiagData,32,-,18,NONE,3,2,0,Diagnostic Info,Diagnostic Data on IHU Performance -55,realTime,pad1,1,-,0,NONE,0,0,0,NONE,Filler -56,realTime,wodSize,8,000s,36,NONE,3,3,0,WOD Stored,Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds -57,realTime,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information -58,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset -59,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset -60,realTime,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received +46,realTime,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received +47,realTime,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted +48,realTime,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V +49,realTime,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected +50,realTime,rf6,12,-,0,NONE,0,0,0,None,None +51,realTime,rf7,12,-,0,NONE,0,0,0,None,None +52,realTime,MuxTest,12,V,43,NONE,7,5,3,Sensor Power,Sensor Power Voltage at the ICR +53,realTime,LtVGACtl,12,V,42,NONE,1,4,3,VGA Control,Control Voltage to the Variable Gain Amplifier (VGA) +54,realTime,pad,4,-,34,NONE,0,0,0,None,Unused +55,realTime,IHUdiagData,32,-,18,NONE,3,2,0,Diagnostic Info,Diagnostic Data on IHU Performance +56,realTime,pad1,1,-,0,NONE,0,0,0,NONE,Filler +57,realTime,wodSize,8,000s,36,NONE,3,3,0,WOD Stored,Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds +58,realTime,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information +59,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset +60,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset 61,realTime,pad2,17,-,0,NONE,0,0,0,NONE,Filler + From f7ddcbdfd5f605465fc3a25edae02bf45da60ffe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:47:32 -0500 Subject: [PATCH 297/395] remove blank lines at end --- spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv | 4 ---- spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv | 2 -- 2 files changed, 6 deletions(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv index bedd627b..9fdaed04 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_PSK_rttelemetry.csv @@ -61,7 +61,3 @@ 59,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset 60,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset 61,realTime,pad2,17,-,0,NONE,0,0,0,NONE,Filler - - - - diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv index c3a5ba3b..59779cdf 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv @@ -47,5 +47,3 @@ 45,RT,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status 46,RT,GroundCommands2,10,-,1,Computer Software,3,3,0,Ground Commands,Number of ground commands received 47,RT,Pad,46,-,0,NONE,0,0,0,NONE,NONE - - From 79edb6ba30eef501b2ef4b5c63937a57798e68e2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:51:45 -0500 Subject: [PATCH 298/395] Update README.md --- spacecraft/FoxTelem_1.13i/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacecraft/FoxTelem_1.13i/README.md b/spacecraft/FoxTelem_1.13i/README.md index d085dedc..00626f45 100644 --- a/spacecraft/FoxTelem_1.13i/README.md +++ b/spacecraft/FoxTelem_1.13i/README.md @@ -1,6 +1,8 @@ These files update the spacecraft files in FoxTelem version 1.13i or later and fix a bug in the payload altitude sensor display. -You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23217474/foxtelem_spacecraft_files.zip) +You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23393161/foxtelem_spacecraft_files.zip) + +[foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23217474/foxtelem_spacecraft_files.zip) Extract (unzip foxtelem_spacecraft_files) and copy into FoxTelem spacecraft folder, replacing existing files. From a6676683ab09d19ad9314e2671cab085bc3a32db Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 07:56:26 -0500 Subject: [PATCH 299/395] Update README.md added other files --- spacecraft/FoxTelem_1.13i/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacecraft/FoxTelem_1.13i/README.md b/spacecraft/FoxTelem_1.13i/README.md index 00626f45..7d691ef3 100644 --- a/spacecraft/FoxTelem_1.13i/README.md +++ b/spacecraft/FoxTelem_1.13i/README.md @@ -1,6 +1,6 @@ These files update the spacecraft files in FoxTelem version 1.13i or later and fix a bug in the payload altitude sensor display. -You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23393161/foxtelem_spacecraft_files.zip) +You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23393272/foxtelem_spacecraft_files.zip) [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23217474/foxtelem_spacecraft_files.zip) From 2f33c8326baca43abc52aba4ca9aeab592a1daf5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 08:00:34 -0500 Subject: [PATCH 300/395] change module to NONE --- spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv index 59779cdf..967514bc 100644 --- a/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13i/CubeSatSim_rttelemetry.csv @@ -41,7 +41,7 @@ 39,RT,I2CBus1Failure,1,-,17,Computer Hardware,2,2,0,I2C Bus 1,I2C bus 1 failure indicator 40,RT,I2CBus3Failure,1,-,17,Computer Hardware,2,3,0,I2C Bus 3,I2C bus 3 failure indicator 41,RT,CameraFailure,1,-,17,Computer Hardware,2,4,0,Camera,Camera failure indicator -42,RT,GroundCommands,4,-,1,Computer Software,0,0,0,Ground Commands,Number of ground commands received +42,RT,GroundCommands,4,-,1,NONE,0,0,0,Ground Commands,Number of ground commands received 43,RT,RXAntenna,1,-,16,Radio,1,3,0,RX Antenna,Receive antenna status 44,RT,TXAntenna,1,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status 45,RT,C2CStatus,2,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status From 1fe3ced0c1c9b3478a01b6e72cfb03b531a3e20a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 08:03:40 -0500 Subject: [PATCH 301/395] Update README.md added all files --- spacecraft/FoxTelem_1.13i/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spacecraft/FoxTelem_1.13i/README.md b/spacecraft/FoxTelem_1.13i/README.md index 7d691ef3..b5431fe9 100644 --- a/spacecraft/FoxTelem_1.13i/README.md +++ b/spacecraft/FoxTelem_1.13i/README.md @@ -1,9 +1,9 @@ These files update the spacecraft files in FoxTelem version 1.13i or later and fix a bug in the payload altitude sensor display. -You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23393272/foxtelem_spacecraft_files.zip) +You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23393444/foxtelem_spacecraft_files.zip) [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23217474/foxtelem_spacecraft_files.zip) -Extract (unzip foxtelem_spacecraft_files) and copy into FoxTelem spacecraft folder, replacing existing files. +Extract (unzip foxtelem_spacecraft_files.zip) and copy into FoxTelem spacecraft folder, replacing existing files. Next time you run FoxTelem, the CubeSatSim-FSK and CubeSatSim-BPSK spacecraft will be automatically updated. From 86db53eb1357d8b5b6970fe68a72a8f7ea82b853 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 6 Nov 2025 08:07:59 -0500 Subject: [PATCH 302/395] Update README.md remove old zip file --- spacecraft/FoxTelem_1.13i/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/spacecraft/FoxTelem_1.13i/README.md b/spacecraft/FoxTelem_1.13i/README.md index b5431fe9..765fba49 100644 --- a/spacecraft/FoxTelem_1.13i/README.md +++ b/spacecraft/FoxTelem_1.13i/README.md @@ -2,8 +2,6 @@ These files update the spacecraft files in FoxTelem version 1.13i or later and f You can download them as a zip file: [foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23393444/foxtelem_spacecraft_files.zip) -[foxtelem_spacecraft_files.zip](https://github.com/user-attachments/files/23217474/foxtelem_spacecraft_files.zip) - Extract (unzip foxtelem_spacecraft_files.zip) and copy into FoxTelem spacecraft folder, replacing existing files. Next time you run FoxTelem, the CubeSatSim-FSK and CubeSatSim-BPSK spacecraft will be automatically updated. From 654bb84f92ec5fb7413c8ac4f2dcff3f0ecf237a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 20 Nov 2025 21:54:07 -0500 Subject: [PATCH 303/395] 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 304/395] 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 305/395] 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 306/395] 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 307/395] 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 308/395] 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 309/395] 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 From 39ebc247c921b6c1109e63802e5e69d77c98df12 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 13 Dec 2025 08:54:00 -0500 Subject: [PATCH 310/395] Update main.c fix get_tlm_fox {} --- main.c | 969 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 468 insertions(+), 501 deletions(-) diff --git a/main.c b/main.c index 107c1593..a97e7e33 100644 --- a/main.c +++ b/main.c @@ -1346,22 +1346,22 @@ void get_tlm(void) { // generates telemetry which is decoded by AMSAT's FoxTelem: https://www.amsat.org/foxtelem-software-for-windows-mac-linux/ // for more info about how we use FoxTelem see https://www.g0kla.com/foxtelem/amsat_telemetry_designers_handbook.pdf -void get_tlm_fox() { +void get_tlm_fox() { int i; long int sync = syncWord; int cam = ON; - smaller = (int) (S_RATE / (2 * freq_Hz)); + smaller = (int)(S_RATE / (2 * freq_Hz)); short int b[dataLen]; short int b_max[dataLen]; short int b_min[dataLen]; - + memset(b, 0, sizeof(b)); memset(b_max, 0, sizeof(b_max)); memset(b_min, 0, sizeof(b_min)); - + short int h[headerLen]; memset(h, 0, sizeof(h)); @@ -1382,176 +1382,163 @@ void get_tlm_fox() { short int buffer_test[bufLen]; int buffSize; - buffSize = (int) sizeof(buffer_test); - - if (failureMode == FAIL_NONE) - printf("No Simulated Failure!\n"); -// if (failureMode == -1) { -// failureMode = (int) rnd_float(1, FAIL_COUNT); -// printf("Random Failure\n"); -// } + buffSize = (int)sizeof(buffer_test); + + 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 == FAIL_UNPLUG) { - voltage[map[PLUS_Y]] = rnd_float(0.8, 0.95); - current[map[PLUS_Y]] = 0.0; - printf("+Y 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; - current[map[PLUS_X]] = 0.0; - printf("+X Solar Simulated Failure\n"); + voltage[map[PLUS_X]] = 0.0; + current[map[PLUS_X]] = 0.0; + printf("+X Solar Simulated Failure\n"); } if (failureMode == FAIL_DEGRADE) { - 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"); + 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) { - voltage[map[MINUS_Y]] = 0.0; - printf("-Y Solar SC Simulated Failure!\n"); + 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_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_PAYLOAD) { - payload = OFF; - printf("Payload Simulated Failure!\n"); + payload = OFF; + printf("Payload Simulated Failure!\n"); } if (failureMode == FAIL_CAMERA) { - cam = OFF; - printf("Camera Simulated Failure!\n"); + cam = OFF; + printf("Camera Simulated Failure!\n"); } if (mode == FSK) id = 7; else - id = 0; // 99 in h[6] - - // for (int frames = 0; frames < FRAME_CNT; frames++) + id = 0; // 99 in h[6] + + // for (int frames = 0; frames < FRAME_CNT; frames++) for (int frames = 0; frames < frameCnt; frames++) { - -// if (firstTime != ON) { - if (TRUE) { + // if (firstTime != ON) { + if (TRUE) { // delay for sample period -/**/ -// while ((millis() - sampleTime) < (unsigned int)samplePeriod) - int startSleep = millis(); - if ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100 500 for FSK -// sleep(2.0); // 0.5); // 25); // initial period - sleep(1.0); // 0.5); // 25); // initial period - while ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100 - sleep(0.1); // 25); // 0.5); // 25); -// sleep((unsigned int)sleepTime); -/**/ + /**/ + // while ((millis() - sampleTime) < (unsigned int)samplePeriod) + int startSleep = millis(); + if ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100 500 for FSK + // sleep(2.0); // 0.5); // 25); // initial period + sleep(1.0); // 0.5); // 25); // initial period + while ((millis() - sampleTime) < ((unsigned int)frameTime - 750 + pi_zero_2_offset)) // was 250 100 + sleep(0.1); // 25); // 0.5); // 25); + // sleep((unsigned int)sleepTime); + /**/ printf("Start sleep %d Sleep period: %d while period: %d\n", startSleep, millis() - startSleep, (unsigned int)frameTime - 750 + pi_zero_2_offset); fflush(stdout); - - sampleTime = (unsigned int) millis(); + + sampleTime = (unsigned int)millis(); } else printf("first or second time - no sleep\n"); - printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime)/1000.0); + printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime) / 1000.0); fflush(stdout); - loopTime = millis(); - -// if (mode == FSK) + loopTime = millis(); + + // if (mode == FSK) { // just moved for (int count1 = 0; count1 < 8; count1++) { - if (voltage[count1] < voltage_min[count1]) - voltage_min[count1] = voltage[count1]; - if (current[count1] < current_min[count1]) - current_min[count1] = current[count1]; - - if (voltage[count1] > voltage_max[count1]) - voltage_max[count1] = voltage[count1]; - if (current[count1] > current_max[count1]) - current_max[count1] = current[count1]; + if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1]; + if (current[count1] < current_min[count1]) current_min[count1] = current[count1]; + + if (voltage[count1] > voltage_max[count1]) voltage_max[count1] = voltage[count1]; + if (current[count1] > current_max[count1]) current_max[count1] = current[count1]; -// printf("Vmin %4.2f Vmax %4.2f Imin %4.2f Imax %4.2f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); + // printf("Vmin %4.2f Vmax %4.2f Imin %4.2f Imax %4.2f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); } - for (int count1 = 0; count1 < 3; count1++) { - if (other[count1] < other_min[count1]) - other_min[count1] = other[count1]; - if (other[count1] > other_max[count1]) - other_max[count1] = other[count1]; + for (int count1 = 0; count1 < 3; count1++) { + if (other[count1] < other_min[count1]) other_min[count1] = other[count1]; + if (other[count1] > other_max[count1]) other_max[count1] = other[count1]; // printf("Other min %f max %f \n", other_min[count1], other_max[count1]); } - if (mode == FSK) - { - if (loop % 32 == 0) { // was 8 -// printf("Sending MIN frame \n"); - frm_type = 0x03; - for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { - if (count1 < 3) - other[count1] = other_min[count1]; - if (count1 < 8) { - voltage[count1] = voltage_min[count1]; - current[count1] = current_min[count1]; - } - if (sensor_min[count1] != 1000.0) // make sure values are valid - sensor[count1] = sensor_min[count1]; - } - } - if ((loop + 16) % 32 == 0) { // was 8 -// printf("Sending MAX frame \n"); - frm_type = 0x02; - for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { - if (count1 < 3) - other[count1] = other_max[count1]; - if (count1 < 8) { - voltage[count1] = voltage_max[count1]; - current[count1] = current_max[count1]; - } - if (sensor_max[count1] != -1000.0) // make sure values are valid - sensor[count1] = sensor_max[count1]; - } - } - } - else - frm_type = 0x02; // BPSK always send MAX MIN frame - } + if (mode == FSK) { + if (loop % 32 == 0) { // was 8 + // printf("Sending MIN frame \n"); + frm_type = 0x03; + for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { + if (count1 < 3) other[count1] = other_min[count1]; + if (count1 < 8) { + voltage[count1] = voltage_min[count1]; + current[count1] = current_min[count1]; + } + if (sensor_min[count1] != 1000.0) // make sure values are valid + sensor[count1] = sensor_min[count1]; + } + } + if ((loop + 16) % 32 == 0) { // was 8 + // printf("Sending MAX frame \n"); + frm_type = 0x02; + for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) { + if (count1 < 3) other[count1] = other_max[count1]; + if (count1 < 8) { + voltage[count1] = voltage_max[count1]; + current[count1] = current_max[count1]; + } + if (sensor_max[count1] != -1000.0) // make sure values are valid + sensor[count1] = sensor_max[count1]; + } + } + } else + frm_type = 0x02; // BPSK always send MAX MIN frame + } sensor_payload[0] = 0; // clear for next payload - -// if (mode == FSK) { // remove this -// } + + // if (mode == FSK) { // remove this + // } memset(rs_frame, 0, sizeof(rs_frame)); memset(parities, 0, sizeof(parities)); - h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits - if (uptime != 0) // if uptime is 0, leave reset count at 0 + h[0] = (short int)((h[0] & 0xf8) | (id & 0x07)); // 3 bits + if (uptime != 0) // if uptime is 0, leave reset count at 0 { - h[0] = (short int) ((h[0] & 0x07) | ((reset_count & 0x1f) << 3)); - h[1] = (short int) ((reset_count >> 5) & 0xff); - h[2] = (short int) ((h[2] & 0xf8) | ((reset_count >> 13) & 0x07)); + h[0] = (short int)((h[0] & 0x07) | ((reset_count & 0x1f) << 3)); + h[1] = (short int)((reset_count >> 5) & 0xff); + h[2] = (short int)((h[2] & 0xf8) | ((reset_count >> 13) & 0x07)); } - h[2] = (short int) ((h[2] & 0x0e) | ((uptime & 0x1f) << 3)); - h[3] = (short int) ((uptime >> 5) & 0xff); - h[4] = (short int) ((uptime >> 13) & 0xff); - h[5] = (short int) ((h[5] & 0xf0) | ((uptime >> 21) & 0x0f)); - h[5] = (short int) ((h[5] & 0x0f) | (frm_type << 4)); + h[2] = (short int)((h[2] & 0x0e) | ((uptime & 0x1f) << 3)); + h[3] = (short int)((uptime >> 5) & 0xff); + h[4] = (short int)((uptime >> 13) & 0xff); + h[5] = (short int)((h[5] & 0xf0) | ((uptime >> 21) & 0x0f)); + h[5] = (short int)((h[5] & 0x0f) | (frm_type << 4)); - if (mode == BPSK) - h[6] = 99; + if (mode == BPSK) h[6] = 99; posXi = (int)(current[map[PLUS_X]] + 0.5) + 2048; posYi = (int)(current[map[PLUS_Y]] + 0.5) + 2048; @@ -1572,22 +1559,21 @@ void get_tlm_fox() { BAT2Voltage = (int)(voltage[map[BAT2]] * 100); BAT2Current = (int)(current[map[BAT2]] + 0.5) + 2048; - if (payload == ON) - STEMBoardFailure = 0; + if (payload == ON) STEMBoardFailure = 0; // read payload sensor if available -// encodeA(b, 0 + head_offset, batt_a_v); // replaced by XS2 and XS3 below -// encodeB(b, 1 + head_offset, batt_b_v); + // encodeA(b, 0 + head_offset, batt_a_v); // replaced by XS2 and XS3 below + // 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 + encodeB(b, 10 + head_offset, (int)(sensor[TEMP] * 10 + 0.5)); // Temp if (mode == FSK) { encodeA(b, 12 + head_offset, posXv); @@ -1603,7 +1589,7 @@ void get_tlm_fox() { encodeB(b, 25 + head_offset, negYi); encodeA(b, 27 + head_offset, posZi); encodeB(b, 28 + head_offset, negZi); - } else // BPSK + } else // BPSK { encodeA(b, 12 + head_offset, posXv); encodeB(b, 13 + head_offset, posYv); @@ -1618,7 +1604,7 @@ void get_tlm_fox() { encodeB(b, 25 + head_offset, negXi); encodeA(b, 27 + head_offset, negYi); encodeB(b, 28 + head_offset, negZi); - + encodeA(b_max, 12 + head_offset, (int)(voltage_max[map[PLUS_X]] * 100)); encodeB(b_max, 13 + head_offset, (int)(voltage_max[map[PLUS_Y]] * 100)); encodeA(b_max, 15 + head_offset, (int)(voltage_max[map[PLUS_Z]] * 100)); @@ -1631,51 +1617,49 @@ void get_tlm_fox() { encodeA(b_max, 24 + head_offset, (int)(current_max[map[PLUS_Z]] + 0.5) + 2048); encodeB(b_max, 25 + head_offset, (int)(current_max[map[MINUS_X]] + 0.5) + 2048); encodeA(b_max, 27 + head_offset, (int)(current_max[map[MINUS_Y]] + 0.5) + 2048); - encodeB(b_max, 28 + head_offset, (int)(current_max[map[MINUS_Z]] + 0.5) + 2048); + encodeB(b_max, 28 + head_offset, (int)(current_max[map[MINUS_Z]] + 0.5) + 2048); encodeA(b_max, 9 + head_offset, (int)(current_max[map[BAT]] + 0.5) + 2048); encodeA(b_max, 3 + head_offset, (int)(voltage_max[map[BAT]] * 100)); encodeA(b_max, 30 + head_offset, (int)(voltage_max[map[BAT2]] * 100)); encodeB(b_max, 46 + head_offset, (int)(current_max[map[BAT2]] + 0.5) + 2048); - - encodeB(b_max, 37 + head_offset, (int)(other_max[RSSI] + 0.5) + 2048); + + encodeB(b_max, 37 + head_offset, (int)(other_max[RSSI] + 0.5) + 2048); 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 (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); + } 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)); @@ -1688,149 +1672,143 @@ void get_tlm_fox() { encodeA(b_min, 24 + head_offset, (int)(current_min[map[PLUS_Z]] + 0.5) + 2048); encodeB(b_min, 25 + head_offset, (int)(current_min[map[MINUS_X]] + 0.5) + 2048); encodeA(b_min, 27 + head_offset, (int)(current_min[map[MINUS_Y]] + 0.5) + 2048); - encodeB(b_min, 28 + head_offset, (int)(current_min[map[MINUS_Z]] + 0.5) + 2048); - + encodeB(b_min, 28 + head_offset, (int)(current_min[map[MINUS_Z]] + 0.5) + 2048); + encodeA(b_min, 9 + head_offset, (int)(current_min[map[BAT]] + 0.5) + 2048); encodeA(b_min, 3 + head_offset, (int)(voltage_min[map[BAT]] * 100)); encodeA(b_min, 30 + head_offset, (int)(voltage_min[map[BAT2]] * 100)); encodeB(b_min, 46 + head_offset, (int)(current_min[map[BAT2]] + 0.5) + 2048); - + 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); + 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); - } - } - encodeA(b, 30 + head_offset, BAT2Voltage); - encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); + 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 - encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure - encodeB(b, 34 + head_offset, (int)(sensor[ALT] / 10.0 + 0.5)); // Altitude + encodeB(b_min, 40 + head_offset, 2048); + encodeA(b_min, 42 + head_offset, 2048); + encodeB(b_min, 43 + head_offset, 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_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 + + 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 - 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); - - - 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, 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])); + 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); + + 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, 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])); 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"); - if (command_count_file != NULL) { - char count_string[10]; - if ( (fgets(count_string, 10, command_count_file)) != NULL) - groundCommandCount = atoi(count_string); -// fclose(command_count_file); - } else - printf("Error opening command_count.txt!\n"); + + // encodeB(b, 49 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048); + + FILE* command_count_file = fopen("/home/pi/CubeSatSim/command_count.txt", "r"); + if (command_count_file != NULL) { + char count_string[10]; + if ((fgets(count_string, 10, command_count_file)) != NULL) groundCommandCount = atoi(count_string); + // fclose(command_count_file); + } else + printf("Error opening command_count.txt!\n"); fclose(command_count_file); - -// printf("Command count: %d\n", groundCommandCount); - int simulated; - simulated = sim_mode; - if (failureMode != FAIL_NONE) { - simulated = TRUE; - printf("Showing Simulated 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 = OFF; -// printf("I2C Bus 1 Simulated Failure\n"); - } else if (failureMode == FAIL_I2C3) { - 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; - int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + - (i2c_bus0 == OFF) * 16 + (i2c_1 == OFF) * 32 + (i2c_3 == OFF) * 64 + (cam == OFF) * 128 + groundCommandCount * 256; + + // printf("Command count: %d\n", groundCommandCount); + int simulated; + simulated = sim_mode; + if (failureMode != FAIL_NONE) { + simulated = TRUE; + printf("Showing Simulated 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 = OFF; + // printf("I2C Bus 1 Simulated Failure\n"); + } else if (failureMode == FAIL_I2C3) { + 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; + int status = STEMBoardFailure + SafeMode * 2 + simulated * 4 + PayloadFailure1 * 8 + (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); encodeA(b, 53 + head_offset, groundCommandCount); - - if (mode == BPSK) { + + if (mode == BPSK) { encodeA(b_max, 51 + head_offset, status); encodeA(b_min, 51 + head_offset, status); encodeB(b_max, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); encodeB(b_min, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); } - + if (txAntennaDeployed == 0) { txAntennaDeployed = 1; printf("TX Antenna Deployed!\n"); @@ -1838,16 +1816,16 @@ void get_tlm_fox() { if (rxAntennaDeployed == 0) { rxAntennaDeployed = 1; printf("RX Antenna Deployed!\n"); - } - + } + if (mode == BPSK) { // wod field experiments unsigned long val = 0xffff; - encodeA(b, 64 + head_offset, 0xff & val); - encodeA(b, 65 + head_offset, val >> 8); - encodeA(b, 63 + head_offset, 0x00); + encodeA(b, 64 + head_offset, 0xff & val); + encodeA(b, 65 + head_offset, val >> 8); + encodeA(b, 63 + head_offset, 0x00); encodeA(b, 62 + head_offset, 0x01); - encodeB(b, 74 + head_offset, 0xfff); - } + encodeB(b, 74 + head_offset, 0xfff); + } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; @@ -1855,7 +1833,7 @@ void get_tlm_fox() { int ctr3 = 0; for (i = 0; i < rsFrameLen; i++) { for (int j = 0; j < rsFrames; j++) { - if (!((i == (rsFrameLen - 1)) && (j == 2))) // skip last one for BPSK + if (!((i == (rsFrameLen - 1)) && (j == 2))) // skip last one for BPSK { if (ctr1 < headerLen) { rs_frame[j][i] = h[ctr1]; @@ -1864,30 +1842,23 @@ void get_tlm_fox() { data8[ctr1++] = rs_frame[j][i]; // printf ("data8[%d] = %x \n", ctr1 - 1, rs_frame[j][i]); } else { - if (mode == FSK) - { - rs_frame[j][i] = b[ctr3 % dataLen]; - update_rs(parities[j], b[ctr3 % dataLen]); - } else // BPSK - if ((int)(ctr3/dataLen) == 3) - { - rs_frame[j][i] = b_max[ctr3 % dataLen]; - update_rs(parities[j], b_max[ctr3 % dataLen]); - } - else if ((int)(ctr3/dataLen) == 4) - { - rs_frame[j][i] = b_min[ctr3 % dataLen]; - update_rs(parities[j], b_min[ctr3 % dataLen]); - } - else - { - rs_frame[j][i] = b[ctr3 % dataLen]; - update_rs(parities[j], b[ctr3 % dataLen]); - } - { - } - - // printf("%d rs_frame[%d][%d] = %x %d \n", + if (mode == FSK) { + rs_frame[j][i] = b[ctr3 % dataLen]; + update_rs(parities[j], b[ctr3 % dataLen]); + } else // BPSK + if ((int)(ctr3 / dataLen) == 3) { + rs_frame[j][i] = b_max[ctr3 % dataLen]; + update_rs(parities[j], b_max[ctr3 % dataLen]); + } else if ((int)(ctr3 / dataLen) == 4) { + rs_frame[j][i] = b_min[ctr3 % dataLen]; + update_rs(parities[j], b_min[ctr3 % dataLen]); + } else { + rs_frame[j][i] = b[ctr3 % dataLen]; + update_rs(parities[j], b[ctr3 % dataLen]); + } + {} + + // printf("%d rs_frame[%d][%d] = %x %d \n", // ctr1, j, i, b[ctr3 % DATA_LEN], ctr3 % DATA_LEN); data8[ctr1++] = rs_frame[j][i]; // printf ("data8[%d] = %x \n", ctr1 - 1, rs_frame[j][i]); @@ -1897,54 +1868,54 @@ void get_tlm_fox() { } } - #ifdef DEBUG_LOGGING - // printf("\nAt end of data8 write, %d ctr1 values written\n\n", ctr1); - /* - printf("Parities "); - for (int m = 0; m < parityLen; m++) { - printf("%d ", parities[0][m]); - } - printf("\n"); - */ - #endif - +#ifdef DEBUG_LOGGING +// printf("\nAt end of data8 write, %d ctr1 values written\n\n", ctr1); +/* + printf("Parities "); + for (int m = 0; m < parityLen; m++) { + printf("%d ", parities[0][m]); + } + printf("\n"); +*/ +#endif + int ctr2 = 0; memset(data10, 0, sizeof(data10)); - for (i = 0; i < dataLen * payloads + headerLen; i++) // 476 for BPSK + for (i = 0; i < dataLen * payloads + headerLen; i++) // 476 for BPSK { - data10[ctr2] = (Encode_8b10b[rd][((int) data8[ctr2])] & 0x3ff); - nrd = (Encode_8b10b[rd][((int) data8[ctr2])] >> 10) & 1; + data10[ctr2] = (Encode_8b10b[rd][((int)data8[ctr2])] & 0x3ff); + nrd = (Encode_8b10b[rd][((int)data8[ctr2])] >> 10) & 1; // printf ("data10[%d] = encoded data8[%d] = %x \n", - // ctr2, ctr2, data10[ctr2]); + // ctr2, ctr2, data10[ctr2]); - rd = nrd; // ^ nrd; + rd = nrd; // ^ nrd; ctr2++; } -// { - for (i = 0; i < parityLen; i++) { - for (int j = 0; j < rsFrames; j++) { - if ((uptime != 0) || (i != 0)) // don't correctly update parties if uptime is 0 so the frame will fail the FEC check and be discarded - data10[ctr2++] = (Encode_8b10b[rd][((int) parities[j][i])] & 0x3ff); - nrd = (Encode_8b10b[rd][((int) parities[j][i])] >> 10) & 1; + // { + for (i = 0; i < parityLen; i++) { + for (int j = 0; j < rsFrames; j++) { + if ((uptime != 0) || (i != 0)) // don't correctly update parties if uptime is 0 so the frame will fail the FEC check and be discarded + data10[ctr2++] = (Encode_8b10b[rd][((int)parities[j][i])] & 0x3ff); + nrd = (Encode_8b10b[rd][((int)parities[j][i])] >> 10) & 1; // printf ("data10[%d] = encoded parities[%d][%d] = %x \n", - // ctr2 - 1, j, i, data10[ctr2 - 1]); + // ctr2 - 1, j, i, data10[ctr2 - 1]); - rd = nrd; - } + rd = nrd; } - // } - #ifdef DEBUG_LOGGING - // printf("\nAt end of data10 write, %d ctr2 values written\n\n", ctr2); - #endif + } + // } +#ifdef DEBUG_LOGGING +// printf("\nAt end of data10 write, %d ctr2 values written\n\n", ctr2); +#endif int data; int val; - //int offset = 0; + // int offset = 0; - #ifdef DEBUG_LOGGING - // printf("\nAt start of buffer loop, syncBits %d samples %d ctr %d\n", syncBits, samples, ctr); - #endif +#ifdef DEBUG_LOGGING +// printf("\nAt start of buffer loop, syncBits %d samples %d ctr %d\n", syncBits, samples, ctr); +#endif for (i = 1; i <= syncBits * samples; i++) { write_wave(ctr, buffer); @@ -1962,18 +1933,17 @@ void get_tlm_fox() { if (data == 0) { phase *= -1; if ((ctr - smaller) > 0) { - for (int j = 1; j <= smaller; j++) - buffer[ctr - j] = buffer[ctr - j] * 0.4; + for (int j = 1; j <= smaller; j++) buffer[ctr - j] = buffer[ctr - j] * 0.4; } flip_ctr = ctr; } } } } - #ifdef DEBUG_LOGGING - // printf("\n\nValue of ctr after header: %d Buffer Len: %d\n\n", ctr, buffSize); - #endif - for (i = 1; i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572 +#ifdef DEBUG_LOGGING +// printf("\n\nValue of ctr after header: %d Buffer Len: %d\n\n", ctr, buffSize); +#endif + for (i = 1; i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572 { write_wave(ctr, buffer); if ((i % samples) == 0) { @@ -1990,8 +1960,7 @@ void get_tlm_fox() { if (data == 0) { phase *= -1; if ((ctr - smaller) > 0) { - for (int j = 1; j <= smaller; j++) - buffer[ctr - j] = buffer[ctr - j] * 0.4; + for (int j = 1; j <= smaller; j++) buffer[ctr - j] = buffer[ctr - j] * 0.4; } flip_ctr = ctr; } @@ -1999,55 +1968,29 @@ void get_tlm_fox() { } } } - #ifdef DEBUG_LOGGING - // printf("\nValue of ctr after looping: %d Buffer Len: %d\n", ctr, buffSize); - // printf("\ctr/samples = %d ctr/(samples*10) = %d\n\n", ctr/samples, ctr/(samples*10)); - #endif +#ifdef DEBUG_LOGGING +// printf("\nValue of ctr after looping: %d Buffer Len: %d\n", ctr, buffSize); +// printf("\ctr/samples = %d ctr/(samples*10) = %d\n\n", ctr/samples, ctr/(samples*10)); +#endif - //int error = 0; - // int count; - // for (count = 0; count < dataLen; count++) { - // printf("%02X", b[count]); - // } - // printf("\n"); + // int error = 0; + // int count; + // for (count = 0; count < dataLen; count++) { + // printf("%02X", b[count]); + // } + // printf("\n"); // socket write socket_send(ctr); -/* - if (!socket_open && transmit) { - printf("Opening socket!\n"); - // struct sockaddr_in address; - // int valread; - struct sockaddr_in serv_addr; - // char *hello = "Hello from client"; - // char buffer[1024] = {0}; - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("\n Socket creation error \n"); - error = 1; - } - - memset( & serv_addr, '0', sizeof(serv_addr)); - - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons(PORT); - - // Convert IPv4 and IPv6 addresses from text to binary form - if (inet_pton(AF_INET, "127.0.0.1", & serv_addr.sin_addr) <= 0) { - printf("\nInvalid address/ Address not supported \n"); - error = 1; - } - - if (connect(sock, (struct sockaddr * ) & serv_addr, sizeof(serv_addr)) < 0) { - printf("\nConnection Failed \n"); - printf("Error: %s\n", strerror(errno)); - error = 1; -// FILE * transmit_restartf2 = popen("sudo systemctl restart transmit", "r"); -// pclose(transmit_restartf2); -// sleep(10); // was 5 // sleep if socket connection refused - - // try again - error = 0; + /* + if (!socket_open && transmit) { + printf("Opening socket!\n"); + // struct sockaddr_in address; + // int valread; + struct sockaddr_in serv_addr; + // char *hello = "Hello from client"; + // char buffer[1024] = {0}; if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("\n Socket creation error \n"); error = 1; @@ -2058,7 +2001,7 @@ void get_tlm_fox() { serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(PORT); - // Convert IPv4 and IPv6 addresses from text to binary form + // Convert IPv4 and IPv6 addresses from text to binary form if (inet_pton(AF_INET, "127.0.0.1", & serv_addr.sin_addr) <= 0) { printf("\nInvalid address/ Address not supported \n"); error = 1; @@ -2068,100 +2011,124 @@ void get_tlm_fox() { printf("\nConnection Failed \n"); printf("Error: %s\n", strerror(errno)); error = 1; -// FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r"); -// pclose(transmit_restartf); -// sleep(10); // was 5 // sleep if socket connection refused - } - } - if (error == 1) { - printf("Socket error count: %d\n", error_count); -// ; //transmitStatus = -1; - if (error_count++ > 5) { - printf("Restarting transmit\n"); - FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r"); - pclose(transmit_restartf); - sleep(10); // was 5 // sleep if socket connection refused - } - } - else { - socket_open = 1; - error_count = 0; - } - } + // FILE * transmit_restartf2 = popen("sudo systemctl restart transmit", "r"); + // pclose(transmit_restartf2); + // sleep(10); // was 5 // sleep if socket connection refused + + // try again + error = 0; + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + printf("\n Socket creation error \n"); + error = 1; + } - if (!error && transmit) { - // digitalWrite (0, LOW); - // printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, (long unsigned int)millis() - start); - start = millis(); - int sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); -// printf("socket send 1 %d ms bytes: %d \n\n", (unsigned int)millis() - start, sock_ret); - fflush(stdout); - - if (sock_ret < (ctr * 2 + 2)) { - // printf("Not resending\n"); - sleep(0.5); - sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); -// printf("socket send 2 %d ms bytes: %d \n\n", millis() - start, sock_ret); + memset( & serv_addr, '0', sizeof(serv_addr)); + + serv_addr.sin_family = AF_INET; + serv_addr.sin_port = htons(PORT); + + // Convert IPv4 and IPv6 addresses from text to binary form + if (inet_pton(AF_INET, "127.0.0.1", & serv_addr.sin_addr) <= 0) { + printf("\nInvalid address/ Address not supported \n"); + error = 1; + } + + if (connect(sock, (struct sockaddr * ) & serv_addr, sizeof(serv_addr)) < 0) { + printf("\nConnection Failed \n"); + printf("Error: %s\n", strerror(errno)); + error = 1; + // FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r"); + // pclose(transmit_restartf); + // sleep(10); // was 5 // sleep if socket connection refused + } + } + if (error == 1) { + printf("Socket error count: %d\n", error_count); + // ; //transmitStatus = -1; + if (error_count++ > 5) { + printf("Restarting transmit\n"); + FILE * transmit_restartf = popen("sudo systemctl restart transmit", "r"); + pclose(transmit_restartf); + sleep(10); // was 5 // sleep if socket connection refused + } + } + else { + socket_open = 1; + error_count = 0; + } } -*/ - - loop_count++; - if ((firstTime == 1) || (((loop_count % 180) == 0) && (mode == FSK)) || (((loop_count % 80) == 0) && (mode == BPSK))) // do first time and was every 180 samples - { - int max; - if (mode == FSK) - if (sim_mode) - max = 6; - else if (firstTime == 1) - max = 4; // 5; // was 6 - else - max = 3; - else - if (firstTime == 1) - max = 5; // 5; // was 6 - else - max = 4; - - for (int times = 0; times < max; times++) - { -/// start = millis(); // send frame until buffer fills - socket_send(ctr); -/// sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); -// printf("socket send %d in %d ms bytes: %d \n\n",times + 2, (unsigned int)millis() - start, sock_ret); - -/// if ((millis() - start) > 500) { -/// printf("Buffer over filled!\n"); -/// break; -/// } - -/// if (sock_ret < (ctr * 2 + 2)) { - // printf("Not resending\n"); -/// sleep(0.5); -/// sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); -/// printf("socket resend %d in %d ms bytes: %d \n\n",times, millis() - start, sock_ret); -/// } + + if (!error && transmit) { + // digitalWrite (0, LOW); + // printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, (long unsigned int)millis() - start); + start = millis(); + int sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); + // printf("socket send 1 %d ms bytes: %d \n\n", (unsigned int)millis() - start, sock_ret); + fflush(stdout); + + if (sock_ret < (ctr * 2 + 2)) { + // printf("Not resending\n"); + sleep(0.5); + sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); + // printf("socket send 2 %d ms bytes: %d \n\n", millis() - start, sock_ret); } - sampleTime = (unsigned int) millis(); // resetting time for sleeping - // fflush(stdout); -// if (firstTime == 1) -// max -= 1; + */ + + loop_count++; + if ((firstTime == 1) || (((loop_count % 180) == 0) && (mode == FSK)) || (((loop_count % 80) == 0) && (mode == BPSK))) // do first time and was every 180 samples + { + int max; + if (mode == FSK) + if (sim_mode) + max = 6; + else if (firstTime == 1) + max = 4; // 5; // was 6 + else + max = 3; + else if (firstTime == 1) + max = 5; // 5; // was 6 + else + max = 4; + + for (int times = 0; times < max; times++) { + /// start = millis(); // send frame until buffer fills + socket_send(ctr); + /// sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); + // printf("socket send %d in %d ms bytes: %d \n\n",times + 2, (unsigned int)millis() - start, sock_ret); + + /// if ((millis() - start) > 500) { + /// printf("Buffer over filled!\n"); + /// break; + /// } + + /// if (sock_ret < (ctr * 2 + 2)) { + // printf("Not resending\n"); + /// sleep(0.5); + /// sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); + /// printf("socket resend %d in %d ms bytes: %d \n\n",times, millis() - start, sock_ret); + /// } } + sampleTime = (unsigned int)millis(); // resetting time for sleeping + // fflush(stdout); + // if (firstTime == 1) + // max -= 1; + } -/// if (sock_ret == -1) { -/// printf("Error: %s \n", strerror(errno)); -/// socket_open = 0; - //transmitStatus = -1; -/// } -/// } + /// if (sock_ret == -1) { + /// printf("Error: %s \n", strerror(errno)); + /// socket_open = 0; + // transmitStatus = -1; + /// } + /// } if (!transmit) { fprintf(stderr, "\nNo CubeSatSim Band Pass Filter detected. No transmissions after the CW ID.\n"); fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n"); } -/// if (socket_open == 1) -/// firstTime = 0; -// else if (frames_sent > 0) //5) -// firstTime = 0; + /// if (socket_open == 1) + /// firstTime = 0; + // else if (frames_sent > 0) //5) + // firstTime = 0; return; } From 0d500ede48e835a03e7b0ed402e4a32dadec1eed Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 05:04:52 -0500 Subject: [PATCH 311/395] Create gps_client.py --- gps_client.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 gps_client.py diff --git a/gps_client.py b/gps_client.py new file mode 100644 index 00000000..a4a7dea6 --- /dev/null +++ b/gps_client.py @@ -0,0 +1,41 @@ +#! /usr/bin/env python3 +""" +example Python gpsd client +run this way: python3 example1.py.txt +""" + +# from https://gpsd.gitlab.io/gpsd/gpsd-client-example-code.html + +import gps # the gpsd interface module + +session = gps.gps(mode=gps.WATCH_ENABLE) + +try: + while 0 == session.read(): + if not (gps.MODE_SET & session.valid): + # not useful, probably not a TPV message + continue + + print('Mode: %s(%d) Time: ' % + (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], + session.fix.mode), end="") + # print time, if we have it + if gps.TIME_SET & session.valid: + print(session.fix.time, end="") + else: + print('n/a', end="") + + if ((gps.isfinite(session.fix.latitude) and + gps.isfinite(session.fix.longitude))): + print(" Lat %.6f Lon %.6f" % + (session.fix.latitude, session.fix.longitude)) + else: + print(" Lat n/a Lon n/a") + +except KeyboardInterrupt: + # got a ^C. Say bye, bye + print('') + +# Got ^C, or fell out of the loop. Cleanup, and leave. +session.close() +exit(0) From b6930b424bf7141225efe8d085519e9d59b4bade Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 05:11:35 -0500 Subject: [PATCH 312/395] Update gps_client.py just print mode lat lon --- gps_client.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/gps_client.py b/gps_client.py index a4a7dea6..5213f3e7 100644 --- a/gps_client.py +++ b/gps_client.py @@ -6,6 +6,8 @@ run this way: python3 example1.py.txt # from https://gpsd.gitlab.io/gpsd/gpsd-client-example-code.html +# this client is for the CubeSatSim Lite which does not have a Pico microcontroller + import gps # the gpsd interface module session = gps.gps(mode=gps.WATCH_ENABLE) @@ -16,21 +18,22 @@ try: # not useful, probably not a TPV message continue - print('Mode: %s(%d) Time: ' % - (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], - session.fix.mode), end="") +# print('Mode: %s(%d) Time: ' % +# (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], +# session.fix.mode), end="") # print time, if we have it - if gps.TIME_SET & session.valid: - print(session.fix.time, end="") - else: - print('n/a', end="") + print("%d ", session.fix.mode) +# if gps.TIME_SET & session.valid: +# print(session.fix.time, end="") +# else: +# print('n/a', end="") if ((gps.isfinite(session.fix.latitude) and gps.isfinite(session.fix.longitude))): - print(" Lat %.6f Lon %.6f" % + print(" %.6f %.6f" % (session.fix.latitude, session.fix.longitude)) else: - print(" Lat n/a Lon n/a") + print(" 0 0") except KeyboardInterrupt: # got a ^C. Say bye, bye From 8bb167acd1f05def9944ee972be7037625092ff0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 05:13:33 -0500 Subject: [PATCH 313/395] Update gps_client.py fix mode print --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 5213f3e7..038347b5 100644 --- a/gps_client.py +++ b/gps_client.py @@ -22,7 +22,7 @@ try: # (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], # session.fix.mode), end="") # print time, if we have it - print("%d ", session.fix.mode) + print("%d " % session.fix.mode, end="") # if gps.TIME_SET & session.valid: # print(session.fix.time, end="") # else: From 12494ebb9fb18bd28902705f1c092736ce15d580 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:06:59 -0500 Subject: [PATCH 314/395] Update gps_client.py print values --- gps_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 038347b5..c5c93e9c 100644 --- a/gps_client.py +++ b/gps_client.py @@ -14,6 +14,8 @@ session = gps.gps(mode=gps.WATCH_ENABLE) try: while 0 == session.read(): + print(gps.MODE_SET) + print(session.valid) if not (gps.MODE_SET & session.valid): # not useful, probably not a TPV message continue @@ -30,7 +32,7 @@ try: if ((gps.isfinite(session.fix.latitude) and gps.isfinite(session.fix.longitude))): - print(" %.6f %.6f" % + print("%.6f %.6f" % (session.fix.latitude, session.fix.longitude)) else: print(" 0 0") From 6d764c1c5222cc2affef641f68f3a9a4b174d9dd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:21:37 -0500 Subject: [PATCH 315/395] Update gps_client.py add 1 second timeout --- gps_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index c5c93e9c..09afac43 100644 --- a/gps_client.py +++ b/gps_client.py @@ -9,11 +9,14 @@ run this way: python3 example1.py.txt # this client is for the CubeSatSim Lite which does not have a Pico microcontroller import gps # the gpsd interface module +import time session = gps.gps(mode=gps.WATCH_ENABLE) +start = time.perf_timer() + try: - while 0 == session.read(): + while session.read() == 0 and ((time.perf_timer(0 - start) < 1): print(gps.MODE_SET) print(session.valid) if not (gps.MODE_SET & session.valid): From 08454a385d944b917635ec53565e31fa0fd7d1c3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:23:16 -0500 Subject: [PATCH 316/395] Update gps_client.py typo --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 09afac43..49d8e08c 100644 --- a/gps_client.py +++ b/gps_client.py @@ -16,7 +16,7 @@ session = gps.gps(mode=gps.WATCH_ENABLE) start = time.perf_timer() try: - while session.read() == 0 and ((time.perf_timer(0 - start) < 1): + while session.read() == 0 and ((time.perf_timer(0 - start)) < 1): print(gps.MODE_SET) print(session.valid) if not (gps.MODE_SET & session.valid): From 75762f120ae323f5514ac5aa5d999769001f161f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:24:26 -0500 Subject: [PATCH 317/395] Update gps_client.py counter --- gps_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gps_client.py b/gps_client.py index 49d8e08c..e5074232 100644 --- a/gps_client.py +++ b/gps_client.py @@ -13,10 +13,10 @@ import time session = gps.gps(mode=gps.WATCH_ENABLE) -start = time.perf_timer() +start = time.perf_counter() try: - while session.read() == 0 and ((time.perf_timer(0 - start)) < 1): + while session.read() == 0 and ((time.perf_counter(0 - start)) < 1): print(gps.MODE_SET) print(session.valid) if not (gps.MODE_SET & session.valid): From e4fa0f7082fbf1e090356b34cc65809f836e605f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:25:05 -0500 Subject: [PATCH 318/395] Update gps_client.py --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index e5074232..b9ba38d9 100644 --- a/gps_client.py +++ b/gps_client.py @@ -16,7 +16,7 @@ session = gps.gps(mode=gps.WATCH_ENABLE) start = time.perf_counter() try: - while session.read() == 0 and ((time.perf_counter(0 - start)) < 1): + while session.read() == 0 and ((time.perf_counter() - start) < 1): print(gps.MODE_SET) print(session.valid) if not (gps.MODE_SET & session.valid): From a64604e76e3497511eda47b474b5b84fb8cfb067 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:33:35 -0500 Subject: [PATCH 319/395] Update gps_client.py add alt --- gps_client.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/gps_client.py b/gps_client.py index b9ba38d9..eaefe39c 100644 --- a/gps_client.py +++ b/gps_client.py @@ -15,10 +15,18 @@ session = gps.gps(mode=gps.WATCH_ENABLE) start = time.perf_counter() +mode = -1 + +lat = 0 + +lon = 0 + +alt = 0 + try: - while session.read() == 0 and ((time.perf_counter() - start) < 1): - print(gps.MODE_SET) - print(session.valid) + while (session.read() == 0) and ((time.perf_counter() - start) < 1.5) and (mode < 3): +# print(gps.MODE_SET) + # print(session.valid) if not (gps.MODE_SET & session.valid): # not useful, probably not a TPV message continue @@ -28,6 +36,8 @@ try: # session.fix.mode), end="") # print time, if we have it print("%d " % session.fix.mode, end="") + if (session.fix.mode > mode): + mode = session.fix.mode # if gps.TIME_SET & session.valid: # print(session.fix.time, end="") # else: @@ -37,8 +47,11 @@ try: gps.isfinite(session.fix.longitude))): print("%.6f %.6f" % (session.fix.latitude, session.fix.longitude)) + lat = session.fix.latitude + lon = session.fix.longitude + alt = session.fix.altitude else: - print(" 0 0") + print(" 0 0 0") except KeyboardInterrupt: # got a ^C. Say bye, bye @@ -46,4 +59,5 @@ except KeyboardInterrupt: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() +print("%.6f %.6f %.1" % lat lon alt) exit(0) From 7d46d0f74d457b168c9b04fb0afce9dff98854c0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:34:25 -0500 Subject: [PATCH 320/395] Update gps_client.py fix prints --- gps_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gps_client.py b/gps_client.py index eaefe39c..ba2bdafd 100644 --- a/gps_client.py +++ b/gps_client.py @@ -45,8 +45,8 @@ try: if ((gps.isfinite(session.fix.latitude) and gps.isfinite(session.fix.longitude))): - print("%.6f %.6f" % - (session.fix.latitude, session.fix.longitude)) + print("%.6f %.6f %.6f" % + (session.fix.latitude, session.fix.longitude), session.fix.altitude) lat = session.fix.latitude lon = session.fix.longitude alt = session.fix.altitude @@ -59,5 +59,5 @@ except KeyboardInterrupt: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() -print("%.6f %.6f %.1" % lat lon alt) +print("%.6f %.6f %.1" % lat, lon, alt) exit(0) From ac265777711a45d4ae66e0367af3af0f591a2827 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:34:56 -0500 Subject: [PATCH 321/395] Update gps_client.py fix print --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index ba2bdafd..e58b02dc 100644 --- a/gps_client.py +++ b/gps_client.py @@ -59,5 +59,5 @@ except KeyboardInterrupt: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() -print("%.6f %.6f %.1" % lat, lon, alt) +print("%.6f %.6f %.1f" % lat, lon, alt) exit(0) From dd0b73c2cbe0742e3539360daa7300b074fef821 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:36:34 -0500 Subject: [PATCH 322/395] Update gps_client.py fix prints --- gps_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gps_client.py b/gps_client.py index e58b02dc..a417cdce 100644 --- a/gps_client.py +++ b/gps_client.py @@ -46,7 +46,7 @@ try: if ((gps.isfinite(session.fix.latitude) and gps.isfinite(session.fix.longitude))): print("%.6f %.6f %.6f" % - (session.fix.latitude, session.fix.longitude), session.fix.altitude) + (session.fix.latitude, session.fix.longitude, session.fix.altitude)) lat = session.fix.latitude lon = session.fix.longitude alt = session.fix.altitude @@ -59,5 +59,5 @@ except KeyboardInterrupt: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() -print("%.6f %.6f %.1f" % lat, lon, alt) +print("%.6f %.6f %.1f" % (lat, lon, alt)) exit(0) From 78996ea0156f4e77478dd5ebd9635065ebc92841 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:39:49 -0500 Subject: [PATCH 323/395] Update gps_client.py add mode --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index a417cdce..01f4820f 100644 --- a/gps_client.py +++ b/gps_client.py @@ -59,5 +59,5 @@ except KeyboardInterrupt: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() -print("%.6f %.6f %.1f" % (lat, lon, alt)) +print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) exit(0) From 921737ff6ee5577919458d4dd6d011cc68d18988 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:41:09 -0500 Subject: [PATCH 324/395] Update gps_client.py 2 seconds --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 01f4820f..502ee125 100644 --- a/gps_client.py +++ b/gps_client.py @@ -24,7 +24,7 @@ lon = 0 alt = 0 try: - while (session.read() == 0) and ((time.perf_counter() - start) < 1.5) and (mode < 3): + while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 3): # print(gps.MODE_SET) # print(session.valid) if not (gps.MODE_SET & session.valid): From 5797a0734a834cf530e1fe633aa6db7ee4b4b074 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:46:32 -0500 Subject: [PATCH 325/395] Update gps_client.py add if session valid --- gps_client.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/gps_client.py b/gps_client.py index 502ee125..0cef49dc 100644 --- a/gps_client.py +++ b/gps_client.py @@ -27,31 +27,31 @@ try: while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 3): # print(gps.MODE_SET) # print(session.valid) - if not (gps.MODE_SET & session.valid): + if (session.valid): # not useful, probably not a TPV message - continue +# continue # print('Mode: %s(%d) Time: ' % # (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], # session.fix.mode), end="") # print time, if we have it - print("%d " % session.fix.mode, end="") - if (session.fix.mode > mode): - mode = session.fix.mode -# if gps.TIME_SET & session.valid: -# print(session.fix.time, end="") -# else: -# print('n/a', end="") - - if ((gps.isfinite(session.fix.latitude) and - gps.isfinite(session.fix.longitude))): - print("%.6f %.6f %.6f" % - (session.fix.latitude, session.fix.longitude, session.fix.altitude)) - lat = session.fix.latitude - lon = session.fix.longitude - alt = session.fix.altitude - else: - print(" 0 0 0") + print("%d " % session.fix.mode, end="") + if (session.fix.mode > mode): + mode = session.fix.mode + # if gps.TIME_SET & session.valid: + # print(session.fix.time, end="") + # else: + # print('n/a', end="") + + if ((gps.isfinite(session.fix.latitude) and + gps.isfinite(session.fix.longitude))): + print("%.6f %.6f %.6f" % + (session.fix.latitude, session.fix.longitude, session.fix.altitude)) + lat = session.fix.latitude + lon = session.fix.longitude + alt = session.fix.altitude + else: + print(" 0 0 0") except KeyboardInterrupt: # got a ^C. Say bye, bye From 8cc8f6f0798aa0c2db949b3b4ce0b6d3d029e93e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:49:29 -0500 Subject: [PATCH 326/395] Update gps_client.py check for finite --- gps_client.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gps_client.py b/gps_client.py index 0cef49dc..910f00ef 100644 --- a/gps_client.py +++ b/gps_client.py @@ -42,16 +42,18 @@ try: # print(session.fix.time, end="") # else: # print('n/a', end="") - - if ((gps.isfinite(session.fix.latitude) and - gps.isfinite(session.fix.longitude))): - print("%.6f %.6f %.6f" % - (session.fix.latitude, session.fix.longitude, session.fix.altitude)) + + if ((gps.isfinite(session.fix.latitude) lat = session.fix.latitude + if gps.isfinite(session.fix.longitude) lon = session.fix.longitude + if gps.isfinite(session.fix.altitude): alt = session.fix.altitude - else: - print(" 0 0 0") + print("%.6f %.6f %.6f" % + (session.fix.latitude, session.fix.longitude, session.fix.altitude)) + +# else: +# print(" 0 0 0") except KeyboardInterrupt: # got a ^C. Say bye, bye From 53d8ecaa23915c2c705339456d6a26169fb5ee8c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:51:02 -0500 Subject: [PATCH 327/395] Update gps_client.py fix if --- gps_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gps_client.py b/gps_client.py index 910f00ef..1b1b9354 100644 --- a/gps_client.py +++ b/gps_client.py @@ -43,9 +43,9 @@ try: # else: # print('n/a', end="") - if ((gps.isfinite(session.fix.latitude) + if ((gps.isfinite(session.fix.latitude): lat = session.fix.latitude - if gps.isfinite(session.fix.longitude) + if gps.isfinite(session.fix.longitude): lon = session.fix.longitude if gps.isfinite(session.fix.altitude): alt = session.fix.altitude From ed570b8dc46ccc0cb0c8bd89220b3563fdde5100 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 07:51:47 -0500 Subject: [PATCH 328/395] Update gps_client.py fix () --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 1b1b9354..76b19395 100644 --- a/gps_client.py +++ b/gps_client.py @@ -43,7 +43,7 @@ try: # else: # print('n/a', end="") - if ((gps.isfinite(session.fix.latitude): + if gps.isfinite(session.fix.latitude): lat = session.fix.latitude if gps.isfinite(session.fix.longitude): lon = session.fix.longitude From cb80a03df371dde4947fa5ea1043f85c01f442ff Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:04:55 -0500 Subject: [PATCH 329/395] Update gps_client.py stop if mode 3 --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 76b19395..74826a60 100644 --- a/gps_client.py +++ b/gps_client.py @@ -24,7 +24,7 @@ lon = 0 alt = 0 try: - while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 3): + while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2): # print(gps.MODE_SET) # print(session.valid) if (session.valid): From 4454747453e9a550affc9a3f3b350409e258ba6c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:08:01 -0500 Subject: [PATCH 330/395] Update gps_client.py return -1 if no socket --- gps_client.py | 93 +++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/gps_client.py b/gps_client.py index 74826a60..1c4712fe 100644 --- a/gps_client.py +++ b/gps_client.py @@ -11,55 +11,54 @@ run this way: python3 example1.py.txt import gps # the gpsd interface module import time -session = gps.gps(mode=gps.WATCH_ENABLE) - -start = time.perf_counter() - -mode = -1 - -lat = 0 - -lon = 0 - +mode = -1 +lat = 0 +lon = 0 alt = 0 try: - while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2): -# print(gps.MODE_SET) - # print(session.valid) - if (session.valid): - # not useful, probably not a TPV message -# continue - -# print('Mode: %s(%d) Time: ' % -# (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], -# session.fix.mode), end="") - # print time, if we have it - print("%d " % session.fix.mode, end="") - if (session.fix.mode > mode): - mode = session.fix.mode - # if gps.TIME_SET & session.valid: - # print(session.fix.time, end="") - # else: - # print('n/a', end="") - - if gps.isfinite(session.fix.latitude): - lat = session.fix.latitude - if gps.isfinite(session.fix.longitude): - lon = session.fix.longitude - if gps.isfinite(session.fix.altitude): - alt = session.fix.altitude - print("%.6f %.6f %.6f" % - (session.fix.latitude, session.fix.longitude, session.fix.altitude)) - -# else: -# print(" 0 0 0") - -except KeyboardInterrupt: - # got a ^C. Say bye, bye - print('') - -# Got ^C, or fell out of the loop. Cleanup, and leave. -session.close() + + session = gps.gps(mode=gps.WATCH_ENABLE) + + start = time.perf_counter() + + try: + while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2): + # print(gps.MODE_SET) + # print(session.valid) + if (session.valid): + # not useful, probably not a TPV message + # continue + + # print('Mode: %s(%d) Time: ' % + # (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], + # session.fix.mode), end="") + # print time, if we have it + print("%d " % session.fix.mode, end="") + if (session.fix.mode > mode): + mode = session.fix.mode + # if gps.TIME_SET & session.valid: + # print(session.fix.time, end="") + # else: + # print('n/a', end="") + + if gps.isfinite(session.fix.latitude): + lat = session.fix.latitude + if gps.isfinite(session.fix.longitude): + lon = session.fix.longitude + if gps.isfinite(session.fix.altitude): + alt = session.fix.altitude + print("%.6f %.6f %.6f" % + (session.fix.latitude, session.fix.longitude, session.fix.altitude)) + + # else: + # print(" 0 0 0") + + except KeyboardInterrupt: + # got a ^C. Say bye, bye + print('') + + # Got ^C, or fell out of the loop. Cleanup, and leave. + session.close() print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) exit(0) From 7140fab3f5169edda827905c71377a6e63977089 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:09:16 -0500 Subject: [PATCH 331/395] Update gps_client.py add except --- gps_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gps_client.py b/gps_client.py index 1c4712fe..7662f278 100644 --- a/gps_client.py +++ b/gps_client.py @@ -60,5 +60,6 @@ try: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() +except: print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) exit(0) From ce2ae0ea61cdfc94baad75d98e105dfaa029ff1b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:10:05 -0500 Subject: [PATCH 332/395] Update gps_client.py fix except --- gps_client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gps_client.py b/gps_client.py index 7662f278..b0b33e39 100644 --- a/gps_client.py +++ b/gps_client.py @@ -60,6 +60,9 @@ try: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() + print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) + exit(0) + except: -print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) -exit(0) + print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) + exit(0) From 307c7c6038d6769a6ba8a5940017e51ea6dbaad0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:12:22 -0500 Subject: [PATCH 333/395] Update gps_client.py cleanup --- gps_client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gps_client.py b/gps_client.py index b0b33e39..d7bebccf 100644 --- a/gps_client.py +++ b/gps_client.py @@ -11,14 +11,14 @@ run this way: python3 example1.py.txt import gps # the gpsd interface module import time -mode = -1 -lat = 0 -lon = 0 -alt = 0 - try: session = gps.gps(mode=gps.WATCH_ENABLE) + + mode = -1 + lat = 0 + lon = 0 + alt = 0 start = time.perf_counter() @@ -64,5 +64,5 @@ try: exit(0) except: - print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) + print("-1 0 0 0) exit(0) From f43a9f19d7d0926e71f06f149d92af23d36d9a63 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:12:49 -0500 Subject: [PATCH 334/395] Update gps_client.py missing " --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index d7bebccf..844c629d 100644 --- a/gps_client.py +++ b/gps_client.py @@ -64,5 +64,5 @@ try: exit(0) except: - print("-1 0 0 0) + print("-1 0 0 0") exit(0) From 9e13222bd1d05f78f0be15e228a05c05982f4775 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:13:23 -0500 Subject: [PATCH 335/395] Update gps_client.py add return --- gps_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gps_client.py b/gps_client.py index 844c629d..3f243c37 100644 --- a/gps_client.py +++ b/gps_client.py @@ -62,6 +62,7 @@ try: session.close() print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) exit(0) + return except: print("-1 0 0 0") From 37a607ba86ed17d8674952abadcad2f13d6fb1d3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:15:08 -0500 Subject: [PATCH 336/395] Update gps_client.py fix except --- gps_client.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gps_client.py b/gps_client.py index 3f243c37..a11a454b 100644 --- a/gps_client.py +++ b/gps_client.py @@ -11,14 +11,14 @@ run this way: python3 example1.py.txt import gps # the gpsd interface module import time +mode = -1 +lat = 0 +lon = 0 +alt = 0 + try: session = gps.gps(mode=gps.WATCH_ENABLE) - - mode = -1 - lat = 0 - lon = 0 - alt = 0 start = time.perf_counter() @@ -60,10 +60,8 @@ try: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() - print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) - exit(0) - return -except: - print("-1 0 0 0") +except: + print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) exit(0) + From 0ffa6c75124d5dd46f62c96b4d4e71ef2d71e185 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:18:22 -0500 Subject: [PATCH 337/395] Update gps_client.py extra print --- gps_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gps_client.py b/gps_client.py index a11a454b..d33c8fde 100644 --- a/gps_client.py +++ b/gps_client.py @@ -60,6 +60,8 @@ try: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() + print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) + exit(0) except: print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) From f965097f551fec762bc3b9264d48b28ea79e19fc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:19:48 -0500 Subject: [PATCH 338/395] Update gps_client.py make fail -1 0 0 0 --- gps_client.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gps_client.py b/gps_client.py index d33c8fde..66ba8c51 100644 --- a/gps_client.py +++ b/gps_client.py @@ -11,13 +11,13 @@ run this way: python3 example1.py.txt import gps # the gpsd interface module import time -mode = -1 -lat = 0 -lon = 0 -alt = 0 - try: - + + mode = -1 + lat = 0 + lon = 0 + alt = 0 + session = gps.gps(mode=gps.WATCH_ENABLE) start = time.perf_counter() @@ -64,6 +64,6 @@ try: exit(0) except: - print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) + print("-1 0 0 0) exit(0) From afd8cb3bf5cc1bd299338e91b6631ae747b7c6cb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 08:20:13 -0500 Subject: [PATCH 339/395] Update gps_client.py typo --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 66ba8c51..82c19137 100644 --- a/gps_client.py +++ b/gps_client.py @@ -64,6 +64,6 @@ try: exit(0) except: - print("-1 0 0 0) + print("-1 0 0 0") exit(0) From 4d79943e555be5976d626a7c277fdc0b64cab14b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:20:17 -0500 Subject: [PATCH 340/395] Update main.h add gps_mode --- main.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.h b/main.h index 0ba9c824..a45f8d14 100644 --- a/main.h +++ b/main.h @@ -66,7 +66,7 @@ #define IHU_TEMP 2 #define SPIN 1 -#define OFF - 1 +#define - 1 #define ON 1 #define CHECK 0 #define DISABLED 0 @@ -235,6 +235,7 @@ int fail_rnd_mode = FALSE; int battery_saver_mode = FALSE; long int loopTime; long int failTime = 0; +int gps_mode = OFF; int error_count = 0; int groundCommandCount = 0; From 3df37284262da745bd223c66062836a7758cc734 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:27:00 -0500 Subject: [PATCH 341/395] Update main.c add gps check --- main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.c b/main.c index a97e7e33..e9e431f1 100644 --- a/main.c +++ b/main.c @@ -341,6 +341,20 @@ 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)); } + + gps_status = OFF; + FILE *gps_read = sopen("python3 /home/pi/CubeSatSim/gps_client.py"); // python sensor polling function + + if (gps_read != NULL) { + fgets(cmdbuffer, 1000, gps_read); + fprintf(stderr, "gps read: %s\n", gps_read); + if cmdbuffer[0] != '-') + { + gps_status = ON; + fprintf(stderr, "Pi GPS enabled"); + } + fclose(gps_read); + } sensor_setup(); From cc2f6670b6d8a1e3ce3aabe1c14c2558b66f3473 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:28:37 -0500 Subject: [PATCH 342/395] Update main.h gps_status --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index a45f8d14..a0ad8414 100644 --- a/main.h +++ b/main.h @@ -235,7 +235,7 @@ int fail_rnd_mode = FALSE; int battery_saver_mode = FALSE; long int loopTime; long int failTime = 0; -int gps_mode = OFF; +int gps_status = OFF; int error_count = 0; int groundCommandCount = 0; From eedf0944bc6990b74ba83a1b2ce00f02eeec0bee Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:29:33 -0500 Subject: [PATCH 343/395] Update main.c missing ( --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index e9e431f1..b3c793fd 100644 --- a/main.c +++ b/main.c @@ -348,7 +348,7 @@ int main(int argc, char * argv[]) { if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); fprintf(stderr, "gps read: %s\n", gps_read); - if cmdbuffer[0] != '-') + if (cmdbuffer[0] != '-') { gps_status = ON; fprintf(stderr, "Pi GPS enabled"); From 2fc1a58afeccf63d2dcb4492e9a323206898788d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:30:26 -0500 Subject: [PATCH 344/395] Update main.h fix off --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index a0ad8414..4ad8b1f0 100644 --- a/main.h +++ b/main.h @@ -66,7 +66,7 @@ #define IHU_TEMP 2 #define SPIN 1 -#define - 1 +#define OFF -1 #define ON 1 #define CHECK 0 #define DISABLED 0 From 75325d38b24a76422dafdbd920dde24e3d04775c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:35:45 -0500 Subject: [PATCH 345/395] Update main.c gps on/off --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index b3c793fd..a49e85cb 100644 --- a/main.c +++ b/main.c @@ -351,8 +351,9 @@ int main(int argc, char * argv[]) { if (cmdbuffer[0] != '-') { gps_status = ON; - fprintf(stderr, "Pi GPS enabled"); - } + fprintf(stderr, "Pi GPS on"); + } else + fprintf(stderr, "Pi GPS off"); fclose(gps_read); } From 7a1bfce7488de6933f29471540b17f1151bae58e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:37:34 -0500 Subject: [PATCH 346/395] Update main.c add error checking gps --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index a49e85cb..ab8bc47a 100644 --- a/main.c +++ b/main.c @@ -355,7 +355,8 @@ int main(int argc, char * argv[]) { } else fprintf(stderr, "Pi GPS off"); fclose(gps_read); - } + } else + fprintf(stderr, "Error checking gps"); sensor_setup(); From f7cd661fc8e16f364d7c3016e37b77876a5155e4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 09:44:43 -0500 Subject: [PATCH 347/395] Update main.c display gps read --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index ab8bc47a..0ba67b20 100644 --- a/main.c +++ b/main.c @@ -351,9 +351,9 @@ int main(int argc, char * argv[]) { if (cmdbuffer[0] != '-') { gps_status = ON; - fprintf(stderr, "Pi GPS on"); + fprintf(stderr, "Pi GPS on\n"); } else - fprintf(stderr, "Pi GPS off"); + fprintf(stderr, "Pi GPS off\n"); fclose(gps_read); } else fprintf(stderr, "Error checking gps"); From 9fcaef192d217afce8e404424b27065d1765b8bd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 10:02:46 -0500 Subject: [PATCH 348/395] Update main.c check gps before payload --- main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index 0ba67b20..f9643fa5 100644 --- a/main.c +++ b/main.c @@ -329,22 +329,10 @@ int main(int argc, char * argv[]) { FILE * file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1", "r"); //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 - fprintf(stderr,"Serial opened to Pico\n"); -// payload = ON; - payload = get_payload_serial(FALSE); - fprintf(stderr,"Get_payload_status: %d \n", payload); // not debug - - } else { - fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno)); - } - + gps_status = OFF; FILE *gps_read = sopen("python3 /home/pi/CubeSatSim/gps_client.py"); // python sensor polling function - + if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); fprintf(stderr, "gps read: %s\n", gps_read); @@ -357,7 +345,19 @@ int main(int argc, char * argv[]) { fclose(gps_read); } else fprintf(stderr, "Error checking gps"); - + + payload = OFF; + fprintf(stderr,"Opening serial\n"); + if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600 + fprintf(stderr,"Serial opened to Pico\n"); +// payload = ON; + payload = get_payload_serial(FALSE); + fprintf(stderr,"Get_payload_status: %d \n", payload); // not debug + + } else { + 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)) { From e588a79cadd83bbaf05dabbc1c198fb5f16280be Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 10:10:36 -0500 Subject: [PATCH 349/395] Update main.c --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index f9643fa5..a53c330e 100644 --- a/main.c +++ b/main.c @@ -329,7 +329,8 @@ int main(int argc, char * argv[]) { FILE * file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1", "r"); //file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1", "r"); pclose(file5); - + + cmdbuffer[0] = '\0'; gps_status = OFF; FILE *gps_read = sopen("python3 /home/pi/CubeSatSim/gps_client.py"); // python sensor polling function From 97ff121ce30cd9c32172dfcc897f5ca9914850ba Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 10:29:22 -0500 Subject: [PATCH 350/395] Update gps_client.py no exit --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index 82c19137..02034944 100644 --- a/gps_client.py +++ b/gps_client.py @@ -61,7 +61,7 @@ try: # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt)) - exit(0) +# exit(0) except: print("-1 0 0 0") From 61608a9fcb14051e67d896c7b79eb8aab1bfb46b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 10:30:43 -0500 Subject: [PATCH 351/395] Update gps_client.py remove extra prints --- gps_client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gps_client.py b/gps_client.py index 02034944..d7910b20 100644 --- a/gps_client.py +++ b/gps_client.py @@ -48,15 +48,14 @@ try: lon = session.fix.longitude if gps.isfinite(session.fix.altitude): alt = session.fix.altitude - print("%.6f %.6f %.6f" % - (session.fix.latitude, session.fix.longitude, session.fix.altitude)) +# print("%.6f %.6f %.6f" % (session.fix.latitude, session.fix.longitude, session.fix.altitude)) # else: # print(" 0 0 0") except KeyboardInterrupt: # got a ^C. Say bye, bye - print('') +# print('') # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() From 5d68765a53e630836d8e7c5c5c8a718c7e4cee86 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 10:31:32 -0500 Subject: [PATCH 352/395] Update gps_client.py --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index d7910b20..c3b4dff3 100644 --- a/gps_client.py +++ b/gps_client.py @@ -55,7 +55,7 @@ try: except KeyboardInterrupt: # got a ^C. Say bye, bye -# print('') + print('') # Got ^C, or fell out of the loop. Cleanup, and leave. session.close() From b9aa2b5811a554b2e378c5b2abaf2bf66d65c05c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 10:34:03 -0500 Subject: [PATCH 353/395] Update gps_client.py no prints --- gps_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gps_client.py b/gps_client.py index c3b4dff3..3051da1c 100644 --- a/gps_client.py +++ b/gps_client.py @@ -34,7 +34,7 @@ try: # (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode], # session.fix.mode), end="") # print time, if we have it - print("%d " % session.fix.mode, end="") +# print("%d " % session.fix.mode, end="") if (session.fix.mode > mode): mode = session.fix.mode # if gps.TIME_SET & session.valid: From 9ffb8aa715e8bf7187f61133a15976c90a9d3331 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 11:13:19 -0500 Subject: [PATCH 354/395] Update main.c fix gps read print --- main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index a53c330e..6b26b5c7 100644 --- a/main.c +++ b/main.c @@ -336,13 +336,14 @@ int main(int argc, char * argv[]) { if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); - fprintf(stderr, "gps read: %s\n", gps_read); - if (cmdbuffer[0] != '-') + fprintf(stderr, "gps read: %s\n", cmdbuffer); + if ((cmdbuffer[0] == '-') and (cmdbuffer[1] == '1')) { + gps_status = OFF; + fprintf(stderr, "Pi GPS off\n"); + } else gps_status = ON; fprintf(stderr, "Pi GPS on\n"); - } else - fprintf(stderr, "Pi GPS off\n"); fclose(gps_read); } else fprintf(stderr, "Error checking gps"); From 4bafce21c77091166bd9df398bb35f3e131da9ef Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 11:13:51 -0500 Subject: [PATCH 355/395] Update main.c fix and --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 6b26b5c7..26bfa98e 100644 --- a/main.c +++ b/main.c @@ -337,7 +337,7 @@ int main(int argc, char * argv[]) { if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); fprintf(stderr, "gps read: %s\n", cmdbuffer); - if ((cmdbuffer[0] == '-') and (cmdbuffer[1] == '1')) + if ((cmdbuffer[0] == '-') && (cmdbuffer[1] == '1')) { gps_status = OFF; fprintf(stderr, "Pi GPS off\n"); From 221ef17d309487c8483182f56e1bc6f6bab8116c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 11:31:04 -0500 Subject: [PATCH 356/395] Update main.c don't check get_payload_status if gps is on --- main.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index 26bfa98e..8dc0d9bb 100644 --- a/main.c +++ b/main.c @@ -341,24 +341,34 @@ int main(int argc, char * argv[]) { { gps_status = OFF; fprintf(stderr, "Pi GPS off\n"); - } else + } else { gps_status = ON; fprintf(stderr, "Pi GPS on\n"); + } fclose(gps_read); } else fprintf(stderr, "Error checking gps"); payload = OFF; - fprintf(stderr,"Opening serial\n"); - if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600 - fprintf(stderr,"Serial opened to Pico\n"); -// payload = ON; - payload = get_payload_serial(FALSE); - fprintf(stderr,"Get_payload_status: %d \n", payload); // not debug - - } else { - fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno)); - } + + if (gps_status == OFF) + { + fprintf(stderr,"Opening serial\n"); + if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600 + fprintf(stderr,"Serial opened to Pico\n"); + // payload = ON; + payload = get_payload_serial(FALSE); + fprintf(stderr,"Get_payload_status: %d \n", payload); // not debug + + } else { + fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno)); + } + } + else + { + payload = FALSE; + printf("get_payload_status not run since gps_status is ON\n"); + } sensor_setup(); @@ -667,9 +677,17 @@ int main(int argc, char * argv[]) { - - payload = get_payload_serial(FALSE); // not debug - printf("get_payload_status: %d \n", payload); + if (gps_status == OFF) + { + payload = get_payload_serial(FALSE); // not debug + printf("get_payload_status: %d \n", payload); + } + else + { + payload = FALSE; + printf("get_payload_status not run since gps_status is ON\n"); + } + if (payload == FALSE) { payload = pi_sensors(buffer2); printf("pi_sensors status: %d \n", payload); From 67376fcea04b9348a3a3337020332c7812211e64 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 14:53:42 -0500 Subject: [PATCH 357/395] Update main.c pi gps sensor parsing --- main.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 8dc0d9bb..01b84e2e 100644 --- a/main.c +++ b/main.c @@ -762,9 +762,47 @@ int main(int argc, char * argv[]) { token = strtok(NULL, space); } } - - printf("\n"); + if (gps_status == TRUE) { + fprintf(stderr, "Checking Pi gps\n"); + cmdbuffer[0] = '\0'; + gps_read = sopen("python3 /home/pi/CubeSatSim/gps_client.py"); // python sensor polling function + + if (gps_read != NULL) { + fgets(cmdbuffer, 1000, gps_read); + fprintf(stderr, "gps read: %s\n", cmdbuffer); + if ((cmdbuffer[0] == '2') || (cmdbuffer[0] == '3')) + { + printf("Valid gps data!\n"); + int count1; + char * token; + + const char space[2] = " "; + token = strtok(cmdbuffer, space); + // printf("token: %s\n", token); + for (count1 = GPS; count1 < (GPS + 3); 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); + } + } + printf("\n"); + + } else { + fprintf(stderr, "No Pi gps available\n"); + } + fclose(gps_read); + } else + fprintf(stderr, "Error checking gps"); + + } + + printf("\n"); // if (sensor[GPS1] != 0) { if ((sensor[GPS1] > -90.0) && (sensor[GPS1] < 90.0) && (sensor[GPS1] != 0.0)) { if (sensor[GPS1] != latitude) { From 928a58d6364e9472f3a7ad55885e6cb9e9ee9f5b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 14:54:48 -0500 Subject: [PATCH 358/395] Update main.h add GPS position holder --- main.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.h b/main.h index 4ad8b1f0..c0928529 100644 --- a/main.h +++ b/main.h @@ -39,16 +39,17 @@ #define PRES 3 #define ALT 4 #define HUMI 5 -#define GYRO_X 7 // MPU6050 is posisition 6 +#define GYRO_X 7 // MPU6050 label is posisition 6 #define GYRO_Y 8 #define GYRO_Z 9 #define ACCEL_X 10 #define ACCEL_Y 11 #define ACCEL_Z 12 -#define GPS1 14 // GPS is position 13 -#define GPS2 15 -#define GPS3 16 -#define DTEMP 18 // TMP is position 17 +#define GPS 13 // GPS label +#define GPS1 14 // latitude +#define GPS2 15 // longitude +#define GPS3 16 // altitude +#define DTEMP 18 // TMP label is position 17 #define XS1 20 // NEW user defined token will be position 19 #define XS2 21 #define XS3 22 From 0f2133e6fc05b87e82ba95cb6fbf94ee5c753ad3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 15:34:05 -0500 Subject: [PATCH 359/395] Update gps_client.py add session.waiting --- gps_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gps_client.py b/gps_client.py index 3051da1c..ec34f89e 100644 --- a/gps_client.py +++ b/gps_client.py @@ -21,9 +21,13 @@ try: session = gps.gps(mode=gps.WATCH_ENABLE) start = time.perf_counter() - + try: - while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2): +# while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2): + while ((time.perf_counter() - start) < 2) and (mode < 2): + if session.waiting(2.0): + session.read() + # print(gps.MODE_SET) # print(session.valid) if (session.valid): From f9745952965674f630bda42eaf01b7cd099c4f2b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 15:38:25 -0500 Subject: [PATCH 360/395] Update main.c add gps test string --- main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.c b/main.c index 01b84e2e..6d5a3cec 100644 --- a/main.c +++ b/main.c @@ -770,6 +770,10 @@ int main(int argc, char * argv[]) { if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); + + char *gpsTestStr[] = "2 32.3 -54 333\n"; + strcpy(cmdbuffer, gpsTestStr); + fprintf(stderr, "gps read: %s\n", cmdbuffer); if ((cmdbuffer[0] == '2') || (cmdbuffer[0] == '3')) { From d2ad41f0e014d7ce384f66d25a7c2b86dce4014b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 15:39:36 -0500 Subject: [PATCH 361/395] Update main.c add const --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 6d5a3cec..99397f30 100644 --- a/main.c +++ b/main.c @@ -771,7 +771,7 @@ int main(int argc, char * argv[]) { if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); - char *gpsTestStr[] = "2 32.3 -54 333\n"; + const char *gpsTestStr[] = "2 32.3 -54 333\n"; strcpy(cmdbuffer, gpsTestStr); fprintf(stderr, "gps read: %s\n", cmdbuffer); From 08fae87d1738b54aefa9c49661c7dceddcc449a1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 14 Dec 2025 15:41:19 -0500 Subject: [PATCH 362/395] Update main.c fix const --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 99397f30..49b4410c 100644 --- a/main.c +++ b/main.c @@ -771,7 +771,7 @@ int main(int argc, char * argv[]) { if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); - const char *gpsTestStr[] = "2 32.3 -54 333\n"; + const char gpsTestStr[] = "2 32.3 -54 333\n"; strcpy(cmdbuffer, gpsTestStr); fprintf(stderr, "gps read: %s\n", cmdbuffer); From 8410d2db406f6ff137350754a2ac986a7ed0ceb8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 15 Dec 2025 00:19:20 -0500 Subject: [PATCH 363/395] Update main.c changed to 4 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 49b4410c..40b3fea3 100644 --- a/main.c +++ b/main.c @@ -784,7 +784,7 @@ int main(int argc, char * argv[]) { const char space[2] = " "; token = strtok(cmdbuffer, space); // printf("token: %s\n", token); - for (count1 = GPS; count1 < (GPS + 3); count1++) { + for (count1 = GPS; count1 < (GPS + 4); count1++) { if (token != NULL) { sensor[count1] = (float) atof(token); strcpy(sensor_string[count1], token); From c9b1c73f425efe3beb37d7e330f6c9743689fa4d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 15 Dec 2025 00:23:12 -0500 Subject: [PATCH 364/395] Update main.c write gps back --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 40b3fea3..2a368998 100644 --- a/main.c +++ b/main.c @@ -796,6 +796,7 @@ int main(int argc, char * argv[]) { } } printf("\n"); + strcpy(sensor_string[GPS], "GPS"); } else { fprintf(stderr, "No Pi gps available\n"); From 7cf0b8ccd5528a7197a0712a280e2a3310e05d64 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 15 Dec 2025 00:24:58 -0500 Subject: [PATCH 365/395] Update main.c remove gps test string --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 2a368998..9989851f 100644 --- a/main.c +++ b/main.c @@ -771,8 +771,8 @@ int main(int argc, char * argv[]) { if (gps_read != NULL) { fgets(cmdbuffer, 1000, gps_read); - const char gpsTestStr[] = "2 32.3 -54 333\n"; - strcpy(cmdbuffer, gpsTestStr); +// const char gpsTestStr[] = "2 32.3 -54 333\n"; +// strcpy(cmdbuffer, gpsTestStr); fprintf(stderr, "gps read: %s\n", cmdbuffer); if ((cmdbuffer[0] == '2') || (cmdbuffer[0] == '3')) From 946334535db8bc99d07c0dc783e6b6bbaea550ba Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 15 Dec 2025 01:18:08 -0500 Subject: [PATCH 366/395] Update main.c print last two chars --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 9989851f..8336ea04 100644 --- a/main.c +++ b/main.c @@ -777,7 +777,8 @@ int main(int argc, char * argv[]) { fprintf(stderr, "gps read: %s\n", cmdbuffer); if ((cmdbuffer[0] == '2') || (cmdbuffer[0] == '3')) { - printf("Valid gps data!\n"); + printf("Valid gps data!\n"); + printf("%x %x \n", cmdbuffer[strlen(cmdbuffer) - 2], cmdbuffer[strlen(cmdbuffer) - 1] ); int count1; char * token; From e10f0d83a31cc4aa9b6cdf86c37c65209010b167 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 15 Dec 2025 01:36:34 -0500 Subject: [PATCH 367/395] Update main.c remove \n in gps string --- main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.c b/main.c index 8336ea04..28a3a127 100644 --- a/main.c +++ b/main.c @@ -779,6 +779,10 @@ int main(int argc, char * argv[]) { { printf("Valid gps data!\n"); printf("%x %x \n", cmdbuffer[strlen(cmdbuffer) - 2], cmdbuffer[strlen(cmdbuffer) - 1] ); + if (cmdbuffer[strlen(cmdbuffer) - 1] == '\n') + cmdbuffer[strlen(cmdbuffer) - 1] = '\0'; + printf("%x %x \n", cmdbuffer[strlen(cmdbuffer) - 2], cmdbuffer[strlen(cmdbuffer) - 1] ); + int count1; char * token; From d378dec4486a1395b5f8c4cd18ce56cacdaec5d5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 03:15:16 -0500 Subject: [PATCH 368/395] Update update add gpsd install --- update | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/update b/update index 8d316d44..64f856a4 100755 --- a/update +++ b/update @@ -31,7 +31,7 @@ if [ "$1" = "u" ]; then # sudo apt-get update && sudo apt-get dist-upgrade -y sudo apt-get update -y - sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom + sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom gpsd gpsd-clients libgps-dev fi @@ -49,6 +49,8 @@ sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # si sudo sed -i 's/maxcpus=2/maxcpus=1/g' /boot/cmdline.txt # single core if Pi Zero 2 +sudo sed -i 's/DEVICES=""/DEVICES="/dev/serial0"/g' /etc/default/gpsd + cd /home/pi/CubeSatSim git pull --no-rebase > .updated From 3a45aa4c6af6e7f2f6218076a31bf7dc9ab7c251 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 03:55:40 -0500 Subject: [PATCH 369/395] Update install for gpsd --- install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install b/install index 6bf50f0f..43d293b2 100755 --- a/install +++ b/install @@ -48,7 +48,7 @@ sudo apt-get update && sudo apt-get dist-upgrade -y sudo apt-get remove pulseaudio -y # removed wiringpi and python-picamera python3-picamera -sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev minicom +sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev minicom gpsd gpsd-clients libgps-dev python3-gps cd /tmp @@ -270,6 +270,8 @@ sudo raspi-config nonint do_legacy 0 sudo sh -c 'echo "\n" >> /boot/config.txt' +sudo sed -i 's/DEVICES=""/DEVICES="/dev/serial0"/g' /etc/default/gpsd + changed=0 value=`cat /home/pi/CubeSatSim/sim.cfg` echo "$value" > /dev/null From 45f78ae3b67d2ec0591b5f05e4fb7298adac9450 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 03:56:06 -0500 Subject: [PATCH 370/395] Update update add python3 gpsd --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index 64f856a4..f9c6c260 100755 --- a/update +++ b/update @@ -31,7 +31,7 @@ if [ "$1" = "u" ]; then # sudo apt-get update && sudo apt-get dist-upgrade -y sudo apt-get update -y - sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom gpsd gpsd-clients libgps-dev + sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom gpsd gpsd-clients libgps-dev python3-gps fi From 8aca688530df9ad08245d011ffbfacc50c4807de Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 04:27:05 -0500 Subject: [PATCH 371/395] Update install fix sed --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 43d293b2..414e39d0 100755 --- a/install +++ b/install @@ -270,7 +270,7 @@ sudo raspi-config nonint do_legacy 0 sudo sh -c 'echo "\n" >> /boot/config.txt' -sudo sed -i 's/DEVICES=""/DEVICES="/dev/serial0"/g' /etc/default/gpsd +sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd changed=0 value=`cat /home/pi/CubeSatSim/sim.cfg` From 748c79120089ae1cafa3e8f4306c74710f243d06 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 04:27:38 -0500 Subject: [PATCH 372/395] Update update fix gpsd sed --- update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update b/update index f9c6c260..dfe1f3d5 100755 --- a/update +++ b/update @@ -49,7 +49,7 @@ sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # si sudo sed -i 's/maxcpus=2/maxcpus=1/g' /boot/cmdline.txt # single core if Pi Zero 2 -sudo sed -i 's/DEVICES=""/DEVICES="/dev/serial0"/g' /etc/default/gpsd +sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd cd /home/pi/CubeSatSim From df3189a288ff2a3275adf7d3d35bcf5861204387 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:21:58 -0500 Subject: [PATCH 373/395] Update transmit.py add gpsd check before programming FM --- transmit.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index 6ac1b713..d2960a88 100644 --- a/transmit.py +++ b/transmit.py @@ -11,6 +11,7 @@ from os import system from PIL import Image, ImageDraw, ImageFont, ImageColor import serial import random +import subprocess def sim_failure_check(): try: @@ -395,7 +396,11 @@ if __name__ == "__main__": card = "Headphones" # default using pcm audio output of Pi Zero # card = "Device" # using USB sound card for audio output - if (mode != 'e'): + query = ["sudo", "systemctl", "is-active", "gpsd.socket.service"] + result = subprocess.run(query, capture_output=True, text=True, check=True) + print(result.stdout) + + if (mode != 'e') and (result.stdout != "active"): print("Programming FM module!\n"); output(pd, 1) output (ptt, 1) From 2d3c717386529edefb51ab2884edb4e0d3fc5c8a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:29:25 -0500 Subject: [PATCH 374/395] Update transmit.py command error --- transmit.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index d2960a88..9024a2f2 100644 --- a/transmit.py +++ b/transmit.py @@ -397,8 +397,14 @@ if __name__ == "__main__": # card = "Device" # using USB sound card for audio output query = ["sudo", "systemctl", "is-active", "gpsd.socket.service"] - result = subprocess.run(query, capture_output=True, text=True, check=True) - print(result.stdout) + try: + result = subprocess.run(query, capture_output=True, text=True, check=True) + except subprocess.CalledProcessError as e: + print(f"Command failed with return code: {e.returncode}") + print(f"Command run was: {e.cmd}") + print(f"Output of the command (stdout): {e.stdout}") + print(f"Error output of the command (stderr): {e.stderr}") + print(result.stdout) if (mode != 'e') and (result.stdout != "active"): print("Programming FM module!\n"); From 3685b91984ff34371b3144d7f726ada42fa6c24e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:30:30 -0500 Subject: [PATCH 375/395] Update transmit.py fix tabs --- transmit.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/transmit.py b/transmit.py index 9024a2f2..18c97c1c 100644 --- a/transmit.py +++ b/transmit.py @@ -400,11 +400,11 @@ if __name__ == "__main__": try: result = subprocess.run(query, capture_output=True, text=True, check=True) except subprocess.CalledProcessError as e: - print(f"Command failed with return code: {e.returncode}") - print(f"Command run was: {e.cmd}") - print(f"Output of the command (stdout): {e.stdout}") - print(f"Error output of the command (stderr): {e.stderr}") - print(result.stdout) + print(f"Command failed with return code: {e.returncode}") + print(f"Command run was: {e.cmd}") + print(f"Output of the command (stdout): {e.stdout}") + print(f"Error output of the command (stderr): {e.stderr}") + print(result.stdout) if (mode != 'e') and (result.stdout != "active"): print("Programming FM module!\n"); From c82ae5ba9c7a63346cae428ad2ae50277898f4bb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:33:18 -0500 Subject: [PATCH 376/395] Update transmit.py fix gpsd query --- transmit.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index 18c97c1c..cd65a096 100644 --- a/transmit.py +++ b/transmit.py @@ -404,9 +404,8 @@ if __name__ == "__main__": print(f"Command run was: {e.cmd}") print(f"Output of the command (stdout): {e.stdout}") print(f"Error output of the command (stderr): {e.stderr}") - print(result.stdout) - if (mode != 'e') and (result.stdout != "active"): + if (mode != 'e') and (e.stdout != "active"): print("Programming FM module!\n"); output(pd, 1) output (ptt, 1) From 9374fe4a0ff8d5d43c561262d2ad548e9ef1d7c0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:34:51 -0500 Subject: [PATCH 377/395] Update transmit.py fix e.result --- transmit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index cd65a096..3d5c1871 100644 --- a/transmit.py +++ b/transmit.py @@ -402,10 +402,11 @@ if __name__ == "__main__": except subprocess.CalledProcessError as e: print(f"Command failed with return code: {e.returncode}") print(f"Command run was: {e.cmd}") + output = e.cmd print(f"Output of the command (stdout): {e.stdout}") print(f"Error output of the command (stderr): {e.stderr}") - if (mode != 'e') and (e.stdout != "active"): + if (mode != 'e') and (output != "active"): print("Programming FM module!\n"); output(pd, 1) output (ptt, 1) From d9d9ab7a987bbd6c2ea32800fab4b041d04f71ac Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:36:57 -0500 Subject: [PATCH 378/395] Update transmit.py gpsd status check --- transmit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transmit.py b/transmit.py index 3d5c1871..3a40b1dc 100644 --- a/transmit.py +++ b/transmit.py @@ -400,13 +400,13 @@ if __name__ == "__main__": try: result = subprocess.run(query, capture_output=True, text=True, check=True) except subprocess.CalledProcessError as e: - print(f"Command failed with return code: {e.returncode}") +# print(f"Command failed with return code: {e.returncode}") print(f"Command run was: {e.cmd}") - output = e.cmd + gpsd_status = e.stdout print(f"Output of the command (stdout): {e.stdout}") - print(f"Error output of the command (stderr): {e.stderr}") +# print(f"Error output of the command (stderr): {e.stderr}") - if (mode != 'e') and (output != "active"): + if (mode != 'e') and (gpsd_status != "active"): print("Programming FM module!\n"); output(pd, 1) output (ptt, 1) From 6a4f538949ff606870f575fc44f7529c27d5f185 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:39:02 -0500 Subject: [PATCH 379/395] Update transmit.py fix is-active cmd --- transmit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index 3a40b1dc..e5adff0b 100644 --- a/transmit.py +++ b/transmit.py @@ -396,7 +396,7 @@ if __name__ == "__main__": card = "Headphones" # default using pcm audio output of Pi Zero # card = "Device" # using USB sound card for audio output - query = ["sudo", "systemctl", "is-active", "gpsd.socket.service"] + query = ["sudo", "systemctl", "is-active", "gpsd.socket"] try: result = subprocess.run(query, capture_output=True, text=True, check=True) except subprocess.CalledProcessError as e: From 4612435c8fd1f5f43fdf89c2ea133812185698fd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:40:54 -0500 Subject: [PATCH 380/395] Update transmit.py handle success --- transmit.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transmit.py b/transmit.py index e5adff0b..28e705b1 100644 --- a/transmit.py +++ b/transmit.py @@ -399,6 +399,9 @@ if __name__ == "__main__": query = ["sudo", "systemctl", "is-active", "gpsd.socket"] try: result = subprocess.run(query, capture_output=True, text=True, check=True) + print(f"Command run was: {query}") + gpsd_status = result.stdout + print(f"Output of the command (stdout): {gpsd_status}") except subprocess.CalledProcessError as e: # print(f"Command failed with return code: {e.returncode}") print(f"Command run was: {e.cmd}") From bcfdb97796de2be912eba9ca49a21e4d7a17f98b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:47:02 -0500 Subject: [PATCH 381/395] Update transmit.py print gpsd status --- transmit.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transmit.py b/transmit.py index 28e705b1..34ec9ab1 100644 --- a/transmit.py +++ b/transmit.py @@ -408,6 +408,11 @@ if __name__ == "__main__": gpsd_status = e.stdout print(f"Output of the command (stdout): {e.stdout}") # print(f"Error output of the command (stderr): {e.stderr}") + + if gpsd_status == "active"): + print("gpsd status is active" + if gpsd_status == "inactive"): + print("gpsd status is inactive" if (mode != 'e') and (gpsd_status != "active"): print("Programming FM module!\n"); From 6bfade0231dfe24d92c97c08f557ba0b032cf3f4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:47:42 -0500 Subject: [PATCH 382/395] Update transmit.py print typo --- transmit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index 34ec9ab1..3fb0c76c 100644 --- a/transmit.py +++ b/transmit.py @@ -409,9 +409,9 @@ if __name__ == "__main__": print(f"Output of the command (stdout): {e.stdout}") # print(f"Error output of the command (stderr): {e.stderr}") - if gpsd_status == "active"): + if gpsd_status == "active": print("gpsd status is active" - if gpsd_status == "inactive"): + if gpsd_status == "inactive": print("gpsd status is inactive" if (mode != 'e') and (gpsd_status != "active"): From 8134f7752b430ddc02dc94b97b87e46f4407dfbb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:51:47 -0500 Subject: [PATCH 383/395] Update transmit.py add strip() --- transmit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transmit.py b/transmit.py index 3fb0c76c..e2b73080 100644 --- a/transmit.py +++ b/transmit.py @@ -400,18 +400,18 @@ if __name__ == "__main__": try: result = subprocess.run(query, capture_output=True, text=True, check=True) print(f"Command run was: {query}") - gpsd_status = result.stdout + gpsd_status = result.stdout.strip() print(f"Output of the command (stdout): {gpsd_status}") except subprocess.CalledProcessError as e: # print(f"Command failed with return code: {e.returncode}") print(f"Command run was: {e.cmd}") - gpsd_status = e.stdout + gpsd_status = e.stdout.strip() print(f"Output of the command (stdout): {e.stdout}") # print(f"Error output of the command (stderr): {e.stderr}") - if gpsd_status == "active": + if (gpsd_status == "active"): print("gpsd status is active" - if gpsd_status == "inactive": + if (gpsd_status == "inactive"): print("gpsd status is inactive" if (mode != 'e') and (gpsd_status != "active"): From 0db5b8793b1005faecfb2f6973f2ad0b45b565a8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:52:43 -0500 Subject: [PATCH 384/395] Update transmit.py --- transmit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transmit.py b/transmit.py index e2b73080..b620377d 100644 --- a/transmit.py +++ b/transmit.py @@ -409,10 +409,10 @@ if __name__ == "__main__": print(f"Output of the command (stdout): {e.stdout}") # print(f"Error output of the command (stderr): {e.stderr}") - if (gpsd_status == "active"): - print("gpsd status is active" - if (gpsd_status == "inactive"): - print("gpsd status is inactive" +# if (gpsd_status == "active"): +# print("gpsd status is active" +# if (gpsd_status == "inactive"): +# print("gpsd status is inactive" if (mode != 'e') and (gpsd_status != "active"): print("Programming FM module!\n"); From 0a46f27f1ef1ec8bafde3e8f0086e1aedf8cdd78 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 06:53:43 -0500 Subject: [PATCH 385/395] Update transmit.py don't program fm if gpsd running --- transmit.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/transmit.py b/transmit.py index b620377d..786fc94e 100644 --- a/transmit.py +++ b/transmit.py @@ -408,12 +408,7 @@ if __name__ == "__main__": gpsd_status = e.stdout.strip() print(f"Output of the command (stdout): {e.stdout}") # print(f"Error output of the command (stderr): {e.stderr}") - -# if (gpsd_status == "active"): -# print("gpsd status is active" -# if (gpsd_status == "inactive"): -# print("gpsd status is inactive" - + if (mode != 'e') and (gpsd_status != "active"): print("Programming FM module!\n"); output(pd, 1) From dcd09063da1e679f835b4c359f1befbd3733cfe4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 07:09:31 -0500 Subject: [PATCH 386/395] Update config add -u for change gpsd state --- config | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/config b/config index 092c9d55..12f6f200 100755 --- a/config +++ b/config @@ -1771,7 +1771,42 @@ elif [ "$1" = "-U" ]; then if [ "${12}" != "$sim" ] || [ "${13}" != "$time" ] ; then reboot=1 fi - + +elif [ "$1" = "-u" ]; then + + echo + echo "Change gpsd state" + echo + + FILE=/home/pi/CubeSatSim/command_control + if [[ $(sudo systemctl is-active gpsd.socket | grep inactive) ]]; then + echo "gpsd is inactive" + echo + echo "Do you want to turn gpsd to ON (y/n) " + read reset + echo + + if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then + echo "gpsd set to ON" + sudo systemctl disable gpsd.socket + reboot=1 + fi + + else + echo "gpsd is active" + echo + echo "Do you want to turn gpsd to OFF (y/n) " + read reset + echo + + if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then + echo "gpsd set to OFF" + sudo systemctl enable gpsd.socket + reboot=1 + fi + + fi + elif [ "$1" = "-h" ]; then echo "config OPTION" From 46fddd90ac4f3bc4b658d76379b25809607dfcbe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 07:12:12 -0500 Subject: [PATCH 387/395] Update config gpsd and gpsd.socket --- config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config b/config index 12f6f200..433b6817 100755 --- a/config +++ b/config @@ -1788,6 +1788,7 @@ elif [ "$1" = "-u" ]; then if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then echo "gpsd set to ON" + sudo systemctl disable gpsd sudo systemctl disable gpsd.socket reboot=1 fi @@ -1801,8 +1802,9 @@ elif [ "$1" = "-u" ]; then if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then echo "gpsd set to OFF" + sudo systemctl enable gpsd sudo systemctl enable gpsd.socket - reboot=1 +reboot=1 fi fi From 1277cbbdaba6daa484e8b8558d7acaf7d71a72aa Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 07:15:25 -0500 Subject: [PATCH 388/395] Update config fix enable disable gpsd --- config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config b/config index 433b6817..f2ff1fb8 100755 --- a/config +++ b/config @@ -1788,8 +1788,8 @@ elif [ "$1" = "-u" ]; then if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then echo "gpsd set to ON" - sudo systemctl disable gpsd - sudo systemctl disable gpsd.socket + sudo systemctl enable gpsd + sudo systemctl enable gpsd.socket reboot=1 fi @@ -1802,8 +1802,8 @@ elif [ "$1" = "-u" ]; then if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then echo "gpsd set to OFF" - sudo systemctl enable gpsd - sudo systemctl enable gpsd.socket + sudo systemctl disable gpsd + sudo systemctl disable gpsd.socket reboot=1 fi From a24522868992b804f48f453f51ea5e8226f36b6d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 07:20:49 -0500 Subject: [PATCH 389/395] Update config add gpsmon print --- config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config b/config index f2ff1fb8..391ca91c 100755 --- a/config +++ b/config @@ -1790,6 +1790,9 @@ elif [ "$1" = "-u" ]; then echo "gpsd set to ON" sudo systemctl enable gpsd sudo systemctl enable gpsd.socket + echo + echo "to monitor your gps device, use the command gpsmon" + echo reboot=1 fi From 3985e9ee139d8e521c519e49045f991d75802a47 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 07:49:54 -0500 Subject: [PATCH 390/395] Update update move gps install --- update | 2 ++ 1 file changed, 2 insertions(+) diff --git a/update b/update index dfe1f3d5..4ae6653c 100755 --- a/update +++ b/update @@ -35,6 +35,8 @@ if [ "$1" = "u" ]; then fi +sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps + # sudo apt-get install -y python3-smbus libusb-1.0 sudo sed -i 's/update.sh/update /g' /etc/motd From c6d4e69d3f2d7f1f9e48b72421fca2a502f3713b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 07:54:10 -0500 Subject: [PATCH 391/395] Update update install gpsd but disable --- update | 3 +++ 1 file changed, 3 insertions(+) diff --git a/update b/update index 4ae6653c..c942f9fb 100755 --- a/update +++ b/update @@ -53,6 +53,9 @@ sudo sed -i 's/maxcpus=2/maxcpus=1/g' /boot/cmdline.txt # single core if Pi Zero sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd +sudo systemctl disable gpsd > /dev/null 2>&1 +sudo systemctl disable gpsd.socket > /dev/null 2>&1 + cd /home/pi/CubeSatSim git pull --no-rebase > .updated From 563e2da48d245e640387ed42d4098451de7ec951 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 08:07:03 -0500 Subject: [PATCH 392/395] Update config to change frequency, disable gpsd --- config | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/config b/config index 391ca91c..32ed69fc 100755 --- a/config +++ b/config @@ -1188,24 +1188,24 @@ elif [ "$1" = "-F" ]; then rx="$8" echo "Keeping value of" $rx fi -# else - - echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - 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 -# echo -# else + 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 + + echo + echo "Restarting CubeSatSim with new configuration file" + + if [[ $(sudo systemctl is-active gpsd.socket | grep inactive) ]]; then + sudo systemctl restart transmit + else echo - echo "Restarting CubeSatSim with new configuration file" -## echo -# reboot=1 -## sudo reboot now + echo "temporarily disabling gpsd and rebooting to program FM module" + sudo systemctl stop gpsd.socket sudo systemctl restart transmit -# fi + sleep 10 + restart=1 + fi elif [ "$1" = "-o" ]; then @@ -1778,7 +1778,6 @@ elif [ "$1" = "-u" ]; then echo "Change gpsd state" echo - FILE=/home/pi/CubeSatSim/command_control if [[ $(sudo systemctl is-active gpsd.socket | grep inactive) ]]; then echo "gpsd is inactive" echo From 3d9d4ae3c8d68661a3be0de225453cb4aca13249 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 08:08:56 -0500 Subject: [PATCH 393/395] Update config after gpsd toggle, reboot --- config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config b/config index 32ed69fc..5f0079e2 100755 --- a/config +++ b/config @@ -1201,10 +1201,11 @@ elif [ "$1" = "-F" ]; then else echo echo "temporarily disabling gpsd and rebooting to program FM module" + echo "this will take about 40 seconds" sudo systemctl stop gpsd.socket sudo systemctl restart transmit sleep 10 - restart=1 + reboot=1 fi elif [ "$1" = "-o" ]; then From 0ec6f2520b4ed76a43e88e5024adaf0ad80c88dc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 16 Dec 2025 08:16:04 -0500 Subject: [PATCH 394/395] Update config add gpsd config default --- config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config b/config index 5f0079e2..ac46cb60 100755 --- a/config +++ b/config @@ -1791,7 +1791,8 @@ elif [ "$1" = "-u" ]; then sudo systemctl enable gpsd sudo systemctl enable gpsd.socket echo - echo "to monitor your gps device, use the command gpsmon" + echo "Unless you configure gpsd otherwise, the gps is connected to serial0 on the Pi." + echo "To monitor your gps device, use the command gpsmon" echo reboot=1 fi From bd478645f406ea0ec1986316c467a33c015bcd14 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 18 Jan 2026 16:20:38 -0500 Subject: [PATCH 395/395] Update main.c ALT divide by 10 instead of 10x --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 28a3a127..6d168cb6 100644 --- a/main.c +++ b/main.c @@ -1831,7 +1831,7 @@ void get_tlm_fox() { 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 + 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));