From 8a2444fd29cc82c3d6377ad2f4f7e9767db780b8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 26 Jul 2020 22:44:34 -0400 Subject: [PATCH 1/6] Blink green onLed when low voltage shutdown --- afsk/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 2bb8ba99..6f426555 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -554,6 +554,17 @@ while (loop-- != 0) if ((batteryVoltage > 0) && (batteryVoltage < batteryThreshold)) { fprintf(stderr,"Battery voltage too low: %f V - shutting down!\n", batteryVoltage); + + digitalWrite (onLed, onLedOff); + sleep(1); + digitalWrite (onLed, onLedOn); + sleep(1); + digitalWrite (onLed, onLedOff); + sleep(1); + digitalWrite (onLed, onLedOn); + sleep(1); + digitalWrite (onLed, onLedOff); + popen("sudo shutdown -h now > /dev/null 2>&1", "r"); } From 04bef68b471b184a1f29b1947c967402403c0b45 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 27 Jul 2020 10:41:55 -0400 Subject: [PATCH 2/6] turning off tx LED when low battery shutdown --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 6f426555..b80659f1 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -554,7 +554,7 @@ while (loop-- != 0) if ((batteryVoltage > 0) && (batteryVoltage < batteryThreshold)) { fprintf(stderr,"Battery voltage too low: %f V - shutting down!\n", batteryVoltage); - + digitalWrite (txLed, txLedOff); digitalWrite (onLed, onLedOff); sleep(1); digitalWrite (onLed, onLedOn); From a2015ca412ca9a33792591cf7ced5f5475034426 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 27 Jul 2020 10:55:46 -0400 Subject: [PATCH 3/6] added sleep after shutdown command --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index b80659f1..82835276 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -405,7 +405,7 @@ int main(int argc, char *argv[]) { pinMode (onLed, OUTPUT); digitalWrite (onLed, onLedOn); #ifdef DEBUG_LOGGING - printf("Tx LED On\n"); + printf("Power LED On\n"); #endif // if ((cycle == ON) && !ax5043) // don't cycle modes if using AX5043 @@ -415,8 +415,7 @@ int main(int argc, char *argv[]) { fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg","r"); - - + if (vB4) { sensor[PLUS_X] = config_sensor("/dev/i2c-1", 0x40, 400); @@ -566,7 +565,8 @@ while (loop-- != 0) digitalWrite (onLed, onLedOff); popen("sudo shutdown -h now > /dev/null 2>&1", "r"); - } + sleep(10); + } if (mode == FSK) { bitRate = 200; From 1ea32bbc49c1536810b7b22b35ba2101e45de1e6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 27 Jul 2020 11:14:44 -0400 Subject: [PATCH 4/6] handle case where no battery is plugged into INA219 which reads < 1V --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 82835276..385bfcc7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -550,7 +550,7 @@ while (loop-- != 0) #ifdef DEBUG_LOGGING fprintf(stderr,"INFO: Battery voltage: %f V Battery Threshold %f V\n", batteryVoltage, batteryThreshold); #endif - if ((batteryVoltage > 0) && (batteryVoltage < batteryThreshold)) + if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V { fprintf(stderr,"Battery voltage too low: %f V - shutting down!\n", batteryVoltage); digitalWrite (txLed, txLedOff); From 0aa4e96568a4307a872abe86113a7b470137c9ce Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 27 Jul 2020 15:26:29 -0400 Subject: [PATCH 5/6] don't transmit if no BPF --- rpitx.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpitx.py b/rpitx.py index bbfecbc4..bffb5b20 100644 --- a/rpitx.py +++ b/rpitx.py @@ -27,6 +27,9 @@ os.system("echo 'de " + callsign + "' > id.txt && gen_packets -M 20 id.txt -o mo time.sleep(2) if __name__ == "__main__": + + if (transmit): + print 'Length: ', len(sys.argv) if (len(sys.argv)) > 1: @@ -44,3 +47,5 @@ if __name__ == "__main__": else: print("FSK") os.system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") + else: + print("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.") From 5decbe4af841bdef756e092b95d8a4623cc57c9f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 27 Jul 2020 15:30:13 -0400 Subject: [PATCH 6/6] sleep after no BPF detected --- rpitx.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpitx.py b/rpitx.py index bffb5b20..fc572bfb 100644 --- a/rpitx.py +++ b/rpitx.py @@ -49,3 +49,5 @@ if __name__ == "__main__": os.system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") else: print("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.") + while True: + time.sleep(5)