diff --git a/config b/config index 2f5bdeb7..10d038ed 100755 --- a/config +++ b/config @@ -350,7 +350,7 @@ if [ "$1" = "" ]; then elif [ "$1" = "-i" ]; then - reboot=1 + restart=1 elif [ "$1" = "-a" ]; then @@ -807,8 +807,9 @@ elif [ "$1" = "-d" ]; then # reboot=1 sudo systemctl restart command if [[ $(arecord -l | grep card) ]]; then - echo "restarting cubesatsim software" - sudo systemctl restart cubesatsim + restart=1 +### echo "restarting cubesatsim software" +### sudo systemctl restart cubesatsim fi ## sudo reboot now fi diff --git a/main.c b/main.c index bf7c185c..77b9afa4 100644 --- a/main.c +++ b/main.c @@ -25,59 +25,6 @@ int main(int argc, char * argv[]) { - FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r"); - if (command_file == NULL) { - fprintf(stderr,"Command and control is OFF\n"); - c2cStatus = 0; - } else { - command_file = fopen("/home/pi/CubeSatSim/command_control_direwolf", "r"); - if (command_file == NULL) { - fprintf(stderr,"Command and control Carrier (squelch) is ON\n"); - c2cStatus = 1; - } else - fprintf(stderr,"Command and control DTMF or APRS is ON\n"); - c2cStatus = 2; - } - char resbuffer[1000]; -// const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//' | grep '9000'"; - const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//'"; - FILE *file_test = sopen(testStr); // see if Pi Zero 2 - fgets(resbuffer, 1000, file_test); - fprintf(stderr, "Pi test result: %s\n", resbuffer); - fclose(file_test); - - FILE * uptime_file = fopen("/proc/uptime", "r"); - fscanf(uptime_file, "%f", & uptime_sec); - printf("Uptime sec: %f \n", uptime_sec); - fclose(uptime_file); - - fprintf(stderr, " %x ", resbuffer[0]); - fprintf(stderr, " %x \n", resbuffer[1]); - if ((resbuffer[0] != '9') || (resbuffer[1] != '0') || (resbuffer[2] != '0') || (resbuffer[3] != '0')) - { - // voltageThreshold = 3.7; - fprintf(stderr, "Pi Zero not detected (could be Pi Zero 2)\n"); - pi_zero_2_offset = 500; - if (uptime_sec < 30.0) { - FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); - pclose(rpitx_stop); - fprintf(stderr, "Sleep 5 sec"); - sleep(5); // try sleep at start to help boot - } - } - else { - fprintf(stderr,"Pi Zero detected\n"); - if ((c2cStatus == 0) || (c2cStatus == 1)) { - pi_zero_2_offset = 500; - } - if (uptime_sec < 30.0) { - FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); - pclose(rpitx_stop); - fprintf(stderr,"Sleep 10 sec"); - sleep(10); - } - } - printf("\n\nCubeSatSim v1.3.2 starting...\n\n"); wiringPiSetup(); @@ -131,6 +78,62 @@ int main(int argc, char * argv[]) { if (strcmp(hab_yes, "yes") == 0) { hab_mode = TRUE; fprintf(stderr, "HAB mode is ON\n"); + } + + FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r"); + if (command_file == NULL) { + fprintf(stderr,"Command and control is OFF\n"); + c2cStatus = 0; + } else { + command_file = fopen("/home/pi/CubeSatSim/command_control_direwolf", "r"); + if (command_file == NULL) { + fprintf(stderr,"Command and control Carrier (squelch) is ON\n"); + c2cStatus = 1; + } else { + fprintf(stderr,"Command and control DTMF or APRS is ON\n"); + c2cStatus = 2; + } + } + printf("c2cStatus: %d \n", c2cStatus); + + char resbuffer[1000]; +// const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//' | grep '9000'"; + const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//'"; + FILE *file_test = sopen(testStr); // see if Pi Zero 2 + fgets(resbuffer, 1000, file_test); + fprintf(stderr, "Pi test result: %s\n", resbuffer); + fclose(file_test); + + FILE * uptime_file = fopen("/proc/uptime", "r"); + fscanf(uptime_file, "%f", & uptime_sec); + printf("Uptime sec: %f \n", uptime_sec); + fclose(uptime_file); + + fprintf(stderr, " %x ", resbuffer[0]); + fprintf(stderr, " %x \n", resbuffer[1]); + if ((resbuffer[0] != '9') || (resbuffer[1] != '0') || (resbuffer[2] != '0') || (resbuffer[3] != '0')) + { + // voltageThreshold = 3.7; + fprintf(stderr, "Pi Zero not detected (could be Pi Zero 2)\n"); + pi_zero_2_offset = 500; + if (uptime_sec < 30.0) { + FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); + pclose(rpitx_stop); + fprintf(stderr, "Sleep 5 sec"); + sleep(5); // try sleep at start to help boot + } + } + else { + fprintf(stderr,"Pi Zero detected\n"); + if ((c2cStatus == 0) || (c2cStatus == 1)) { + pi_zero_2_offset = 500; + } + if (uptime_sec < 30.0) { + FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); + pclose(rpitx_stop); + fprintf(stderr,"Sleep 10 sec"); + sleep(10); + } } // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); @@ -1565,6 +1568,28 @@ void get_tlm_fox() { (i2c_bus0 == OFF) * 16 + (i2c_bus1 == OFF) * 32 + (i2c_bus3 == OFF) * 64 + (camera == OFF) * 128 + groundCommandCount * 256; encodeA(b, 51 + head_offset, status); + + FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r"); + if (command_file == NULL) { + if (c2cStatus != 0) { + fprintf(stderr,"Command and control is OFF\n"); + c2cStatus = 0; + } + } else { + command_file = fopen("/home/pi/CubeSatSim/command_control_direwolf", "r"); + if (command_file == NULL) { + if (c2cStatus != 1) { + fprintf(stderr,"Command and control Carrier (squelch) is ON\n"); + c2cStatus = 1; + } + } else { + if (c2cStatus != 2) { + fprintf(stderr,"Command and control DTMF or APRS is ON\n"); + c2cStatus = 2; + } + } + } + // printf("c2cStatus: %d \n", c2cStatus); encodeB(b, 52 + head_offset, rxAntennaDeployed + txAntennaDeployed * 2 + c2cStatus * 4); if (txAntennaDeployed == 0) { diff --git a/rpitx.py b/rpitx.py index 47b98d35..8c079e7a 100644 --- a/rpitx.py +++ b/rpitx.py @@ -363,7 +363,8 @@ if __name__ == "__main__": # ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n") ser.write(uhf_string.encode()) sleep(0.1) - ser.close() + ser.close() + ser = serial.Serial("/dev/ttyAMA0", 115200) # reset back to 115200 for cubesatsim code for payload sensor data except: print("Error in serial write") output(pd, 0) diff --git a/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_maxtelemetry.csv b/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_maxtelemetry.csv index 49526e8b..5e421492 100644 --- a/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_maxtelemetry.csv +++ b/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_maxtelemetry.csv @@ -44,7 +44,7 @@ 42,MAX,GroundCommands,4,-,1,NONE,3,3,0,Ground Commands,Number of ground commands received 43,MAX,RxAntenna,1,-,16,NONE,1,3,0,RX Antenna,Receive antenna status 44,MAX,TxAntenna,1,-,16,NONE,1,2,0,TX Antenna,Transmit antenna status -45,MAX,C2CStatus,1,-,STATUS_ON_OFF,NONE,3,5,0,Command Control, Command & Control Status +45,MAX,C2CStatus,2,-,COMMAND_STATUS,NONE,3,5,0,Command Control, Command & Control Status 46,MAX,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted 47,MAX,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V 48,MAX,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected @@ -59,4 +59,4 @@ 57,MAX,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information 58,MAX,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset 59,MAX,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset -60,MAX,pad2,28,-,0,NONE,0,0,0,NONE,Filler +60,MAX,pad2,27,-,0,NONE,0,0,0,NONE,Filler diff --git a/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_mintelemetry.csv b/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_mintelemetry.csv index 8b06f27c..97dcaa4b 100644 --- a/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_mintelemetry.csv +++ b/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_mintelemetry.csv @@ -44,7 +44,7 @@ 42,MIN,GroundCommands,4,-,1,NONE,3,3,0,Ground Commands,Number of ground commands received 43,MIN,RxAntenna,1,-,16,NONE,1,3,0,RX Antenna,Receive antenna status 44,MIN,TxAntenna,1,-,16,NONE,1,2,0,TX Antenna,Transmit antenna status -45,MIN,C2CStatus,1,-,STATUS_ON_OFF,NONE,3,5,0,Command Control, Command & Control Status +45,MIN,C2CStatus,2,-,COMMAND_STATUS,NONE,3,5,0,Command Control, Command & Control Status 46,MIN,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted 47,MIN,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V 48,MIN,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected @@ -59,4 +59,4 @@ 57,MIN,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information 58,MIN,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset 59,MIN,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset -60,MIN,pad2,28,-,0,NONE,0,0,0,NONE,Filler +60,MIN,pad2,27,-,0,NONE,0,0,0,NONE,Filler diff --git a/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_rttelemetry.csv b/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_rttelemetry.csv index b751bacd..17ef4ab6 100644 --- a/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13e/CubeSatSim_PSK_rttelemetry.csv @@ -44,7 +44,7 @@ 42,realTime,GroundCommands,4,-,1,Computer Software,3,3,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,1,-,STATUS_ON_OFF,Computer Software,3,5,0,Command Control, Command & Control 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 @@ -59,4 +59,4 @@ 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,28,-,0,NONE,0,0,0,NONE,Filler +60,realTime,pad2,27,-,0,NONE,0,0,0,NONE,Filler diff --git a/spacecraft/FoxTelem_1.13e/CubeSatSim_maxtelemetry.csv b/spacecraft/FoxTelem_1.13e/CubeSatSim_maxtelemetry.csv index 10e0e4d6..c442b89d 100644 --- a/spacecraft/FoxTelem_1.13e/CubeSatSim_maxtelemetry.csv +++ b/spacecraft/FoxTelem_1.13e/CubeSatSim_maxtelemetry.csv @@ -44,5 +44,5 @@ 42,MAX,GroundCommands,4,-,1,NONE,3,3,0,Ground Commands,Number of ground commands received 43,MAX,RXAntenna,1,-,16,NONE,1,3,0,RX Antenna,Receive antenna status 44,MAX,TXAntenna,1,-,16,NONE,1,2,0,TX Antenna,Transmit antenna status -45,MAX,C2CStatus,1,-,STATUS_ON_OFF,NONE,3,5,0,Command Control, Command & Control Status -46,MAX,Pad,57,-,0,NONE,0,0,0,NONE,NONE +45,MAX,C2CStatus,2,-,COMMAND_STATUS,NONE,3,5,0,Command Control, Command & Control Status +46,MAX,Pad,56,-,0,NONE,0,0,0,NONE,NONE diff --git a/spacecraft/FoxTelem_1.13e/CubeSatSim_mintelemetry.csv b/spacecraft/FoxTelem_1.13e/CubeSatSim_mintelemetry.csv index 3941d7a8..eefa1e48 100644 --- a/spacecraft/FoxTelem_1.13e/CubeSatSim_mintelemetry.csv +++ b/spacecraft/FoxTelem_1.13e/CubeSatSim_mintelemetry.csv @@ -44,5 +44,5 @@ 42,MIN,GroundCommands,4,-,1,NONE,3,3,0,Ground Commands,Number of ground commands received 43,MIN,RXAntenna,1,-,16,NONE,1,3,0,RX Antenna,Receive antenna status 44,MIN,TXAntenna,1,-,16,NONE,1,2,0,TX Antenna,Transmit antenna status -45,MIN,C2CStatus,1,-,STATUS_ON_OFF,NONE,3,5,0,Command Control, Command & Control Status -46,MIN,Pad,57,-,0,NONE,0,0,0,NONE,NONE +45,MIN,C2CStatus,2,-,COMMAND_STATUS,NONE,3,5,0,Command Control, Command & Control Status +46,MIN,Pad,56,-,0,NONE,0,0,0,NONE,NONE diff --git a/spacecraft/FoxTelem_1.13e/CubeSatSim_rttelemetry.csv b/spacecraft/FoxTelem_1.13e/CubeSatSim_rttelemetry.csv index 7b66db49..14389ff1 100644 --- a/spacecraft/FoxTelem_1.13e/CubeSatSim_rttelemetry.csv +++ b/spacecraft/FoxTelem_1.13e/CubeSatSim_rttelemetry.csv @@ -44,5 +44,5 @@ 42,RT,GroundCommands,4,-,1,Computer Software,3,3,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,1,-,COMMAND_STATUS,Computer Software,3,5,0,Command Control, Command & Control Status -46,RT,Pad,57,-,0,NONE,0,0,0,NONE,NONE +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 diff --git a/spacecraft/FoxTelem_1.13e/CubeSat_Simulator_PSK.MASTER b/spacecraft/FoxTelem_1.13e/CubeSat_Simulator_PSK.MASTER new file mode 100644 index 00000000..56c22e88 --- /dev/null +++ b/spacecraft/FoxTelem_1.13e/CubeSat_Simulator_PSK.MASTER @@ -0,0 +1,77 @@ +#Fox 1 Telemetry Decoder Properties +#Thu Apr 11 13:23:23 EST 2020 +user_mode=4 +foxId=99 +IHU_SN=7 +catalogNumber=0 +model=0 +mpptResistanceError=6.58 +mpptSensorOffThreshold=1600 +name=CubeSatSim +displayName=CubeSatSim-BPSK +BATTERY_CURRENT_ZERO=-1.834 +hasImprovedCommandReceiver=true +EXP1=0 +EXP2=0 +EXP3=0 +EXP4=0 +description=CubeSatSim, the AMSAT CubeSat Simulator, is a functional satellite model that generates real telemetry from solar panels, batteries, and temperature sensors. Use this for BPSK telemetry. For more information see http://cubesatsim.org +numberOfFrameLayouts=5 +frameLayout0.filename=FOX1E_Type0_ALL_WOD.frame +frameLayout0.name=All WOD +frameLayout1.filename=CubeSatSim_PSK_Type1_HEALTH.frame +frameLayout1.name=Health +frameLayout2.filename=CubeSatSim_PSK_Type2_MINMAX.frame +frameLayout2.name=MinMax +frameLayout3.filename=FOX1E_Type3_REALTIME_BEACON.frame +frameLayout3.name=Realtime Beacon +frameLayout4.filename=FOX1E_Type4_WOD_BEACON.frame +frameLayout4.name=WOD Beacon +numberOfLayouts=9 +layout0.filename=FOX1A_debug.csv +layout0.name=DEBUG +layout1.filename=CubeSatSim_PSK_maxtelemetry.csv +layout1.name=maxtelemetry +layout2.filename=CubeSatSim_PSK_rttelemetry.csv +layout2.name=rttelemetry +layout3.filename=CubeSatSim_PSK_mintelemetry.csv +layout3.name=mintelemetry +layout4.filename=FOX1E_radtelemetry.csv +layout4.name=radtelemetry +layout5.filename=FOX1E_radtelemetry2.csv +layout5.name=radtelemetry2 +layout5.parentLayout=radtelemetry +layout6.filename=CubeSatSim_PSK_wodtelemetry.csv +layout6.name=wodtelemetry +layout7.filename=FOX1E_wodradtelemetry.csv +layout7.name=wodradtelemetry +layout8.filename=FOX1E_wodradtelemetry2.csv +layout8.name=wodradtelemetry2 +layout8.parentLayout=wodradtelemetry +numberOfLookupTables=3 +lookupTable0.filename=FOX1A_rssiFM.tab +lookupTable0=RSSI +lookupTable1.filename=FOX1E_ihuVBattSNx.tab +lookupTable1=IHU_VBATT +lookupTable2.filename=FOX1A_ihutempSN7.tab +lookupTable2=IHU_TEMP +numberOfStringLookupTables=2 +stringLookupTable0.filename=status_on_off.tab +stringLookupTable0=STATUS_ON_OFF +stringLookupTable1=COMMAND_STATUS +stringLookupTable1.filename=command_status.tab +maxFreqBoundkHz=434950 +measurementsFileName=measurements.csv +memsRestValueX=2129 +memsRestValueY=2131 +memsRestValueZ=2103 +minFreqBoundkHz=434850 +passMeasurementsFileName=passmeasurements.csv +telemetryDownlinkFreqkHz=434900 +track=true +useIHUVBatt=false +numberOfSources=1 +source0.name=amsat.cubesat_simulator.ihu.bpsk +user_format=0 +useConversionCoeffs=true +conversionCurvesFileName=CubeSatSim_conversion_curves.csv