From 5e74e602d9dc29f3d26eca2d072ab974a9c20a53 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 10:19:45 -0500 Subject: [PATCH 01/26] Update main.c updated length to 2*ctr+2 like bpsk --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 83d5c932..8dc0f1a1 100644 --- a/main.c +++ b/main.c @@ -2481,7 +2481,7 @@ void get_tlm_fc() { /* write waveform buffer over socket */ - int length = (headerLen + syncBits + dataLen) * samples; + int length = (((headerLen + syncBits + dataLen) * samples) * 2) + 2; // ctr * 2 + 2 like bpsk due to 2 bytes per sample. if (!error && transmit) { // digitalWrite (0, LOW); From 3684cd08cbe1bbd6ebf2a6a352dee82e94e883a4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 12:03:16 -0500 Subject: [PATCH 02/26] Update main.c first byte 01 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 8dc0f1a1..32afae52 100644 --- a/main.c +++ b/main.c @@ -2302,7 +2302,7 @@ void get_tlm_fc() { // printf("\nSYMPBLOCK = %d\n", SYMPBLOCK); memset(source_bytes, 0x00, sizeof(source_bytes)); - source_bytes[0] = 0b10000010 ; // 10100000 10000001 01000001 10000001 10000001 + source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = (uint8_t) rnd_float(0,255); source_bytes[50] = 0xff; // Sequence number From 24ffeac63e74cd07ad93c7f7a2841e1c49760ebe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 14:41:44 -0500 Subject: [PATCH 03/26] Update main.c print length ctr --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 32afae52..e64630ed 100644 --- a/main.c +++ b/main.c @@ -2482,6 +2482,7 @@ void get_tlm_fc() { /* write waveform buffer over socket */ int length = (((headerLen + syncBits + dataLen) * samples) * 2) + 2; // ctr * 2 + 2 like bpsk due to 2 bytes per sample. + printf("length: %d ctr: %d\n", length, ctr); if (!error && transmit) { // digitalWrite (0, LOW); From dae1fac673ac1af75352e1ae8e6dd78328cebbf4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:01:47 -0500 Subject: [PATCH 04/26] Update main.c add sequence --- main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index e64630ed..4fee5847 100644 --- a/main.c +++ b/main.c @@ -56,7 +56,7 @@ int main(int argc, char * argv[]) { // program_radio(); // do in transmit instead if (uptime_sec < 30.0) { - reset_count = (reset_count + 1) % 0xffff; // only increment uptime if just rebooted + reset_count = (reset_count + 1) % ff; // only increment uptime if just rebooted fprintf(stderr,"INFO: Reset Count: %d Uptime since Reset: %ld \n", reset_count, uptime_sec); } @@ -1343,12 +1343,12 @@ void get_tlm_fox() { 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[1] = (short int) ((reset_count >> 5) & ); 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[3] = (short int) ((uptime >> 5) & ); + h[4] = (short int) ((uptime >> 13) & ); h[5] = (short int) ((h[5] & 0xf0) | ((uptime >> 21) & 0x0f)); h[5] = (short int) ((h[5] & 0x0f) | (frm_type << 4)); @@ -1596,12 +1596,12 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 0xffff; - encodeA(b, 64 + head_offset, 0xff & val); + unsigned long val = ff; + encodeA(b, 64 + head_offset, & 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, f); } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; @@ -1989,7 +1989,7 @@ void write_wave(int i, short int *buffer) int encodeA(short int *b, int index, int val) { // printf("Encoding A\n"); - b[index] = val & 0xff; + b[index] = val & ; b[index + 1] = (short int) ((b[index + 1] & 0xf0) | ((val >> 8) & 0x0f)); return 0; } @@ -1997,7 +1997,7 @@ int encodeA(short int *b, int index, int val) { int encodeB(short int *b, int index, int val) { // printf("Encoding B\n"); b[index] = (short int) ((b[index] & 0x0f) | ((val << 4) & 0xf0)); - b[index + 1] = (val >> 4 ) & 0xff; + b[index + 1] = (val >> 4 ) & ; return 0; } @@ -2305,9 +2305,9 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = (uint8_t) rnd_float(0,255); - source_bytes[50] = 0xff; // Sequence number - source_bytes[51] = 0xff; - source_bytes[52] = 0xff; + source_bytes[50] = 0x00; // Sequence number + source_bytes[51] = 0x00; + source_bytes[52] = 0xFF & sequence++; /**/ printf("\nsource_bytes\n"); for (int i=0; i<256; i++) From 87fa349b122376760043bc2c03e8aa9f2a14b80e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:04:08 -0500 Subject: [PATCH 05/26] Update main.h --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index 82a2b10f..b39db37a 100644 --- a/main.h +++ b/main.h @@ -104,6 +104,7 @@ FILE * file1; short int buffer[2336400]; // max size for 10 frames count of BPSK FILE *sopen(const char *program); FILE *telem_file; +long int sequence = 0; #define S_RATE (48000) // (44100) From d4161f28d4e55387109c86505ae2bb1e910bbbea Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:05:15 -0500 Subject: [PATCH 06/26] Update main.c revert --- main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index 4fee5847..e64630ed 100644 --- a/main.c +++ b/main.c @@ -56,7 +56,7 @@ int main(int argc, char * argv[]) { // program_radio(); // do in transmit instead if (uptime_sec < 30.0) { - reset_count = (reset_count + 1) % ff; // only increment uptime if just rebooted + reset_count = (reset_count + 1) % 0xffff; // only increment uptime if just rebooted fprintf(stderr,"INFO: Reset Count: %d Uptime since Reset: %ld \n", reset_count, uptime_sec); } @@ -1343,12 +1343,12 @@ void get_tlm_fox() { 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) & ); + 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) & ); - h[4] = (short int) ((uptime >> 13) & ); + 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)); @@ -1596,12 +1596,12 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = ff; - encodeA(b, 64 + head_offset, & val); + 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, 62 + head_offset, 0x01); - encodeB(b, 74 + head_offset, f); + encodeB(b, 74 + head_offset, 0xfff); } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; @@ -1989,7 +1989,7 @@ void write_wave(int i, short int *buffer) int encodeA(short int *b, int index, int val) { // printf("Encoding A\n"); - b[index] = val & ; + b[index] = val & 0xff; b[index + 1] = (short int) ((b[index + 1] & 0xf0) | ((val >> 8) & 0x0f)); return 0; } @@ -1997,7 +1997,7 @@ int encodeA(short int *b, int index, int val) { int encodeB(short int *b, int index, int val) { // printf("Encoding B\n"); b[index] = (short int) ((b[index] & 0x0f) | ((val << 4) & 0xf0)); - b[index + 1] = (val >> 4 ) & ; + b[index + 1] = (val >> 4 ) & 0xff; return 0; } @@ -2305,9 +2305,9 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = (uint8_t) rnd_float(0,255); - source_bytes[50] = 0x00; // Sequence number - source_bytes[51] = 0x00; - source_bytes[52] = 0xFF & sequence++; + source_bytes[50] = 0xff; // Sequence number + source_bytes[51] = 0xff; + source_bytes[52] = 0xff; /**/ printf("\nsource_bytes\n"); for (int i=0; i<256; i++) From 094af3c1a3ff2a7d654204569461229233cf2d4e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:06:35 -0500 Subject: [PATCH 07/26] Update main.c add sequence number --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index e64630ed..9bbec852 100644 --- a/main.c +++ b/main.c @@ -2305,9 +2305,9 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = (uint8_t) rnd_float(0,255); - source_bytes[50] = 0xff; // Sequence number - source_bytes[51] = 0xff; - source_bytes[52] = 0xff; + source_bytes[50] = 0x00; // Sequence number + source_bytes[51] = 0x00; + source_bytes[52] = 0xff & (unsigned long int)sequence; /**/ printf("\nsource_bytes\n"); for (int i=0; i<256; i++) From 0fa446fe638e7e84bb0f55e24c293330a8352193 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:06:55 -0500 Subject: [PATCH 08/26] Update main.c add increment --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 9bbec852..9b996487 100644 --- a/main.c +++ b/main.c @@ -2307,7 +2307,7 @@ void get_tlm_fc() { source_bytes[10] = (uint8_t) rnd_float(0,255); source_bytes[50] = 0x00; // Sequence number source_bytes[51] = 0x00; - source_bytes[52] = 0xff & (unsigned long int)sequence; + source_bytes[52] = 0xff & (unsigned long int)sequence++; /**/ printf("\nsource_bytes\n"); for (int i=0; i<256; i++) From 6eb339da263afa1554158a536e8558acf151d866 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:12:00 -0500 Subject: [PATCH 09/26] Update main.c add sequence offset --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 9b996487..011f91c1 100644 --- a/main.c +++ b/main.c @@ -2305,8 +2305,8 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = (uint8_t) rnd_float(0,255); - source_bytes[50] = 0x00; // Sequence number - source_bytes[51] = 0x00; + source_bytes[50] = 0x02; // Sequence number + source_bytes[51] = 0x01; source_bytes[52] = 0xff & (unsigned long int)sequence++; /**/ printf("\nsource_bytes\n"); From 995a2e5d31592814effe2fb27acaf55fcb2baf62 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:15:28 -0500 Subject: [PATCH 10/26] Update main.c full sequence number --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 011f91c1..4094799e 100644 --- a/main.c +++ b/main.c @@ -2305,8 +2305,8 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = (uint8_t) rnd_float(0,255); - source_bytes[50] = 0x02; // Sequence number - source_bytes[51] = 0x01; + source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16) // Sequence number + source_bytes[51] = 0xff & ((unsigned long int)sequence >> 8) source_bytes[52] = 0xff & (unsigned long int)sequence++; /**/ printf("\nsource_bytes\n"); From aba7ec0ae7145b55c521d762ea94f2573e94bbee Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:17:42 -0500 Subject: [PATCH 11/26] Update main.h test sequence starting at 0x201000 --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index b39db37a..d2c9411b 100644 --- a/main.h +++ b/main.h @@ -104,7 +104,7 @@ FILE * file1; short int buffer[2336400]; // max size for 10 frames count of BPSK FILE *sopen(const char *program); FILE *telem_file; -long int sequence = 0; +long int sequence = 131328; #define S_RATE (48000) // (44100) From 5fdae9491daf8c860a47ef906b2cae0331dfcca1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:19:02 -0500 Subject: [PATCH 12/26] Update main.c missing ; --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 4094799e..5964d3b2 100644 --- a/main.c +++ b/main.c @@ -2305,8 +2305,8 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = (uint8_t) rnd_float(0,255); - source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16) // Sequence number - source_bytes[51] = 0xff & ((unsigned long int)sequence >> 8) + source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number + source_bytes[51] = 0xff & ((unsigned long int)sequence >> 8); source_bytes[52] = 0xff & (unsigned long int)sequence++; /**/ printf("\nsource_bytes\n"); From bb5f3e82713d43b32cc699731ff0435209f370c5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:34:27 -0500 Subject: [PATCH 13/26] Update main.c add bat volt current resets --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 5964d3b2..9eed0416 100644 --- a/main.c +++ b/main.c @@ -2304,7 +2304,12 @@ void get_tlm_fc() { memset(source_bytes, 0x00, sizeof(source_bytes)); source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; - source_bytes[10] = (uint8_t) rnd_float(0,255); + source_bytes[10] = 0xff & ((voltage[map[BAT]] * 1000) >> 8); + source_bytes[11] = 0xff & (voltage[map[BAT]] * 1000); + source_bytes[10] = 0xff & ((current[map[BAT]] * 1000) >> 8); + source_bytes[11] = 0xff & (current[map[BAT]] * 1000); + source_bytes[14] = 0xff & ((unsigned long int)reset_count >> 8); + source_bytes[15] = 0xff & (unsigned long int)reset_count; source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number source_bytes[51] = 0xff & ((unsigned long int)sequence >> 8); source_bytes[52] = 0xff & (unsigned long int)sequence++; From 4214c0a0f9b6158de3390d9c2948d550bcb35185 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:37:48 -0500 Subject: [PATCH 14/26] Update main.c added conversion --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 9eed0416..b8d3afcb 100644 --- a/main.c +++ b/main.c @@ -2304,10 +2304,10 @@ void get_tlm_fc() { memset(source_bytes, 0x00, sizeof(source_bytes)); source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; - source_bytes[10] = 0xff & ((voltage[map[BAT]] * 1000) >> 8); - source_bytes[11] = 0xff & (voltage[map[BAT]] * 1000); - source_bytes[10] = 0xff & ((current[map[BAT]] * 1000) >> 8); - source_bytes[11] = 0xff & (current[map[BAT]] * 1000); + source_bytes[10] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000) >> 8); + source_bytes[11] = 0xff & ((unsigned int)voltage[map[BAT]] * 1000); + source_bytes[10] = 0xff & (((unsigned int)current[map[BAT]] * 1000) >> 8); + source_bytes[11] = 0xff & ((unsigned int)current[map[BAT]] * 1000); source_bytes[14] = 0xff & ((unsigned long int)reset_count >> 8); source_bytes[15] = 0xff & (unsigned long int)reset_count; source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number From ec519a606b6c104bbb72b20ba117acfa362c63fa Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:50:54 -0500 Subject: [PATCH 15/26] Update main.c fix telem --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index b8d3afcb..6d76c8cb 100644 --- a/main.c +++ b/main.c @@ -2305,9 +2305,9 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; source_bytes[10] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000) >> 8); - source_bytes[11] = 0xff & ((unsigned int)voltage[map[BAT]] * 1000); - source_bytes[10] = 0xff & (((unsigned int)current[map[BAT]] * 1000) >> 8); - source_bytes[11] = 0xff & ((unsigned int)current[map[BAT]] * 1000); + source_bytes[11] = 0xff & (unsigned int)(voltage[map[BAT]] * 1000); + source_bytes[10] = 0xff & ((unsigned int)(current[map[BAT]] * 100) >> 8); + source_bytes[11] = 0xff & (unsigned int)(current[map[BAT]] * 100); source_bytes[14] = 0xff & ((unsigned long int)reset_count >> 8); source_bytes[15] = 0xff & (unsigned long int)reset_count; source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number From b268750a33badd943df88f6de07603a44ac55bdd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:54:13 -0500 Subject: [PATCH 16/26] Update main.c print current and voltage --- main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.c b/main.c index 6d76c8cb..2bf6a8f8 100644 --- a/main.c +++ b/main.c @@ -2304,6 +2304,10 @@ void get_tlm_fc() { memset(source_bytes, 0x00, sizeof(source_bytes)); source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; + + print("Volt: %f Int: %d \n", voltage[map[BAT]], (unsigned int)(voltage[map[BAT]] * 1000)); + print("Volt: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 100)); + source_bytes[10] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000) >> 8); source_bytes[11] = 0xff & (unsigned int)(voltage[map[BAT]] * 1000); source_bytes[10] = 0xff & ((unsigned int)(current[map[BAT]] * 100) >> 8); From ffe7fe1d8d2b575c490f24c71a1b23857a2379ca Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 15:54:38 -0500 Subject: [PATCH 17/26] Update main.c printf --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 2bf6a8f8..f7686a7a 100644 --- a/main.c +++ b/main.c @@ -2305,8 +2305,8 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; - print("Volt: %f Int: %d \n", voltage[map[BAT]], (unsigned int)(voltage[map[BAT]] * 1000)); - print("Volt: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 100)); + printf("Volt: %f Int: %d \n", voltage[map[BAT]], (unsigned int)(voltage[map[BAT]] * 1000)); + printf("Volt: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 100)); source_bytes[10] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000) >> 8); source_bytes[11] = 0xff & (unsigned int)(voltage[map[BAT]] * 1000); From df01235fb77ab02166b33ab9b0df9e612a7998b8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:00:15 -0500 Subject: [PATCH 18/26] Update main.c print bat voltage and current --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index f7686a7a..24bc6ca3 100644 --- a/main.c +++ b/main.c @@ -774,7 +774,7 @@ int main(int argc, char * argv[]) { current[map[BAT]] = ((current[map[BAT2]] * voltage[map[BAT2]]) / batt) - 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]]); + 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) { From f311daabf95107b04f06722b8943c8bad7fb301e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:06:39 -0500 Subject: [PATCH 19/26] Update main.c --- main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 24bc6ca3..836e0d53 100644 --- a/main.c +++ b/main.c @@ -2306,14 +2306,14 @@ void get_tlm_fc() { source_bytes[1] = 0b10000010 ; printf("Volt: %f Int: %d \n", voltage[map[BAT]], (unsigned int)(voltage[map[BAT]] * 1000)); - printf("Volt: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 100)); + printf("Amps: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 100)); - source_bytes[10] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000) >> 8); - source_bytes[11] = 0xff & (unsigned int)(voltage[map[BAT]] * 1000); - source_bytes[10] = 0xff & ((unsigned int)(current[map[BAT]] * 100) >> 8); - source_bytes[11] = 0xff & (unsigned int)(current[map[BAT]] * 100); - source_bytes[14] = 0xff & ((unsigned long int)reset_count >> 8); - source_bytes[15] = 0xff & (unsigned long int)reset_count; + source_bytes[10] = 0xff & (((unsigned int)(voltage[map[BAT]] * 1000) >> 8)); + source_bytes[11] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000)); + source_bytes[10] = 0xff & (((unsigned int)(current[map[BAT]] * 100) >> 8)); + source_bytes[11] = 0xff & ((unsigned int)(current[map[BAT]] * 100)); + source_bytes[14] = 0xff & ((unsigned long int)reset_count >> 8)); + source_bytes[15] = 0xff & ((unsigned long int)reset_count); source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number source_bytes[51] = 0xff & ((unsigned long int)sequence >> 8); source_bytes[52] = 0xff & (unsigned long int)sequence++; From 989773974634628fe9521884e9f404cb6e8d5e08 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:07:22 -0500 Subject: [PATCH 20/26] Update main.c --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 836e0d53..e1a5cc93 100644 --- a/main.c +++ b/main.c @@ -2312,7 +2312,7 @@ void get_tlm_fc() { source_bytes[11] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000)); source_bytes[10] = 0xff & (((unsigned int)(current[map[BAT]] * 100) >> 8)); source_bytes[11] = 0xff & ((unsigned int)(current[map[BAT]] * 100)); - source_bytes[14] = 0xff & ((unsigned long int)reset_count >> 8)); + source_bytes[14] = 0xff & (((unsigned long int)reset_count >> 8)); source_bytes[15] = 0xff & ((unsigned long int)reset_count); source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number source_bytes[51] = 0xff & ((unsigned long int)sequence >> 8); From c4a0ae01ff90287acd804bbf0b7cd3313d1f3adf Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:10:11 -0500 Subject: [PATCH 21/26] Update main.c fixed numbering --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index e1a5cc93..ff9464d2 100644 --- a/main.c +++ b/main.c @@ -2310,8 +2310,8 @@ void get_tlm_fc() { source_bytes[10] = 0xff & (((unsigned int)(voltage[map[BAT]] * 1000) >> 8)); source_bytes[11] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000)); - source_bytes[10] = 0xff & (((unsigned int)(current[map[BAT]] * 100) >> 8)); - source_bytes[11] = 0xff & ((unsigned int)(current[map[BAT]] * 100)); + source_bytes[12] = 0xff & (((unsigned int)(current[map[BAT]] * 100) >> 8)); + source_bytes[13] = 0xff & ((unsigned int)(current[map[BAT]] * 100)); source_bytes[14] = 0xff & (((unsigned long int)reset_count >> 8)); source_bytes[15] = 0xff & ((unsigned long int)reset_count); source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number From 4a283318c5f7b4e332094a787e663a397767008c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:28:14 -0500 Subject: [PATCH 22/26] Update main.c fix sim charging current bug --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index ff9464d2..6530d56d 100644 --- a/main.c +++ b/main.c @@ -772,7 +772,8 @@ int main(int argc, char * argv[]) { // float charging = current[map[PLUS_X]] + current[map[MINUS_X]] + current[map[PLUS_Y]] + current[map[MINUS_Y]] + current[map[PLUS_Z]] + current[map[MINUS_Z]]; 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]] = ((current[map[BAT2]] * voltage[map[BAT2]]) / batt) - charging; + current[map[BAT]] = ((rnd_float(158, 171) * rnd_float(5.0, 5.005)) / batt) - 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]]); From 003c3f7f01453e3af83b22546c19bc0284cdaee3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:34:25 -0500 Subject: [PATCH 23/26] Update main.c --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 6530d56d..f6b522c5 100644 --- a/main.c +++ b/main.c @@ -743,7 +743,7 @@ int main(int argc, char * argv[]) { double Yv = eclipse * volts_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2); double Zv = 2.0 * eclipse * volts_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2); - // printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv); + // printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv); current[map[PLUS_X]] = (Xi >= 0) ? Xi : 0; current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi); @@ -759,7 +759,7 @@ int main(int argc, char * argv[]) { 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]]); + 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); From 1c836a2ba6967840f9b4ba28e03cf8fc7027665b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:39:43 -0500 Subject: [PATCH 24/26] Update main.c fix sim current --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index f6b522c5..da373c37 100644 --- a/main.c +++ b/main.c @@ -773,7 +773,7 @@ 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(158, 171) * rnd_float(5.0, 5.005)) / batt) - charging; + current[map[BAT]] = rnd_float(285, 410) - current[map[PLUS_X]] - current[map[MINUS_X]] - current[map[PLUS_Y]] - current[map[MINUS_Y]] - current[map[PLUS_Z]] - current[map[MINUS_Z]]; 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]]); From 3a8169bfcbd5d875e3fc5dea6e81d002db5f52a7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:44:26 -0500 Subject: [PATCH 25/26] Update main.c shift in block --- main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index da373c37..d2f229f2 100644 --- a/main.c +++ b/main.c @@ -2309,12 +2309,12 @@ void get_tlm_fc() { printf("Volt: %f Int: %d \n", voltage[map[BAT]], (unsigned int)(voltage[map[BAT]] * 1000)); printf("Amps: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 100)); - source_bytes[10] = 0xff & (((unsigned int)(voltage[map[BAT]] * 1000) >> 8)); - source_bytes[11] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000)); - source_bytes[12] = 0xff & (((unsigned int)(current[map[BAT]] * 100) >> 8)); - source_bytes[13] = 0xff & ((unsigned int)(current[map[BAT]] * 100)); - source_bytes[14] = 0xff & (((unsigned long int)reset_count >> 8)); - source_bytes[15] = 0xff & ((unsigned long int)reset_count); + source_bytes[9] = 0xff & (((unsigned int)(voltage[map[BAT]] * 1000) >> 8)); + source_bytes[10] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000)); + source_bytes[11] = 0xff & (((unsigned int)(current[map[BAT]] * 100) >> 8)); + source_bytes[12] = 0xff & ((unsigned int)(current[map[BAT]] * 100)); + source_bytes[13] = 0xff & (((unsigned long int)reset_count >> 8)); + source_bytes[14] = 0xff & ((unsigned long int)reset_count); source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number source_bytes[51] = 0xff & ((unsigned long int)sequence >> 8); source_bytes[52] = 0xff & (unsigned long int)sequence++; From c62859adb9c61f9d7855d5db5a67b9faf9c48f91 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jan 2025 16:46:57 -0500 Subject: [PATCH 26/26] Update main.c change to mA --- main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index d2f229f2..d2f46596 100644 --- a/main.c +++ b/main.c @@ -2306,13 +2306,13 @@ void get_tlm_fc() { source_bytes[0] = 0b00000001 ; // 10100000 10000001 01000001 10000001 10000001 source_bytes[1] = 0b10000010 ; - printf("Volt: %f Int: %d \n", voltage[map[BAT]], (unsigned int)(voltage[map[BAT]] * 1000)); - printf("Amps: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 100)); +// printf("Volt: %f Int: %d \n", voltage[map[BAT]], (unsigned int)(voltage[map[BAT]] * 1000)); +// printf("Amps: %f Int: %d \n", current[map[BAT]], (unsigned int)(current[map[BAT]] * 1)); - source_bytes[9] = 0xff & (((unsigned int)(voltage[map[BAT]] * 1000) >> 8)); + source_bytes[9] = 0xff & (((unsigned int)(voltage[map[BAT]] * 1000) >> 8)); // mV source_bytes[10] = 0xff & ((unsigned int)(voltage[map[BAT]] * 1000)); - source_bytes[11] = 0xff & (((unsigned int)(current[map[BAT]] * 100) >> 8)); - source_bytes[12] = 0xff & ((unsigned int)(current[map[BAT]] * 100)); + source_bytes[11] = 0xff & (((unsigned int)(current[map[BAT]] * 1) >> 8)); // mA + source_bytes[12] = 0xff & ((unsigned int)(current[map[BAT]] * 1)); source_bytes[13] = 0xff & (((unsigned long int)reset_count >> 8)); source_bytes[14] = 0xff & ((unsigned long int)reset_count); source_bytes[50] = 0xff & ((unsigned long int)sequence >> 16); // Sequence number