From 1d814f075a9d8aec5d2b415a55c4b9de3285e0c2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 07:53:36 -0400 Subject: [PATCH 01/24] removed extra char call --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 5f099534..78c506ca 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -217,7 +217,7 @@ int uart_fd; int reset_count = 0; float uptime_sec = 1000; long int uptime = 1000; -char call[5]; +//char call[5]; char sim_yes[10]; int mode = BPSK; // SSTV; From 35b553c3ee004d66a81fc400dd2db27e2f6ebc55 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 08:21:25 -0400 Subject: [PATCH 02/24] added CW telemetry mode --- cubesatsim/cubesatsim.ino | 51 +++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2980ff04..eea89b36 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -160,16 +160,17 @@ void loop() { read_payload(); // encode as digits (APRS or CW mode) or binary (DUV FSK) - if ((mode == BPSK) || (mode == FSK)) - { + if ((mode == BPSK) || (mode == FSK)) { get_tlm_fox(); } - else if (mode == AFSK) - { - send_packet(); - } - else if (mode == SSTV) - { + else if ((mode == AFSK) || (mode == CW)) { + get_tlm_a07(); + if (mode == AFSK) { + send_packet(); + } else if (mode == CW) { + send_cw(); + } + else if (mode == SSTV) { Serial.println("\nSending SSTV image!"); send_sstv("/cam.raw"); Serial.println("\nImage sent!"); @@ -262,11 +263,12 @@ void read_reset_count() { } } -void send_packet() { -// encode telemetry - get_tlm_ao7(); - +void send_packet() { // digitalWrite(LED_BUILTIN, LOW); + + char str[1000]; + strcat(str, payload_str); + set_status(str); Serial.println("Sending APRS packet!"); transmit_on(); @@ -289,6 +291,23 @@ void transmit_on() { Serial.println("No transmit!"); } +void send_cw() { + char de[] = " HI HI DE "; + char telem[1000]; + char space[] = " "; + + Serial.println("Sending CW packet!"); + + strcpy(telem, de); + strcat(telem, callsign); + strcat(telem, space); + strcat(telem, payload_str); + print_string(telem); + Serial.println(strlen(telem)); + + transmit_string(telem); +} + void transmit_off() { digitalWrite(PTT_PIN, HIGH); Serial.println("Transmit off!"); @@ -495,10 +514,10 @@ void get_tlm_ao7() { strcat(str, tlm_str); } // print_string(str); - strcat(str, payload_str); +// strcat(str, payload_str); // print_string(str); // Serial.println(strlen(str)); - set_status(str); +// set_status(str); // } } @@ -2978,6 +2997,7 @@ void process_pushbutton() { pb_value = digitalRead(MAIN_PB_PIN); if ((pb_value == RELEASED) && (release == FALSE)) { Serial.println("PB: Switch to CW"); + new_mode = CW; release = TRUE; } @@ -3075,6 +3095,7 @@ void process_bootsel() { // pb_value = digitalRead(MAIN_PB_PIN); if ((!BOOTSEL) && (release == FALSE)) { Serial.println("BOOTSEL: Switch to CW"); + new_mode = CW; release = TRUE; } @@ -3436,9 +3457,7 @@ void transmit_callsign(char *callsign) { strcat(id, callsign); Serial.print("Transmitting id: "); print_string(id); -// transmit_on(); transmit_string(id); -// transmit_off(); } void transmit_string(char *string) { From 04af7395ffd213bbf46c70ccd553d6c3dbc395b7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 08:30:05 -0400 Subject: [PATCH 03/24] fixed simulate telem --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 78c506ca..4df185ff 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -142,7 +142,7 @@ void transmit_on(); void transmit_off(); void config_telem(); void config_simulated_telem(); -void generate_simualted_telem(); +void generate_simulated_telem(); void process_pushbutton(); void blinkTimes(int blinks); void blink_pin(int pin, int duration); From e75dfe099ba543f9c04d5f303c9b0e77d2203be8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 08:31:16 -0400 Subject: [PATCH 04/24] added missing } --- cubesatsim/cubesatsim.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index eea89b36..0d707bb4 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -164,11 +164,12 @@ void loop() { get_tlm_fox(); } else if ((mode == AFSK) || (mode == CW)) { - get_tlm_a07(); + get_tlm_ao7(); if (mode == AFSK) { send_packet(); } else if (mode == CW) { - send_cw(); + send_cw(); + } } else if (mode == SSTV) { Serial.println("\nSending SSTV image!"); From 0dd5f22c5f6880e9b62997fa457040e586f2d9d5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 08:36:12 -0400 Subject: [PATCH 05/24] added tlm and payload str --- cubesatsim/cubesatsim.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 4df185ff..b0e3425b 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -186,6 +186,8 @@ long time_start; short int buffer[BUFFER_SIZE]; // 50000]; //BUFFER_SIZE]; // ctr is an int // 100000]; // 50000]; // 25000]; // 10240]; // was 2336400]; // max size for 10 frames count of BPSK //short int buffer[(WAV_DATA_LENGTH/8)]; //FILE *sopen(const char *program); +char tlm_str[1000]; +char payload_str[100]; #define S_RATE (200) // (8000) //(48000) // (44100) From 8ffd3e3eeb89b7bc61aab09159779548d4f9b5ee Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 08:41:35 -0400 Subject: [PATCH 06/24] added tlm_str --- cubesatsim/cubesatsim.ino | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0d707bb4..7d981cfe 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -49,8 +49,6 @@ Adafruit_INA219 ina219_2_0x41(0x41); Adafruit_INA219 ina219_2_0x44(0x44); Adafruit_INA219 ina219_2_0x45(0x45); -char payload_str[100]; - WiFiServer server(port); WiFiClient client; @@ -267,7 +265,10 @@ void read_reset_count() { void send_packet() { // digitalWrite(LED_BUILTIN, LOW); - char str[1000]; + char str[1000]; + char header_str[] = "hi hi "; + strcpy(str, header_str); + strcpy(str, tlm_str); strcat(str, payload_str); set_status(str); @@ -277,21 +278,6 @@ void send_packet() { transmit_off(); } -void transmit_on() { - if ((mode == AFSK) || (mode == SSTV)) { - Serial.println("Transmit on!"); - digitalWrite(MAIN_LED_BLUE, HIGH); - digitalWrite(PTT_PIN, LOW); - } - else if (mode == BPSK) { - Serial.println("Transmit on!"); - pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5); - pwm_set_gpio_level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5); - } - else - Serial.println("No transmit!"); -} - void send_cw() { char de[] = " HI HI DE "; char telem[1000]; @@ -302,6 +288,8 @@ void send_cw() { strcpy(telem, de); strcat(telem, callsign); strcat(telem, space); + strcat(telem, tlm_str); + strcat(telem, space); strcat(telem, payload_str); print_string(telem); Serial.println(strlen(telem)); @@ -309,6 +297,21 @@ void send_cw() { transmit_string(telem); } +void transmit_on() { + if ((mode == AFSK) || (mode == SSTV)) { + Serial.println("Transmit on!"); + digitalWrite(MAIN_LED_BLUE, HIGH); + digitalWrite(PTT_PIN, LOW); + } + else if (mode == BPSK) { + Serial.println("Transmit on!"); + pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5); + pwm_set_gpio_level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5); + } + else + Serial.println("No transmit!"); +} + void transmit_off() { digitalWrite(PTT_PIN, HIGH); Serial.println("Transmit off!"); @@ -500,7 +503,6 @@ void get_tlm_ao7() { Serial.println(" "); */ char str[1000]; - char tlm_str[1000]; int channel; char header_str[] = "hi hi "; strcpy(str, header_str); From 955d8db97afa94270f67dc1aaa48f15aee6a7f79 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 09:03:46 -0400 Subject: [PATCH 07/24] prints in CW --- cubesatsim/cubesatsim.ino | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7d981cfe..4594a48b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -505,16 +505,16 @@ void get_tlm_ao7() { char str[1000]; int channel; char header_str[] = "hi hi "; - strcpy(str, header_str); + strcpy(tlm_str, header_str); for (channel = 1; channel < 7; channel++) { - sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ", + sprintf(tlm, "%d%d%d %d%d%d %d%d%d %d%d%d ", channel, upper_digit(tlm[channel][1]), lower_digit(tlm[channel][1]), channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); // printf("%s",tlm_str); - strcat(str, tlm_str); + strcat(tlm_str, str); } // print_string(str); // strcat(str, payload_str); @@ -3464,18 +3464,21 @@ void transmit_callsign(char *callsign) { } void transmit_string(char *string) { - int i = 0; + int j = 0; Serial.println("Transmit on"); digitalWrite(PD_PIN, HIGH); // Enable SR_FRS digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(PTT_PIN, LOW); - while ((string[i] != '\0') && (i < 256)) { - if (string[i] != ' ') - transmit_char(string[i++]); + while ((string[j] != '\0') && (j < 256)) { + Serial.print("j = "); + Serial.println(j); + if (string[j] != ' ') + transmit_char(string[j++]); else { + Serial.println("space between words); sleep((6.0 * (float)morse_timing)/1000.0); - i++; + j++; } } Serial.println("Transmit off"); @@ -3487,12 +3490,14 @@ void transmit_string(char *string) { void transmit_char(char character) { int i = 0; while ((morse_table[(toupper(character) - '0') % 44][i] != 0) && (i < 5)) { + Serial.print("i = "); + Serial.println(i); // Serial.print(morse_table[(toupper(character) - '0') % 44][i]); transmit_cw(morse_freq, morse_table[(toupper(character) - '0') % 44][i++] * morse_timing); sleep((float)(morse_timing)/1000.0); } sleep((float)(morse_timing * 3.0)/1000.0); -// Serial.println(" "); + Serial.println("space between characters"); } From 1b63bb8469121e4846be56a400d3c89d4df024c7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 09:08:44 -0400 Subject: [PATCH 08/24] typo --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4594a48b..7e75ed8e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3476,7 +3476,7 @@ void transmit_string(char *string) { if (string[j] != ' ') transmit_char(string[j++]); else { - Serial.println("space between words); + Serial.println("space between words"); sleep((6.0 * (float)morse_timing)/1000.0); j++; } From c944b051b8515d660247a8934dd35a3eca8098b3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 09:12:22 -0400 Subject: [PATCH 09/24] fixed str --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7e75ed8e..9ff60aae 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -508,13 +508,13 @@ void get_tlm_ao7() { strcpy(tlm_str, header_str); for (channel = 1; channel < 7; channel++) { - sprintf(tlm, "%d%d%d %d%d%d %d%d%d %d%d%d ", + sprintf(str, "%d%d%d %d%d%d %d%d%d %d%d%d ", channel, upper_digit(tlm[channel][1]), lower_digit(tlm[channel][1]), channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); - // printf("%s",tlm_str); - strcat(tlm_str, str); + // printf("%s",str); + strcat(tlm_str, str); } // print_string(str); // strcat(str, payload_str); From ce1bb083420ca01a19ef612eb4dace106f7b01fb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 09:29:19 -0400 Subject: [PATCH 10/24] added extra column in morse table --- cubesatsim/cubesatsim.h | 88 ++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index b0e3425b..38bad8d9 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -312,50 +312,50 @@ bool timer0_on = false; char callsign[20]; int morse_timing = 60; // ms for a dit int morse_freq = 1800; // Hz -int morse_table[44][5] = { // 0-9, A-Z only by (ASCII - 48) - { 3, 3, 3, 3, 3 }, // 0 - { 1, 3, 3, 3, 3 }, // 1 - { 1, 1, 3, 3, 3 }, // 2 - { 1, 1, 1, 3, 3 }, // 3 - { 1, 1, 1, 1, 3 }, // 4 - { 1, 1, 1, 1, 1 }, // 5 - { 3, 1, 1, 1, 1 }, // 6 - { 3, 3, 1, 1, 1 }, // 7 - { 3, 3, 3, 1, 1 }, // 8 - { 3, 3, 3, 3, 1 }, // 9 - { 0, 0, 0, 0, 0 }, // - - { 0, 0, 0, 0, 0 }, // - - { 0, 0, 0, 0, 0 }, // - - { 0, 0, 0, 0, 0 }, // - - { 0, 0, 0, 0, 0 }, // - - { 0, 0, 0, 0, 0 }, // - - { 0, 0, 0, 0, 0 }, // - - { 1, 3, 0, 0, 0 }, // A - { 3, 1, 1, 1, 0 }, // B - { 3, 1, 3, 1, 0 }, // C - { 3, 1, 1, 0, 0 }, // D - { 1, 0, 0, 0, 0 }, // E - { 1, 1, 3, 1, 0 }, // F - { 3, 3, 1, 0, 0 }, // G - { 1, 1, 1, 1, 0 }, // H - { 1, 1, 0, 0, 0 }, // I - { 1, 3, 3, 3, 0 }, // J - { 3, 1, 3, 0, 0 }, // K - { 1, 3, 1, 1, 0 }, // L - { 3, 3, 0, 0, 0 }, // M - { 3, 1, 0, 0, 0 }, // N - { 3, 3, 3, 0, 0 }, // O - { 1, 3, 3, 1, 0 }, // P - { 3, 3, 1, 3, 0 }, // Q - { 1, 3, 1, 0, 0 }, // R - { 1, 1, 1, 0, 0 }, // S - { 3, 0, 0, 0, 0 }, // T - { 1, 1, 3, 0, 0 }, // U - { 1, 1, 1, 3, 0 }, // V - { 1, 3, 3, 0, 0 }, // W - { 3, 1, 1, 3, 0 }, // X - { 3, 1, 3, 3, 0 }, // Y - { 3, 3, 1, 1, 0 } // Z +int morse_table[44][6] = { // 0-9, A-Z only by (ASCII - 48) + { 3, 3, 3, 3, 3, 0 }, // 0 + { 1, 3, 3, 3, 3, 0 }, // 1 + { 1, 1, 3, 3, 3, 0 }, // 2 + { 1, 1, 1, 3, 3, 0 }, // 3 + { 1, 1, 1, 1, 3, 0 }, // 4 + { 1, 1, 1, 1, 1, 0 }, // 5 + { 3, 1, 1, 1, 1, 0 }, // 6 + { 3, 3, 1, 1, 1, 0 }, // 7 + { 3, 3, 3, 1, 1, 0 }, // 8 + { 3, 3, 3, 3, 1, 0 }, // 9 + { 0, 0, 0, 0, 0, 0 }, // - + { 0, 0, 0, 0, 0, 0 }, // - + { 0, 0, 0, 0, 0, 0 }, // - + { 0, 0, 0, 0, 0, 0 }, // - + { 0, 0, 0, 0, 0, 0 }, // - + { 0, 0, 0, 0, 0, 0 }, // - + { 0, 0, 0, 0, 0, 0 }, // - + { 1, 3, 0, 0, 0, 0 }, // A + { 3, 1, 1, 1, 0, 0 }, // B + { 3, 1, 3, 1, 0, 0 }, // C + { 3, 1, 1, 0, 0, 0 }, // D + { 1, 0, 0, 0, 0, 0 }, // E + { 1, 1, 3, 1, 0, 0 }, // F + { 3, 3, 1, 0, 0, 0 }, // G + { 1, 1, 1, 1, 0, 0 }, // H + { 1, 1, 0, 0, 0, 0 }, // I + { 1, 3, 3, 3, 0, 0 }, // J + { 3, 1, 3, 0, 0, 0 }, // K + { 1, 3, 1, 1, 0, 0 }, // L + { 3, 3, 0, 0, 0, 0 }, // M + { 3, 1, 0, 0, 0, 0 }, // N + { 3, 3, 3, 0, 0, 0 }, // O + { 1, 3, 3, 1, 0, 0 }, // P + { 3, 3, 1, 3, 0, 0 }, // Q + { 1, 3, 1, 0, 0, 0 }, // R + { 1, 1, 1, 0, 0, 0 }, // S + { 3, 0, 0, 0, 0, 0 }, // T + { 1, 1, 3, 0, 0, 0 }, // U + { 1, 1, 1, 3, 0, 0 }, // V + { 1, 3, 3, 0, 0, 0 }, // W + { 3, 1, 1, 3, 0, 0 }, // X + { 3, 1, 3, 3, 0, 0 }, // Y + { 3, 3, 1, 1, 0, 0 } // Z }; From 8ea74740ccb46b27363cd5aa63839a595c1dd9f1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 09:30:58 -0400 Subject: [PATCH 11/24] removed i < 5 since it didn't work --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9ff60aae..5b438366 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3489,7 +3489,7 @@ void transmit_string(char *string) { void transmit_char(char character) { int i = 0; - while ((morse_table[(toupper(character) - '0') % 44][i] != 0) && (i < 5)) { + while (morse_table[(toupper(character) - '0') % 44][i] != 0) { Serial.print("i = "); Serial.println(i); // Serial.print(morse_table[(toupper(character) - '0') % 44][i]); From ec800855567c48b60799aee5bc357b581bc12627 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 09:39:56 -0400 Subject: [PATCH 12/24] don't transmit callsign if CW mode --- cubesatsim/cubesatsim.ino | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5b438366..89cf06eb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -131,7 +131,8 @@ void setup() { /**/ Serial.println("Transmitting callsign"); strcpy(callsign, call); - transmit_callsign(callsign); + if (mode != CW) + transmit_callsign(callsign); sleep(5.0); /**/ @@ -203,7 +204,8 @@ void loop() { Serial.println("Changing mode"); mode = new_mode; // change modes if button pressed - transmit_callsign(callsign); + if (new_mode != CW) + transmit_callsign(callsign); sleep(0.5); config_telem(); config_radio(); @@ -3471,12 +3473,12 @@ void transmit_string(char *string) { digitalWrite(PTT_PIN, LOW); while ((string[j] != '\0') && (j < 256)) { - Serial.print("j = "); - Serial.println(j); +// Serial.print("j = "); +// Serial.println(j); if (string[j] != ' ') transmit_char(string[j++]); else { - Serial.println("space between words"); +// Serial.println("space between words"); sleep((6.0 * (float)morse_timing)/1000.0); j++; } @@ -3490,14 +3492,14 @@ void transmit_string(char *string) { void transmit_char(char character) { int i = 0; while (morse_table[(toupper(character) - '0') % 44][i] != 0) { - Serial.print("i = "); - Serial.println(i); +// Serial.print("i = "); +// Serial.println(i); // Serial.print(morse_table[(toupper(character) - '0') % 44][i]); transmit_cw(morse_freq, morse_table[(toupper(character) - '0') % 44][i++] * morse_timing); sleep((float)(morse_timing)/1000.0); } sleep((float)(morse_timing * 3.0)/1000.0); - Serial.println("space between characters"); +// Serial.println("space between characters"); } From 45595d2f9e98faefa60f6fce5e47d0a013c24565 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 09:46:11 -0400 Subject: [PATCH 13/24] don't send hi hi first in CW, don't send payload --- cubesatsim/cubesatsim.ino | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 89cf06eb..35ea322d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -281,7 +281,7 @@ void send_packet() { } void send_cw() { - char de[] = " HI HI DE "; + char de[] = " DE "; char telem[1000]; char space[] = " "; @@ -290,9 +290,7 @@ void send_cw() { strcpy(telem, de); strcat(telem, callsign); strcat(telem, space); - strcat(telem, tlm_str); - strcat(telem, space); - strcat(telem, payload_str); + strcat(telem, tlm_str); // don't send payload since it isn't encoded and has "." print_string(telem); Serial.println(strlen(telem)); From 0c90935597f3ea578f7a153a39e1e2ebec0c2ce5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 10:57:35 -0400 Subject: [PATCH 14/24] added cw_stop to exit CW mode --- cubesatsim/cubesatsim.ino | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 35ea322d..c87581c2 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -298,16 +298,20 @@ void send_cw() { } void transmit_on() { - if ((mode == AFSK) || (mode == SSTV)) { + if (mode == SSTV) { Serial.println("Transmit on!"); digitalWrite(MAIN_LED_BLUE, HIGH); - digitalWrite(PTT_PIN, LOW); - } + digitalWrite(PTT_PIN, LOW); + } else if (mode == BPSK) { Serial.println("Transmit on!"); pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5); pwm_set_gpio_level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5); } + else if (mode == CW) { + // Serial.println("Transmit on!"); + cw_stop = false; + } else Serial.println("No transmit!"); } @@ -321,8 +325,10 @@ void transmit_off() { pwm_set_gpio_level(BPSK_PWM_A_PIN, 0); pwm_set_gpio_level(BPSK_PWM_B_PIN, 0); } - if (mode == SSTV) + else if (mode == SSTV) sstv_end(); + else if (mode == CW) + cw_stop = true; } void config_telem() { @@ -3470,7 +3476,7 @@ void transmit_string(char *string) { digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(PTT_PIN, LOW); - while ((string[j] != '\0') && (j < 256)) { + while ((string[j] != '\0') && (j < 256) && !cw_stop) { // Serial.print("j = "); // Serial.println(j); if (string[j] != ' ') From f035fc1835b4d6d5cceaeca1b74224c0b60eedc8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 10:57:48 -0400 Subject: [PATCH 15/24] added cw_stop to exit CW mode --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 38bad8d9..86c50494 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -295,6 +295,7 @@ int sample_rate; int buffer_size; long micro_timer; int ready = FALSE; +bool cw_stop = false; #define PRESSED 0 #define HELD 0 From 44347ba3a270533a47973e1c02a7427a773f7896 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 7 Aug 2022 11:11:15 -0400 Subject: [PATCH 16/24] put transmit_on back on for APRS --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c87581c2..b5fb3d8d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -298,7 +298,7 @@ void send_cw() { } void transmit_on() { - if (mode == SSTV) { + if ((mode == SSTV) || (mode == AFSK)) { // this isn't quite right for APRS - should only do when sending APRS packet Serial.println("Transmit on!"); digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(PTT_PIN, LOW); From 46e8523752b41bb012870db45aaa2f970c850800 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 09:52:34 -0400 Subject: [PATCH 17/24] CW fixes to make input work reliably --- cubesatsim/cubesatsim.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8d15678a..c27a5e22 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2947,9 +2947,9 @@ void sleep(float time) { // sleeps for intervals more than 0.1 seconds } */ -void sleep(float time) { // sleeps for intervals more than 0.01 milli seconds +void sleep(float timer) { // sleeps for intervals more than 0.01 milli seconds - unsigned long time_us = (unsigned long)(time * 1000000.0); + unsigned long time_us = (unsigned long)(timer * 1000000.0); unsigned long startSleep = micros(); while ((micros() - startSleep) < time_us) { // busy_wait_us(100); @@ -3475,7 +3475,8 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise while((micros() - start) < duration_us) { digitalWrite(AUDIO_OUT_PIN, phase); // ToDo: if no TXC, just turn on PWM carrier phase = !phase; - sleep(min(start + duration_us - micros(), period_us) / 1.0E6); + float time_left = (float)(start + duration_us - micros()); + sleep(min(time_left, period_us) / 1.0E6); } digitalWrite(AUDIO_OUT_PIN, LOW); } From 3e22efaf534d689e5347dfd6671ddce6326445d7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 10:06:08 -0400 Subject: [PATCH 18/24] added extra prompt values --- cubesatsim/cubesatsim.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 28ca40ac..dfeb7f59 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -109,6 +109,9 @@ #define PROMPT_LAT 3 #define PROMPT_RESET 4 #define PROMPT_QUERY 5 +#define PROMPT_HELP 6 +#define PROMPT_RESTART 7 + volatile int prompt = false; char serial_string[128]; From c74ce72f88657f9980e546fd67aa41b22f035ae6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 10:22:04 -0400 Subject: [PATCH 19/24] moved help out of isr --- cubesatsim/cubesatsim.ino | 78 +++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c27a5e22..fbca76e4 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3626,6 +3626,9 @@ void serial_input() { switch(result) { case 'h': case 'H': + Serial.println("Help"); + prompt = PROMPT_HELP; + /* Serial.println("\nChange settings by typing the letter:"); Serial.println("h Help info"); Serial.println("a AFSK/APRS mode"); @@ -3638,7 +3641,8 @@ void serial_input() { Serial.println("t Simulated Telemetry"); Serial.println("r Resets Count, or payload & EEPROM"); Serial.println("l Lat and Long"); - Serial.println("? Query sensors\n"); + Serial.println("? Query sensors\n"); +*/ break; case 'a': @@ -3671,30 +3675,31 @@ void serial_input() { case 'i': case 'I': - Serial.println("Restarts CubeSatsim software"); + Serial.println("Restart CubeSatsim software"); + prompt = PROMPT_RESTART; break; case 'c': case 'C': - Serial.println("Change the CALLSIGN in the configuration file sim.cfg"); + Serial.println("Change the CALLSIGN"); prompt = PROMPT_CALLSIGN; break; case 't': case 'T': - Serial.println("Change the Simulated Telemetry setting in sim.cfg"); + Serial.println("Change the Simulated Telemetry"); + prompt = PROMPT_SIM; break; case 'r': case 'R': - Serial.println("Change the Resets Count in the configuration file sim.cfg, or "); - Serial.println("Reset payload and stored EEPROM values"); + Serial.println("Change the Resets Count or Reset payload and stored EEPROM values"); prompt = PROMPT_RESET; break; case 'l': case 'L': - Serial.println("Change the Latitude and Longitude in the configuration file sim.cfg"); + Serial.println("Change the Latitude and Longitude"); prompt = PROMPT_LAT; break; @@ -3722,7 +3727,23 @@ void prompt_for_input() { Serial.read(); switch(prompt) { - + + case PROMPT_HELP: + Serial.println("\nChange settings by typing the letter:"); + Serial.println("h Help info"); + Serial.println("a AFSK/APRS mode"); + Serial.println("c CW mode"); + Serial.println("f FSK/DUV mode"); + Serial.println("b BPSK mode"); + Serial.println("s SSTV mode"); + Serial.println("i Restart"); + Serial.println("c CALLSIGN"); + Serial.println("t Simulated Telemetry"); + Serial.println("r Resets Count, or payload & EEPROM"); + Serial.println("l Lat and Long"); + Serial.println("? Query sensors\n"); + break; + case PROMPT_CALLSIGN: Serial.println("Editing the CALLSIGN in the onfiguration file for CubeSatSim"); Serial.println("Return keeps current value."); @@ -3739,43 +3760,7 @@ void prompt_for_input() { Serial.println("Callsign updated!"); } else Serial.println("Callsign not updated!"); -/* - echo - echo "Editing the CALLSIGN in the" - echo "configuration file for CubeSatSim" - echo - echo "Return keeps current value." -# echo -e "Current sim.cfg configuration file:" -# echo - - value=`cat /home/pi/CubeSatSim/sim.cfg` - echo "$value" > /dev/null - set -- $value - - echo "Current value of CALLSIGN is" - echo $1 - echo - -# echo $1 $2 $3 $4 $5 - - echo "Enter callsign in all capitals: " - read callsign - - if [ -z $callsign ] ; then - - callsign="$1" - echo "Keeping value of" $callsign - norestart=1 - else - - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - - echo $callsign $2 $3 $4 $5 - echo $callsign $2 $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg - fi - -*/ break; case PROMPT_SIM: @@ -3793,7 +3778,10 @@ void prompt_for_input() { case PROMPT_RESET: break; - } + + case PROMPT_RESTART: + Serial.println("Restart not yet implemented"); + break; } } From bf9667206501e22abb2812fecfe7ad65238323de Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 10:36:02 -0400 Subject: [PATCH 20/24] set callsign in APRS and rename send_packet to send_aprs_packet --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fbca76e4..e4c6ce81 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -174,7 +174,7 @@ void loop() { } else if (mode == AFSK) { - send_packet(); + send_aprs_packet(); } else if (mode == SSTV) { @@ -309,7 +309,7 @@ void read_reset_count() { } } -void send_packet() { +void send_aprs_packet() { // encode telemetry get_tlm_ao7(); @@ -441,7 +441,7 @@ void config_telem() { set_pin(AUDIO_OUT_PIN); - char callsign[] = "W3ZM"; +// char callsign[] = "W3ZM"; set_callsign(callsign); char lat_default[] = "0610.55S"; char lon_default[] = "10649.62E"; From 8af6434f19850c86308dd61a7d6ee3ce64c3421d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 10:36:30 -0400 Subject: [PATCH 21/24] changed send_packet to send_aprs_packet --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index dfeb7f59..9a0516d5 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -141,7 +141,7 @@ void write_little_endian(unsigned int word, int num_bytes, FILE *wav_file); static int init_rf(); void test_radio(); void config_radio(); -void send_packet(); +void send_aprs_packet(); void read_ina219(); void read_sensors(); void get_tlm_ao7(); From e90129c802d0501950111d4081ec03728333e6b1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 10:55:25 -0400 Subject: [PATCH 22/24] set callsign immediately if in APRS mode --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8a182c0f..5f287d23 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3792,6 +3792,8 @@ void prompt_for_input() { if (strlen(serial_string) > 0) { strcpy(callsign, serial_string); + if (mode == APRS) + set_callsign(callsign); Serial.println("Callsign updated!"); } else Serial.println("Callsign not updated!"); From 2aa19f51049d8711d519b17c8449d1f416d925c3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 10:56:16 -0400 Subject: [PATCH 23/24] AFSK TYPO --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5f287d23..7ec3884c 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3792,7 +3792,7 @@ void prompt_for_input() { if (strlen(serial_string) > 0) { strcpy(callsign, serial_string); - if (mode == APRS) + if (mode == AFSK) set_callsign(callsign); Serial.println("Callsign updated!"); } else From 4a94d0b83c4228d8f74949c76fb81d5031da5b31 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 19 Aug 2022 10:58:58 -0400 Subject: [PATCH 24/24] added CW mode change in serial input --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7ec3884c..d390ae49 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3689,6 +3689,7 @@ void serial_input() { case 'm': case 'M': Serial.println("Change to CW mode"); + new_mode = CW; break; case 'f':