diff --git a/Makefile b/Makefile index 0f95bb8d..55e7b88a 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ all: DEBUG_BEHAVIOR= all: libax5043.a -all: radioafsk +all: cubesatsim all: telem debug: DEBUG_BEHAVIOR = -DDEBUG_LOGGING debug: libax5043.a -debug: radioafsk +debug: cubesatsim debug: telem rebuild: clean @@ -20,7 +20,7 @@ clean: rm -f testax5043tx rm -f testax50432freq rm -f testax5043init - rm -f radioafsk + rm -f cubesatsim rm -f testafsktx rm -f libax5043.a rm -f */*.o @@ -78,11 +78,11 @@ testafsktx: afsktx/ax5043.o testafsktx: afsktx/main.o gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testafsktx -Wall -Wextra -L./ afsktx/ax25.o afsktx/ax5043.o afsktx/main.o -lwiringPi -lax5043 -radioafsk: libax5043.a -radioafsk: afsk/ax25.o -radioafsk: afsk/ax5043.o -radioafsk: afsk/main.o - gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radioafsk -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 -lm +cubesatsim: libax5043.a +cubesatsim: afsk/ax25.o +cubesatsim: afsk/ax5043.o +cubesatsim: afsk/main.o + gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o cubesatsim -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o -lwiringPi -lax5043 -lm telem: afsk/telem.o gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o telem -Wall -Wextra -L./ afsk/telem.o -lwiringPi diff --git a/README.md b/README.md index e30491a8..868b3be1 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The other option is to start with any Raspberry Pi OS (Rasbian) image and run th - pi-power-button - Direwolf - rpitx +- cpulimit - python3-pip - python-smbus @@ -38,11 +39,11 @@ To get the software follow these steps: `git checkout master` -You are now ready to install the software. In the following command, CALLSIGN is your amateur radio callsign in all capitals, if you have one. If you don't you can put some other word which will be transmitted as a CW ID. +You are now ready to install the software using this script in the CubeSatSim directory: -`./install.sh CALLSIGN` +`./install` -The installation script will run for quite a while. It will prompt you if you want to modify /boot/config.txt file. Type a `y` and the script will complete. You will need to reboot. +The installation script will run for quite a while. You will get prompted for your amateur radio callsign in all capitals, if you have one. If you don't you can put some other word which will be transmitted as a CW ID. You will also be prompted for your latitude and longitude for APRS packets. The script will prompt you if you want to modify /boot/config.txt file. Type a `y` and the script will complete. You will need to reboot. See the Wiki for more details about the CubeSatSim https://github.com/alanbjohnston/CubeSatSim/wiki diff --git a/afsk/main.c b/afsk/main.c index 21a8d55d..c43d1afe 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -9,7 +9,7 @@ * it under the terms of the GNU General Public License as published by * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful,python3 * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -46,7 +46,6 @@ #define B 2 #define C 3 #define D 4 - #define PLUS_X 0 #define PLUS_Y 1 #define BAT 2 @@ -55,7 +54,6 @@ #define MINUS_Y 5 #define PLUS_Z 6 #define MINUS_Z 7 - #define TEMP 2 #define PRES 3 #define ALT 4 @@ -98,12 +96,14 @@ static int init_rf(); int socket_open = 0; int sock = 0; int loop = -1, loop_count = 0; -int firstTime = ON; +int firstTime = ON; // 0; long start; int testCount = 0; long time_start; - +char cmdbuffer[1000]; +FILE * file1; short int buffer[2336400]; // max size for 10 frames count of BPSK +FILE *sopen(const char *program); #define S_RATE (48000) // (44100) @@ -116,6 +116,8 @@ int rpitxStatus = -1; float amplitude; // = ; // 20000; // 32767/(10%amp+5%amp+100%amp) float freq_Hz = 3000; // 1200 +short int sin_samples; +short int sin_map[16]; int smaller; int flip_ctr = 0; @@ -131,10 +133,12 @@ int reset_count; float uptime_sec; long int uptime; char call[5]; +char sim_yes[10]; int bitRate, mode, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; float sleepTime; -int sampleTime = 0, frames_sent = 0; +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; float batteryThreshold = 3.0, batteryVoltage; @@ -147,7 +151,7 @@ double eclipse_time; int test_i2c_bus(int bus); -const char pythonCmd[] = "python3 /home/pi/CubeSatSim/python/voltcurrent.py "; +const char pythonCmd[] = "python3 -u /home/pi/CubeSatSim/python/voltcurrent.py "; char pythonStr[100], pythonConfigStr[100], busStr[10]; int map[8] = {0, 1, 2, 3, 4, 5, 6, 7}; char src_addr[5] = ""; @@ -155,7 +159,7 @@ char dest_addr[5] = "CQ"; float voltage_min[9], current_min[9], voltage_max[9], current_max[9], sensor_max[17], sensor_min[17], other_max[3], other_min[3]; int main(int argc, char * argv[]) { - + mode = FSK; frameCnt = 1; @@ -200,9 +204,10 @@ int main(int argc, char * argv[]) { } // char * cfg_buf[100]; - fscanf(config_file, "%s %d %f %f", call, & reset_count, & lat_file, & long_file); + + fscanf(config_file, "%s %d %f %f %s", call, & reset_count, & lat_file, & long_file, sim_yes); fclose(config_file); - printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f\n", call, reset_count, lat_file, long_file); + printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s\n", call, reset_count, lat_file, long_file, sim_yes); reset_count = (reset_count + 1) % 0xffff; if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { @@ -210,6 +215,8 @@ int main(int argc, char * argv[]) { latitude = lat_file; longitude = long_file; } + if (strcmp(sim_yes, "yes") == 0) + sim_mode = TRUE; wiringPiSetup(); // Check for SPI and AX-5043 Digital Transceiver Board @@ -308,7 +315,7 @@ int main(int argc, char * argv[]) { #endif config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f", call, reset_count, lat_file, long_file); + fprintf(config_file, "%s %d %8.4f %8.4f %s", call, reset_count, lat_file, long_file, sim_yes); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); @@ -340,22 +347,77 @@ int main(int argc, char * argv[]) { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); - strcat(pythonConfigStr, " c"); + strcat(pythonConfigStr, " c"); + + fprintf(stderr, "pythonConfigStr: %s\n", pythonConfigStr); + + file1 = sopen(pythonConfigStr); // try new function + + // test i2c buses + fflush(stdout); + printf("Test bus 0\n"); + fflush(stdout); + i2c_bus0 = (test_i2c_bus(0) != -1) ? ON : OFF; + printf("Test bus 1\n"); + fflush(stdout); + i2c_bus1 = (test_i2c_bus(1) != -1) ? ON : OFF; + printf("Test bus 3\n"); + fflush(stdout); + i2c_bus3 = (test_i2c_bus(3) != -1) ? ON : OFF; + printf("Finished testing\n"); + fflush(stdout); + + // check for camera +// char cmdbuffer1[1000]; + FILE * file4 = popen("vcgencmd get_camera", "r"); + fgets(cmdbuffer, 1000, file4); + char camera_present[] = "supported=1 detected=1"; + // printf("strstr: %s \n", strstr( & cmdbuffer1, camera_present)); + camera = (strstr( (const char *)& cmdbuffer, camera_present) != NULL) ? ON : OFF; + // printf("Camera result:%s camera: %d \n", & cmdbuffer1, camera); + pclose(file4); + + #ifdef DEBUG_LOGGING + printf("INFO: I2C bus status 0: %d 1: %d 3: %d camera: %d\n", i2c_bus0, i2c_bus1, i2c_bus3, camera); + #endif + + fgets(cmdbuffer, 1000, file1); + fprintf(stderr, "pythonStr result: %s\n", cmdbuffer); +/* + sleep(5); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result2: %s\n", cmdbuffer); + + file1 = popen(pythonConfigStr, "w"); - // FILE* file1 = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11 c", "r"); - FILE * file1 = popen(pythonConfigStr, "r"); - char cmdbuffer[1000]; fgets(cmdbuffer, 1000, file1); - // printf("pythonStr result: %s\n", cmdbuffer); - pclose(file1); + printf("pythonStr result: %s\n", cmdbuffer); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr resulta: %s\n", cmdbuffer); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr resultb: %s\n", cmdbuffer); +// pclose(file1); + sleep(5); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result2: %s\n", cmdbuffer); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result2a: %s\n", cmdbuffer); + + sleep(5); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result2: %s\n", cmdbuffer); +*/ // try connecting to Arduino payload using UART if (!ax5043 && !vB3) // don't test if AX5043 is present { payload = OFF; - if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { + if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600 char c; int charss = (char) serialDataAvail(uart_fd); if (charss != 0) @@ -392,30 +454,10 @@ int main(int argc, char * argv[]) { } } - // test i2c buses - i2c_bus0 = (test_i2c_bus(0) != -1) ? ON : OFF; - i2c_bus1 = (test_i2c_bus(1) != -1) ? ON : OFF; - i2c_bus3 = (test_i2c_bus(3) != -1) ? ON : OFF; - - // check for camera - char cmdbuffer1[1000]; - FILE * file4 = popen("vcgencmd get_camera", "r"); - fgets(cmdbuffer1, 1000, file4); - char camera_present[] = "supported=1 detected=1"; - // printf("strstr: %s \n", strstr( & cmdbuffer1, camera_present)); - camera = (strstr( (const char *)& cmdbuffer1, camera_present) != NULL) ? ON : OFF; - // printf("Camera result:%s camera: %d \n", & cmdbuffer1, camera); - pclose(file4); - - #ifdef DEBUG_LOGGING - printf("INFO: I2C bus status 0: %d 1: %d 3: %d camera: %d\n", i2c_bus0, i2c_bus1, i2c_bus3, camera); - #endif - - // if ((i2c_bus1 == OFF) && (i2c_bus3 == OFF)) { - if (i2c_bus3 == OFF) { // i2c bus 13 can be turned off manually by editing /boot/config.txt + if ((i2c_bus3 == OFF) || (sim_mode == TRUE)) { sim_mode = TRUE; - + printf("Simulated telemetry mode!\n"); srand((unsigned int)time(0)); @@ -466,9 +508,6 @@ int main(int argc, char * argv[]) { tx_freq_hz -= tx_channel * 50000; - if (mode == AFSK) - sleep(10); // delay awaiting CW ID completion - if (transmit == FALSE) { fprintf(stderr, "\nNo CubeSatSim Band Pass Filter detected. No transmissions after the CW ID.\n"); @@ -484,38 +523,14 @@ int main(int argc, char * argv[]) { for (int i = 0; i < 17; i++) { sensor_min[i] = 1000.0; sensor_max[i] = -1000.0; - printf("Sensor min and max initialized!"); + // printf("Sensor min and max initialized!"); } for (int i = 0; i < 3; i++) { other_min[i] = 1000.0; other_max[i] = -1000.0; } - while (loop-- != 0) { - frames_sent++; - - #ifdef DEBUG_LOGGING - fprintf(stderr, "INFO: Battery voltage: %f V Battery Threshold %f V\n", batteryVoltage, batteryThreshold); - #endif - 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); - 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"); - sleep(10); - } - - if (mode == FSK) { + if (mode == FSK) { bitRate = 200; rsFrames = 1; payloads = 1; @@ -556,12 +571,53 @@ int main(int argc, char * argv[]) { printf("\n BPSK Mode, bufLen: %d, %d bits per frame, %d bits per second, %d seconds per frame %d ms sample period\n", bufLen, bufLen / (samples * frameCnt), bitRate, bufLen / (samples * frameCnt * bitRate), samplePeriod); + + sin_samples = S_RATE/freq_Hz; + printf("Sin map: "); + for (int j = 0; j < sin_samples; j++) { + sin_map[j] = (short int)(amplitude * sin((float)(2 * M_PI * j / sin_samples))); + printf(" %d", sin_map[j]); + } + printf("\n"); + } + + long int loopTime; + loopTime = millis(); + + while (loop-- != 0) { + fflush(stdout); + fflush(stderr); +// frames_sent++; + + printf("++++ Loop time: %d +++++\n", millis() - loopTime); + loopTime = millis(); + + #ifdef DEBUG_LOGGING + fprintf(stderr, "INFO: Battery voltage: %f V Battery Threshold %f V\n", batteryVoltage, batteryThreshold); + #endif + 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); + 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"); + sleep(10); } // sleep(1); // Delay 1 second ctr = 0; #ifdef DEBUG_LOGGING - fprintf(stderr, "INFO: Getting TLM Data\n"); +// fprintf(stderr, "INFO: Getting TLM Data\n"); #endif if ((mode == AFSK) || (mode == CW)) { @@ -572,7 +628,7 @@ int main(int argc, char * argv[]) { } #ifdef DEBUG_LOGGING - fprintf(stderr, "INFO: Getting ready to send\n"); +// fprintf(stderr, "INFO: Getting ready to send\n"); #endif } @@ -641,6 +697,10 @@ void get_tlm(void) { FILE * txResult; for (int j = 0; j < frameCnt; j++) { + + fflush(stdout); + fflush(stderr); + digitalWrite(txLed, txLedOn); #ifdef DEBUG_LOGGING printf("Tx LED On\n"); @@ -652,12 +712,13 @@ void get_tlm(void) { int count1; char * token; - char cmdbuffer[1000]; +// char cmdbuffer[1000]; - FILE * file = popen(pythonStr, "r"); - fgets(cmdbuffer, 1000, file); - // printf("result: %s\n", cmdbuffer); - pclose(file); +// FILE * file = popen(pythonStr, "r"); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + printf("Python result: %s\n", cmdbuffer); +// pclose(file); const char space[2] = " "; token = strtok(cmdbuffer, space); @@ -696,7 +757,7 @@ void get_tlm(void) { cpuTemp /= 1000; #ifdef DEBUG_LOGGING - printf("CPU Temp Read: %6.1f\n", cpuTemp); +// printf("CPU Temp Read: %6.1f\n", cpuTemp); #endif } @@ -819,7 +880,8 @@ void get_tlm(void) { char header_long[10]; char header_str4[] = "hi hi "; char footer_str1[] = "\' > t.txt && echo \'"; - char footer_str[] = ">CQ:010101/hi hi ' >> t.txt && gen_packets -o telem.wav t.txt -r 48000 > /dev/null 2>&1 && cat telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1"; +// char footer_str[] = ">CQ:010101/hi hi ' >> t.txt && gen_packets -o telem.wav t.txt -r 48000 > /dev/null 2>&1 && cat telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1"; + char footer_str[] = ">CQ:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py if (ax5043) { strcpy(str, header_str); @@ -885,7 +947,7 @@ void get_tlm(void) { int i = 0; serialPutchar(uart_fd, '?'); - printf("Querying payload with ?\n"); +// printf("Querying payload with ?\n"); waitTime = millis() + 500; int end = FALSE; while ((millis() < waitTime) && !end) { @@ -903,7 +965,7 @@ void get_tlm(void) { } // sensor_payload[i++] = '\n'; sensor_payload[i] = '\0'; - printf("Payload string: %s", sensor_payload); + printf(" Payload string: %s\n", sensor_payload); strcat(str, sensor_payload); // append to telemetry string for transmission } @@ -954,6 +1016,7 @@ void get_tlm(void) { if (transmit) { FILE * file2 = popen(str, "r"); pclose(file2); + sleep(2); } else { 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"); @@ -982,7 +1045,7 @@ void get_tlm(void) { void get_tlm_fox() { // Reading I2C voltage and current sensors - +/* FILE * uptime_file = fopen("/proc/uptime", "r"); fscanf(uptime_file, "%f", & uptime_sec); uptime = (int) uptime_sec; @@ -990,7 +1053,7 @@ void get_tlm_fox() { printf("Reset Count: %d Uptime since Reset: %ld \n", reset_count, uptime); #endif fclose(uptime_file); - +*/ int i; // long int sync = SYNC_WORD; long int sync = syncWord; @@ -999,8 +1062,13 @@ void get_tlm_fox() { // short int b[DATA_LEN]; 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[HEADER_LEN]; short int h[headerLen]; memset(h, 0, sizeof(h)); @@ -1046,151 +1114,43 @@ void get_tlm_fox() { // delay for sample period digitalWrite(txLed, txLedOn); #ifdef DEBUG_LOGGING - printf("Tx LED On\n"); +// printf("Tx LED On\n"); #endif - +/* while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); - +*/ +// if (mode == FSK) + sleep(2.3); // No sleep at all! +// else +// sleep(1.3); + digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING - printf("Tx LED Off\n"); +// printf("Tx LED Off\n"); #endif - printf("Sample period: %d\n", millis() - (unsigned int)sampleTime); - sampleTime = (int) millis(); +// printf("Sample period: %d\n", millis() - (unsigned int)sampleTime); + sampleTime = (unsigned int) millis(); } else printf("first time - no sleep\n"); - - int count1; - char * token; - char cmdbuffer[1000]; - - FILE * file = popen(pythonStr, "r"); - fgets(cmdbuffer, 1000, file); - // printf("result: %s\n", cmdbuffer); - pclose(file); - - const char space[2] = " "; - token = strtok(cmdbuffer, space); - + float voltage[9], current[9], sensor[17], other[3]; + char sensor_payload[500]; memset(voltage, 0, sizeof(voltage)); memset(current, 0, sizeof(current)); memset(sensor, 0, sizeof(sensor)); - memset(other, 0, sizeof(other)); - - for (count1 = 0; count1 < 8; count1++) { - if (token != NULL) { - voltage[count1] = (float) atof(token); - #ifdef DEBUG_LOGGING - // printf("voltage: %f ", voltage[count1]); - #endif - token = strtok(NULL, space); - if (token != NULL) { - current[count1] = (float) atof(token); - if ((current[count1] < 0) && (current[count1] > -0.5)) - current[count1] *= (-1.0f); - #ifdef DEBUG_LOGGING - // printf("current: %f\n", current[count1]); - #endif - token = strtok(NULL, space); - } - } - } - - // printf("\n"); - - batteryVoltage = voltage[map[BAT]]; - if (batteryVoltage < 3.5) { - NormalModeFailure = 1; - printf("Safe Mode!\n"); - } else - NormalModeFailure = 0; - - FILE * cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); - if (cpuTempSensor) { - double cpuTemp; - fscanf(cpuTempSensor, "%lf", & cpuTemp); - cpuTemp /= 1000; - - #ifdef DEBUG_LOGGING - printf("CPU Temp Read: %6.1f\n", cpuTemp); - #endif - - other[IHU_TEMP] = (double)cpuTemp; - - // IHUcpuTemp = (int)((cpuTemp * 10.0) + 0.5); - } - fclose(cpuTempSensor); - - char sensor_payload[500]; - - if (payload == ON) { - STEMBoardFailure = 0; - - char c; - int charss = (char) serialDataAvail(uart_fd); - if (charss != 0) - printf("Clearing buffer of %d chars \n", charss); - while ((charss--> 0)) - c = (char) serialGetchar(uart_fd); // clear buffer - - unsigned int waitTime; - int i = 0; - serialPutchar(uart_fd, '?'); - printf("Querying payload with ?\n"); - waitTime = millis() + 500; - int end = FALSE; - // int retry = FALSE; - while ((millis() < waitTime) && !end) { - int chars = (char) serialDataAvail(uart_fd); - while ((chars--> 0) && !end) { - c = (char) serialGetchar(uart_fd); - // printf ("%c", c); - // fflush(stdout); - if (c != '\n') { - sensor_payload[i++] = c; - } else { - end = TRUE; - } - } - } - sensor_payload[i++] = ' '; - // sensor_payload[i++] = '\n'; - sensor_payload[i] = '\0'; - printf("Payload string: %s \n", sensor_payload); - - if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response - { - int count1; - char * token; - // char cmdbuffer[1000]; - - // FILE *file = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11", "r"); - // fgets(cmdbuffer, 1000, file); - // printf("result: %s\n", cmdbuffer); - // pclose(file); - - const char space[2] = " "; - token = strtok(sensor_payload, space); - for (count1 = 0; count1 < 17; count1++) { - if (token != NULL) { - sensor[count1] = (float) atof(token); - #ifdef DEBUG_LOGGING - printf("sensor: %f ", sensor[count1]); - #endif - token = strtok(NULL, space); - } - } - printf("\n"); - - } - - } - - if (sim_mode) { - // simulated telemetry + memset(other, 0, sizeof(other)); + + FILE * uptime_file = fopen("/proc/uptime", "r"); + fscanf(uptime_file, "%f", & uptime_sec); + uptime = (int) uptime_sec; +// #ifdef DEBUG_LOGGING +// printf("INFO: Reset Count: %d Uptime since Reset: %ld \n", reset_count, uptime); +// #endif + fclose(uptime_file); + + if (sim_mode) { // simulated telemetry double time = ((long int)millis() - time_start) / 1000.0; @@ -1200,11 +1160,6 @@ void get_tlm_fox() { printf("\n\nSwitching eclipse mode! \n\n"); } - /* - double Xi = eclipse * amps_max[0] * sin(2.0 * 3.14 * time / (46.0 * speed)) * fabs(sin(2.0 * 3.14 * time / (46.0 * speed))) + rnd_float(-2, 2); - double Yi = eclipse * amps_max[1] * sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14/2.0)) * fabs(sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14/2.0))) + rnd_float(-2, 2); - double Zi = eclipse * amps_max[2] * sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) * fabs(sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2])) + rnd_float(-2, 2); - */ double Xi = eclipse * amps_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-2, 2); double Yi = eclipse * amps_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-2, 2); double Zi = eclipse * amps_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-2, 2); @@ -1261,79 +1216,214 @@ void get_tlm_fox() { // end of simulated telemetry } + else { + int count1; + char * token; +// char cmdbuffer[1000]; +/**/ +// FILE * file = popen(pythonStr, "r"); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + fprintf(stderr, "Python read Result: %s\n", cmdbuffer); +// pclose(file); +/**/ + const char space[2] = " "; + token = strtok(cmdbuffer, space); + + for (count1 = 0; count1 < 8; count1++) { + if (token != NULL) { + voltage[count1] = (float) atof(token); + #ifdef DEBUG_LOGGING + // printf("voltage: %f ", voltage[count1]); + #endif + token = strtok(NULL, space); + if (token != NULL) { + current[count1] = (float) atof(token); + if ((current[count1] < 0) && (current[count1] > -0.5)) + current[count1] *= (-1.0f); + #ifdef DEBUG_LOGGING + // printf("current: %f\n", current[count1]); + #endif + token = strtok(NULL, space); + } + } + } + // printf("\n"); + +// sleep(0.5); +// printf("Sleep over\n"); + + batteryVoltage = voltage[map[BAT]]; + if (batteryVoltage < 3.5) { + NormalModeFailure = 1; + printf("Safe Mode!\n"); + } else + NormalModeFailure = 0; - for (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]; + FILE * cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); + if (cpuTempSensor) { + double cpuTemp; + fscanf(cpuTempSensor, "%lf", & cpuTemp); + cpuTemp /= 1000; - printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); - } + #ifdef DEBUG_LOGGING +// printf("CPU Temp Read: %6.1f\n", cpuTemp); + #endif - if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { - for (count1 = 0; count1 < 17; count1++) { - if (sensor[count1] < sensor_min[count1]) - sensor_min[count1] = sensor[count1]; - if (sensor[count1] > sensor_max[count1]) - sensor_max[count1] = sensor[count1]; + other[IHU_TEMP] = (double)cpuTemp; - printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); + // IHUcpuTemp = (int)((cpuTemp * 10.0) + 0.5); } - } + fclose(cpuTempSensor); - for (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]; + if (payload == ON) { // -55 + STEMBoardFailure = 0; - printf("Other min %f max %f \n", other_min[count1], other_max[count1]); - } + char c; + int charss = (char) serialDataAvail(uart_fd); + if (charss != 0) + printf("Clearing buffer of %d chars \n", charss); + while ((charss--> 0)) + c = (char) serialGetchar(uart_fd); // clear buffer +/* + charss = (char) serialDataAvail(uart_fd); + if (charss != 0) + printf("Clearing buffer of %d chars \n", charss); + while ((charss--> 0)) + c = (char) serialGetchar(uart_fd); // clear buffer +*/ + + unsigned int waitTime; + int i = 0; + serialPutchar(uart_fd, '?'); +// printf("Querying payload with ?\n"); + waitTime = millis() + 500; + int end = FALSE; + // int retry = FALSE; + while ((millis() < waitTime) && !end) { + int chars = (char) serialDataAvail(uart_fd); + while ((chars--> 0) && !end) { + c = (char) serialGetchar(uart_fd); + // printf ("%c", c); + // fflush(stdout); + if (c != '\n') { + sensor_payload[i++] = c; + } else { + end = TRUE; + } + } + } + sensor_payload[i++] = ' '; + // sensor_payload[i++] = '\n'; + sensor_payload[i] = '\0'; + printf(" Payload string: %s", sensor_payload); + + if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response + { + int count1; + char * token; + // char cmdbuffer[1000]; + + // FILE *file = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11", "r"); + // fgets(cmdbuffer, 1000, file); + // printf("result: %s\n", cmdbuffer); + // pclose(file); - if (mode == FSK) { - if (loop % 8 == 0) { - printf("Sending MIN frame \n"); - frm_type = 0x03; - for (count1 = 0; count1 < 17; count1++) { - if (count1 < 3) - other[count1] = other_min[count1]; - if (count1 < 8) { - voltage[count1] = voltage_min[count1]; - current[count1] = current_min[count1]; + const char space[2] = " "; + token = strtok(sensor_payload, space); + for (count1 = 0; count1 < 17; count1++) { + if (token != NULL) { + sensor[count1] = (float) atof(token); + #ifdef DEBUG_LOGGING + // printf("sensor: %f ", sensor[count1]); + #endif + token = strtok(NULL, space); + } + } + printf("\n"); } - if (sensor_min[count1] != 1000.0) // make sure values are valid - sensor[count1] = sensor_min[count1]; } - } - if ((loop + 4) % 8 == 0) { - printf("Sending MAX frame \n"); - frm_type = 0x02; - for (count1 = 0; count1 < 17; 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]; + if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { + for (count1 = 0; count1 < 17; count1++) { + if (sensor[count1] < sensor_min[count1]) + sensor_min[count1] = sensor[count1]; + if (sensor[count1] > sensor_max[count1]) + sensor_max[count1] = sensor[count1]; + // printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); + } } } - } +// 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]; + +// 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]; + + // printf("Other min %f max %f \n", other_min[count1], other_max[count1]); + } + if (mode == FSK) + { + if (loop % 8 == 0) { + printf("Sending MIN frame \n"); + frm_type = 0x03; + for (int count1 = 0; count1 < 17; 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 + 4) % 8 == 0) { + printf("Sending MAX frame \n"); + frm_type = 0x02; + for (int count1 = 0; count1 < 17; 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) { // remove this +// } memset(rs_frame, 0, sizeof(rs_frame)); memset(parities, 0, sizeof(parities)); - +/* FILE * uptime_file = fopen("/proc/uptime", "r"); fscanf(uptime_file, "%f", & uptime_sec); uptime = (int) uptime_sec; fclose(uptime_file); printf("Reset Count: %d Uptime since Reset: %ld \n", reset_count, uptime); +*/ + //sleep(1); + //printf("Sleep over\n"); h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits // printf("h[0] %x\n", h[0]); @@ -1368,7 +1458,6 @@ void get_tlm_fox() { negZv = (int)(voltage[map[MINUS_Z]] * 100); batt_c_v = (int)(voltage[map[BAT]] * 100); - battCurr = (int)(current[map[BAT]] + 0.5) + 2048; PSUVoltage = (int)(voltage[map[BUS]] * 100); PSUCurrent = (int)(current[map[BUS]] + 0.5) + 2048; @@ -1376,9 +1465,6 @@ void get_tlm_fox() { if (payload == ON) STEMBoardFailure = 0; - // if (payload == ON) - // STEMBoardFailure = 0; - // read payload sensor if available encodeA(b, 0 + head_offset, batt_a_v); @@ -1427,8 +1513,122 @@ 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)); + encodeB(b_max, 16 + head_offset, (int)(voltage_max[map[MINUS_X]] * 100)); + encodeA(b_max, 18 + head_offset, (int)(voltage_max[map[MINUS_Y]] * 100)); + encodeB(b_max, 19 + head_offset, (int)(voltage_max[map[MINUS_Z]] * 100)); + + encodeA(b_max, 21 + head_offset, (int)(current_max[map[PLUS_X]] + 0.5) + 2048); + encodeB(b_max, 22 + head_offset, (int)(current_max[map[PLUS_Y]] + 0.5) + 2048); + 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); + + 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[BUS]] * 100)); + encodeB(b_max, 46 + head_offset, (int)(current_max[map[BUS]] + 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[0] != 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[XS2]) + 2048); + encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS3] * 100 + 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)); + } + 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 + +// 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, 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); +// encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); +// encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] + 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)); + encodeB(b_min, 16 + head_offset, (int)(voltage_min[map[MINUS_X]] * 100)); + encodeA(b_min, 18 + head_offset, (int)(voltage_min[map[MINUS_Y]] * 100)); + encodeB(b_min, 19 + head_offset, (int)(voltage_min[map[MINUS_Z]] * 100)); + + encodeA(b_min, 21 + head_offset, (int)(current_min[map[PLUS_X]] + 0.5) + 2048); + encodeB(b_min, 22 + head_offset, (int)(current_min[map[PLUS_Y]] + 0.5) + 2048); + 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); + + 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[BUS]] * 100)); + encodeB(b_min, 46 + head_offset, (int)(current_min[map[BUS]] + 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); + encodeA(b_min, 39 + head_offset, (int)(other_min[IHU_TEMP] * 10 + 0.5)); + + if (sensor_min[0] != 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[XS2]) + 2048); + encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS3] * 100 + 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)); + } + 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_min, 33 + head_offset, (int)(sensor_max[PRES] + 0.5)); // Pressure +// encodeB(b_min, 34 + head_offset, (int)(sensor_max[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); + + encodeA(b_min, 48 + head_offset, 2048); + encodeB(b_min, 49 + head_offset, 2048); +// encodeB(b_min, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); +// encodeA(b_min, 45 + head_offset, (int)(sensor_max[HUMI] + 0.5)); + } + } encodeA(b, 30 + head_offset, PSUVoltage); // encodeB(b, 31 + head_offset,(spin * 10) + 2048); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); @@ -1466,7 +1666,7 @@ void get_tlm_fox() { // camera = ON; - int status = STEMBoardFailure + NormalModeFailure * 2 + PayloadFailure1 * 4 + PayloadFailure2 * 8 + + int status = STEMBoardFailure + NormalModeFailure * 2 + !sim_mode * 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); @@ -1478,10 +1678,14 @@ void get_tlm_fox() { printf("TX Antenna Deployed!\n"); } - if (mode == BPSK) { // WOD field experiments - encodeA(b, 63 + head_offset, 0xff); - encodeB(b, 74 + head_offset, 0xff); - } + 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, 62 + head_offset, 0x01); + encodeB(b, 74 + head_offset, 0xfff); + } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; @@ -1498,8 +1702,29 @@ void get_tlm_fox() { data8[ctr1++] = rs_frame[j][i]; // printf ("data8[%d] = %x \n", ctr1 - 1, rs_frame[j][i]); } else { - rs_frame[j][i] = b[ctr3 % dataLen]; - update_rs(parities[j], b[ctr3 % dataLen]); + 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]; @@ -1520,6 +1745,9 @@ void get_tlm_fox() { printf("\n"); */ #endif + + //sleep(1); + //printf("Sleep over\n"); int ctr2 = 0; memset(data10, 0, sizeof(data10)); @@ -1659,15 +1887,30 @@ void get_tlm_fox() { if (!error && transmit) { // digitalWrite (0, LOW); - printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, (long unsigned int)millis() - start); + // 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("Millis5: %d Result of socket send: %d \n", (unsigned int)millis() - start, sock_ret); - + printf("Millis6: %d Result of socket send: %d \n\n", (unsigned int)millis() - start, sock_ret); + if (sock_ret < (ctr * 2 + 2)) { - printf("Not resending\n"); - // sock_ret = send(sock, buffer[sock_ret], ctr * 2 + 2 - sock_ret, 0); - // printf("Millis10: %d Result of socket send: %d \n", millis() - start, sock_ret); + // printf("Not resending\n"); + sleep(0.5); + sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); + printf("Millis7: %d Result of socket send: %d \n\n", millis() - start, sock_ret); + } + + if (mode == BPSK) + { + start = millis(); // send frame a second time + sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); + printf("Millis8: %d Result of socket send: %d \n\n", (unsigned int)millis() - start, sock_ret); + + 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("Millis9: %d Result of socket send: %d \n\n", millis() - start, sock_ret); + } } if (sock_ret == -1) { @@ -1682,13 +1925,42 @@ void get_tlm_fox() { } // digitalWrite (0, HIGH); - if (mode == FSK) - firstTime = 0; - else if (frames_sent > 0) //5) +// if (mode == FSK) firstTime = 0; +// else if (frames_sent > 0) //5) +// firstTime = 0; return; } + +// code by https://stackoverflow.com/questions/25161377/open-a-cmd-program-with-full-functionality-i-o/25177958#25177958 + + FILE *sopen(const char *program) + { + int fds[2]; + pid_t pid; + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) + return NULL; + + switch(pid=vfork()) { + case -1: /* Error */ + close(fds[0]); + close(fds[1]); + return NULL; + case 0: /* child */ + close(fds[0]); + dup2(fds[1], 0); + dup2(fds[1], 1); + close(fds[1]); + execl("/bin/sh", "sh", "-c", program, NULL); + _exit(127); + } + /* parent */ + close(fds[1]); + return fdopen(fds[0], "r+"); + } + /* * TelemEncoding.h * @@ -1889,10 +2161,11 @@ void write_wave(int i, short int *buffer) else { if ((ctr - flip_ctr) < smaller) - buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); - else - buffer[ctr++] = (short int)(amplitude * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); - } +// buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); + buffer[ctr++] = (short int)(phase * sin_map[ctr % sin_samples] / 2); + else +// buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); buffer[ctr++] = (short int)(amplitude * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); + buffer[ctr++] = (short int)(phase * sin_map[ctr % sin_samples]); } // printf("%d %d \n", i, buffer[ctr - 1]); } @@ -1955,7 +2228,7 @@ int test_i2c_bus(int bus) // printf("%s error: %d \n", &command, error); if (error != 0) { - printf("ERROR: %sd bus has a problem \n Check I2C wiring and pullup resistors \n", busDev); + printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", busDev); output = -1; } } else diff --git a/afsk/telem.c b/afsk/telem.c index c6f00ad6..e6bb8714 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -10,6 +10,11 @@ #include #include #include +#include +#include +#include +#include +#include #define PLUS_X 0 #define PLUS_Y 1 @@ -27,13 +32,16 @@ int test_i2c_bus(int bus); const char pythonCmd[] = "python3 /home/pi/CubeSatSim/python/voltcurrent.py "; char pythonStr[100], pythonConfigStr[100], busStr[10]; int map[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; +FILE *sopen(const char *program); +int debug = OFF; int main(int argc, char *argv[]) { if (argc > 1) { - ; + if ( * argv[1] == 'd') { + debug = ON; + } } - wiringPiSetup (); printf("\n"); @@ -48,9 +56,7 @@ int main(int argc, char *argv[]) { map[BAT] = BUS; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - - snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); - printf("New Bus String: %s \n", busStr); + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); /* if (access("/dev/i2c-0", W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present printf("/dev/i2c-0 is present\n\n"); @@ -90,11 +96,7 @@ int main(int argc, char *argv[]) { printf("vB4 Present\n"); map[BAT] = BUS; map[BUS] = BAT; - - snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); - - printf("New Bus String: %s \n", busStr); - + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); // strcpy(busStr,"1 0"); } else @@ -104,13 +106,12 @@ int main(int argc, char *argv[]) { if (digitalRead(26) != HIGH) { - printf("vB5 Present\n"); // Don't print normal board detection + if (debug == ON) + printf("vB5 or later present\n"); // Don't print normal board detection map[MINUS_X] = MINUS_Y; map[PLUS_Z] = MINUS_X; map[MINUS_Y] = PLUS_Z; snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(3)); - - printf("New Bus String: %s \n", busStr); /* if (test_i2c_b0) != OFF) strcpy(busStr,"1 "); @@ -183,10 +184,7 @@ int main(int argc, char *argv[]) { map[BAT] = BUS; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); - - printf("New Bus String: %s \n", busStr); /* if (access("/dev/i2c-0", W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present printf("/dev/i2c-0 is present\n\n"); @@ -221,25 +219,33 @@ int main(int argc, char *argv[]) { // Reading I2C voltage and current sensors // printf("Starting\n"); - + strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); - strcat(pythonConfigStr, " c"); - - FILE* file1 = popen(pythonConfigStr, "r"); + strcat(pythonConfigStr, " s"); + char cmdbuffer[1000]; + FILE *file1 = sopen(pythonConfigStr); // try new function fgets(cmdbuffer, 1000, file1); + if (debug == ON) + { + printf("New Bus String: %s \n", busStr); + fprintf(stderr, "pythonConfigStr: %s \n", pythonConfigStr); + fprintf(stderr, "pythonStr result: %s\n", cmdbuffer); + } +// FILE* file1 = popen(pythonConfigStr, "r"); +// fgets(cmdbuffer, 1000, file1); // printf("pythonStr result: %s\n", cmdbuffer); - pclose(file1); +// sclose(file1); int count1; char *token; - FILE* file = popen(pythonStr, "r"); - fgets(cmdbuffer, 1000, file); +// FILE* file = popen(pythonStr, "r"); +// fgets(cmdbuffer, 1000, file); // printf("result: %s\n", cmdbuffer); - pclose(file); +// pclose(file); const char space[2] = " "; token = strtok(cmdbuffer, space); @@ -290,7 +296,7 @@ int test_i2c_bus(int bus) char busS[5]; snprintf(busS, 5, "%d", bus); strcat (busDev, busS); - printf("Bus Dev String: %s \n", busDev); +// printf("Bus Dev String: %s \n", busDev); if (access(busDev, W_OK | R_OK) >= 0) { // Test if I2C Bus is present // printf("bus is present\n\n"); @@ -320,3 +326,31 @@ int test_i2c_bus(int bus) } return(output); // return bus number or -1 if there is a problem with the bus } + +// code by https://stackoverflow.com/questions/25161377/open-a-cmd-program-with-full-functionality-i-o/25177958#25177958 + + FILE *sopen(const char *program) + { + int fds[2]; + pid_t pid; + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) + return NULL; + + switch(pid=vfork()) { + case -1: /* Error */ + close(fds[0]); + close(fds[1]); + return NULL; + case 0: /* child */ + close(fds[0]); + dup2(fds[1], 0); + dup2(fds[1], 1); + close(fds[1]); + execl("/bin/sh", "sh", "-c", program, NULL); + _exit(127); + } + /* parent */ + close(fds[1]); + return fdopen(fds[0], "r+"); + } diff --git a/arduino/Payload_BME280_MPU6050_XS.ino b/arduino/Payload_BME280_MPU6050_XS.ino index b7280828..cb419183 100644 --- a/arduino/Payload_BME280_MPU6050_XS.ino +++ b/arduino/Payload_BME280_MPU6050_XS.ino @@ -15,8 +15,7 @@ int RXLED = 17; // The RX LED has a defined Arduino pin int greenLED = 9; int blueLED = 8; int Sensor1 = 0; -int Sensor2 = 0; -float Sensor3 = 0; +float Sensor2 = 0; void eeprom_word_write(int addr, int val); short eeprom_word_read(int addr); int first_time = true; @@ -25,7 +24,7 @@ void setup() { Serial.begin(9600); // Serial Monitor for testing - Serial1.begin(9600); // Pi UART + Serial1.begin(115200); // Pi UART faster speed Serial.println("Starting!"); @@ -81,6 +80,8 @@ void setup() { Serial.println(((float)eeprom_word_read(2)) / 100.0, DEC); Serial.println(((float)eeprom_word_read(3)) / 100.0, DEC); } + pinMode(greenLED, OUTPUT); + pinMode(blueLED, OUTPUT); } void loop() { @@ -131,9 +132,7 @@ void loop() { Serial.print(" XS "); Serial.print(Sensor1); Serial.print(" "); - Serial.print(Sensor2); - Serial.print(" "); - Serial.println(Sensor3); + Serial.println(Sensor2); float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()*mpu6050.getGyroZ()); float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ()); @@ -199,10 +198,8 @@ void loop() { Serial1.print(" XS "); Serial1.print(Sensor1); Serial1.print(" "); - Serial1.print(Sensor2); - Serial1.print(" "); - Serial1.println(Sensor3); - + Serial1.println(Sensor2); + float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()*mpu6050.getGyroZ()); float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ()); // Serial.print(rotation); @@ -271,7 +268,7 @@ void blink(int length) #if defined __AVR_ATmega32U4__ digitalWrite(RXLED, HIGH); // set the RX LED OFF - TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF + TXLED0; //TX LED macro to turn LED ON #endif } diff --git a/config b/config new file mode 100755 index 00000000..f2ed02ab --- /dev/null +++ b/config @@ -0,0 +1,311 @@ +#!/bin/bash + +# echo $1 + +if [ "$2" = "-n" ]; then + norestart=1 +else + norestart=0 +fi + +if [ "$1" = "" ]; then + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" = "ARG1=a" ]; then + echo "APRS mode is set" + elif [ "$1" = "ARG1=f" ]; then + echo "FSK mode is set" + elif [ "$1" = "ARG1=b" ]; then + echo "BPSK mode is set" + elif [ "$1" = "ARG1=s" ]; then + echo "SSTV mode is set" + else + echo + fi + echo + echo -e "Current sim.cfg configuration file:" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo $1 $2 $3 $4 $5 + echo + + if [ "$sim" = "y" ] ; then + sim="yes" + echo "Simulated Telemetry is ON" + else + sim="no" + echo "Simulated Telemetry is OFF" + fi + + echo + echo "To change, include an OPTION" + echo + set -- "-h" +fi + +if [ "$1" = "-i" ]; then + echo "Restarting CubeSatSim" + sudo systemctl restart cubesatsim + exit +elif [ "$1" = "-a" ]; then + echo "changing CubeSatSim to AFSK mode" + sudo echo "ARG1=a" > /home/pi/CubeSatSim/.mode + sudo systemctl restart cubesatsim + exit +elif [ "$1" = "-f" ]; then + echo "changing CubeSatSim to FSK mode" + sudo echo "ARG1=f" > /home/pi/CubeSatSim/.mode + sudo systemctl restart cubesatsim + exit +elif [ "$1" = "-b" ]; then + echo "changing CubeSatSim to BPSK mode" + sudo echo "ARG1=b" > /home/pi/CubeSatSim/.mode + sudo systemctl restart cubesatsim + exit +elif [ "$1" = "-s" ]; then + echo "changing CubeSatSim to SSTV mode" + sudo echo "ARG1=s" > /home/pi/CubeSatSim/.mode + sudo systemctl restart cubesatsim + exit +elif [ "$1" = "-h" ]; then + echo "config OPTION" + echo + echo "Changes CubeSatSim mode, resets, or modifies configuration file" + echo + echo " -h This help info" + echo " -a Change to AFSK/APRS mode" + echo " -f Change to FSK/DUV mode" + echo " -b Change to BPSK mode" + echo " -s Change to SSTV mode" + echo " -i Restarts CubeSatsim software" + echo " -c Change the CALLSIGN in the configuration file sim.cfg" + echo " -m Change the Simulated Telemetry setting in sim.cfg" + echo " -r Change the Resets Count in the configuration file sim.cfg" + echo " -l Change the Latitude and Longitude in the configuration file sim.cfg" + echo " Only used for APRS telemetry" + echo + exit + +elif [ "$1" = "-m" ]; then + + echo + echo "Editing the Simulated Telemetry setting in" + echo "the configuration file for CubeSatSim" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + if [ "$5" = "yes" ]; then + echo "Simualted Telemetry is ON" + else + echo "Simualted Telemetry is OFF" + fi + + echo + +# echo $1 $2 $3 $4 + + echo "Do you want Simulated Telemetry ON (y/n) " + read sim + echo + + if [ "$sim" = "y" ] ; then + sim="yes" + echo "Simulated Telemetry is ON" + else + sim="no" + echo "Simulated Telemetry is OFF" + fi + + echo + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo + echo $1 $2 $3 $4 $sim + echo $1 $2 $3 $4 $sim > /home/pi/CubeSatSim/sim.cfg + echo + echo "Restarting CubeSatSim with new configuraation file" + echo + + sudo systemctl restart cubesatsim + +elif [ "$1" = "-c" ]; then + + 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 + + if [ "$norestart" = "1" ]; then + echo + else + echo + echo "Restarting CubeSatSim with new configuraation file" + echo + sudo systemctl restart cubesatsim + fi + +elif [ "$1" = "-r" ]; then + + echo + echo "Editing the Reset Count 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 + echo "Current value of Reset Count is" + echo $2 + echo + +# echo $1 $2 $3 $4 $5 + + echo -e "Enter Reset Count (integer): " + + read resets + + if [ -z $resets ] ; then + resets="$2" + echo "Keeping value of" $resets + fi + + if ! [[ $resets =~ ^[0-9]+$ ]] ; then + echo "Error: not an integer!" + resets="$2" + echo "Keeping value of" $resets + norestart=1 + else + + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + + echo $1 $resets $3 $4 $5 + echo $1 $resets $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg + fi + + if [ "$norestart" = "1" ]; then + echo + else + echo + echo "Restarting CubeSatSim with new configuraation file" + echo + sudo systemctl restart cubesatsim + fi + +elif [ "$1" = "-l" ]; then + + echo + echo "Editing latitude and longitude in the" + echo "configuration file for CubeSatSim" + echo "(Only used for APRS telemetry)" + 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 + echo "Current value of latitude is" + echo $3 + echo + +# echo $1 $2 $3 $4 $5 + + echo -e "Enter latitude (decimal degrees, positive is north): " + + read lat + + if [ -z $lat ] ; then + + lat="$3" + echo "Keeping value of" $lat + fi + + if ! [[ $lat =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then + + echo "Error: not a number!" + lat="$3" + echo "Keeping value of" $lat + fi + + echo + echo "Current value of longitude is" + echo $4 + echo + + echo -e "Enter longitude (decimal degrees, positive is east): " + + read long + + if [ -z $long ] ; then + + long="$4" + echo "Keeping value of" $long + fi + + if ! [[ $long =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then + + echo "Error: not a number!" + long="$4" + echo "Keeping value of" $long + fi + + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo $1 $2 $lat $long $5 + echo $1 $2 $lat $long $5 > /home/pi/CubeSatSim/sim.cfg + + if [ "$norestart" = "1" ]; then + echo + else + echo + echo "Restarting CubeSatSim with new configuraation file" + echo + sudo systemctl restart cubesatsim + fi +fi + +# sudo systemctl restart cubesatsim diff --git a/demo.sh b/demo.sh index de318527..e25a8214 100755 --- a/demo.sh +++ b/demo.sh @@ -13,15 +13,16 @@ fi if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then echo "Mode is continuous AFSK" - /home/pi/CubeSatSim/radioafsk afsk + /home/pi/CubeSatSim/cubesatsim afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then - echo "Mode is continuous BPSK" - /home/pi/CubeSatSim/radioafsk bpsk + echo "Mode is continuous BPSK" + sudo cpulimit -l 2.5 -b -P cubesatsim + /home/pi/CubeSatSim/cubesatsim bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" while true; do sleep 5; done else echo "Mode is continuous FSK" - /home/pi/CubeSatSim/radioafsk fsk + /home/pi/CubeSatSim/cubesatsim fsk fi diff --git a/install b/install new file mode 100755 index 00000000..554de89e --- /dev/null +++ b/install @@ -0,0 +1,168 @@ +#!/bin/bash + +echo -e "\ninstallation script for CubeSatSim\n" + +sudo apt-get update && sudo apt-get dist-upgrade -y + +sudo apt-get install -y wiringpi git libasound2-dev i2c-tools cpulimit python-picamera python3-picamera build-essential libgd-dev libmagic-dev + +cd /tmp + +wget https://project-downloads.drogon.net/wiringpi-latest.deb + +sudo dpkg -i wiringpi-latest.deb + + +cd + +sudo apt install -y python3-pip python-smbus + +sudo pip3 install --upgrade setuptools + +sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 + + + +cd ~/CubeSatSim + +git pull + +make debug + +FILE=/home/pi/CubeSatSim/.mode +if [ -f "$FILE" ]; then + echo "$FILE exists." +else + echo "creating $FILE" + echo "ARG1=f" > .mode +fi + + +FILE=/home/pi/CubeSatSim/sim.cfg +if [ -f "$FILE" ]; then + echo "$FILE exists." +else + echo "creating $FILE" + echo "AMSAT 1 0.0 0.0" > /home/pi/CubeSatSim/sim.cfg +fi + + +cd + +git clone https://github.com/alanbjohnston/direwolf.git + +cd direwolf + +make -j + +sudo make install + +make install-rpi + + +cd + +git clone https://github.com/alanbjohnston/pi-power-button.git + +cd pi-power-button + +./script/install + + +cd + +git clone https://github.com/alanbjohnston/PiSSTVpp.git + +cd PiSSTVpp + +make pisstvpp + + +cd + +git clone https://github.com/alanbjohnston/rpitx.git + +cd rpitx + +./install.sh + + +cd + +sudo cp ~/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service + +sudo systemctl enable cubesatsim + +sudo cp ~/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service + +sudo systemctl enable rpitx + +sudo cp /boot/config.txt /boot/config.txt.0 + +sudo cp /boot/cmdline.txt /boot/cmdline.txt.0 + + +sudo raspi-config nonint do_i2c 0 + +sudo raspi-config nonint do_camera 0 + + +#if [ "$1" = "u" ]; then +#fi + + sudo sed -i 's/console=serial0,115200 //g' /boot/cmdline.txt + + sudo sed -i 's/#dtparam=i2c_arm=on/dtparam=i2c_arm=on/g' /boot/config.txt + + if [[ $(grep 'dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24' /boot/config.txt) ]]; then + echo "dtoverlay=i2c-gpio already in /boot/config.txt" + else + echo "adding dtoverlay=i2c-gpio to /boot/config.txt" + sudo sh -c 'echo "\ndtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24" >> /boot/config.txt' + fi + + if [[ $(grep 'enable_uart=1' /boot/config.txt) ]]; then + echo "enable_uart=1 already in /boot/config.txt" + else + echo "adding enable_uart=1 to /boot/config.txt" + sudo sh -c 'echo "\nenable_uart=1" >> /boot/config.txt' + fi + + if [[ $(grep 'dtoverlay=disable-bt' /boot/config.txt) ]]; then + echo "dtoverlay=disable-bt already in /boot/config.txt" + else + echo "adding dtoverlay=disable-bt to /boot/config.txt" + sudo sh -c 'echo "\ndtoverlay=disable-bt" >> /boot/config.txt' + fi + + if [[ $(grep 'dtoverlay=dwc2' /boot/config.txt) ]]; then + echo "dtoverlay=dwc2 aalready in /boot/config.txt" + else + echo "adding dtoverlay=dwc2 to /boot/config.txt" + sudo sh -c 'echo "\ndtoverlay=dwc2" >> /boot/config.txt' + fi + + if [[ $(grep 'modules-load=dwc2,g_ether' /boot/cmdline.txt) ]]; then + echo "modules-load=dwc2,g_ether already in /boot/cmdline.txt" + else + echo "adding modules-load=dwc2,g_ether to /boot/cmdline.txt" + sudo sed -i 's/ rootwait/ rootwait modules-load=dwc2,g_ether/g' /boot/cmdline.txt + fi + +CubeSatSim/config -c -n + +CubeSatSim/config -l -n + +echo "Would you like to reboot to complete the installation (y/n)?" + +read -r ANS + +if [ "$ANS" = "y" ]; then + + sudo reboot now + +else + + echo "The CubeSatSim software will start next time you reboot" + +fi diff --git a/log b/log new file mode 100755 index 00000000..f551c284 --- /dev/null +++ b/log @@ -0,0 +1,9 @@ +#!/bin/bash + +echo -e "\nLog file script for CubeSatSim\n" + +sudo journalctl -u cubesatsim > log.txt +cat log.txt + +echo -e "\nLog file also saved as /home/pi/CubeSatSim/log.txt" + diff --git a/python/voltcurrent.py b/python/voltcurrent.py index f34e9e52..5da9eeec 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -1,66 +1,354 @@ """Sample code and test for adafruit_in219""" # Reads all voltage and current sensors for two I2C buses - +import time import sys #import board import busio from adafruit_extended_bus import ExtendedI2C as I2C from adafruit_ina219 import INA219 +from adafruit_ina219 import ADCResolution, BusVoltageRange if __name__ == "__main__": # print 'Length: ', len(sys.argv) buses = [1, 3] # default I2C buses - config = False + single = False + one = two = three = four = five = six = seven = eight = 0 if (len(sys.argv)) > 1: -# print("There are arguments!") +# print("There are arguments!", file=sys.stderr) # if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): +# print(sys.argv[1]) buses[0] = int(sys.argv[1], base=10) if (len(sys.argv)) > 2: buses[1] = int(sys.argv[2], base=10) if (len(sys.argv)) > 3: - if sys.argv[3] == "c": - config = True - from adafruit_ina219 import ADCResolution, BusVoltageRange + if sys.argv[3] == "s": + single = True + +# print(buses[0]) +# print(buses[1]) addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus -# print("buses: ", buses, " addr: ", addresses) - for x in buses: - try: - i2c_bus = I2C(x) # Device is /dev/i2c-x - for y in addresses: - # print(x,y) - try: +# print("buses: ", buses, " addr: ", addresses, file=sys.stderr) + +# config + +# for x in buses: +# try: +# i2c_bus = I2C(x) # Device is /dev/i2c-x +# for y in addresses: +# print(x,y) +# try: # Create library object using Extended Bus I2C port -# print("bus: ", x, " addr: ", y) - if x == 0 and y == 0x45: +# print("bus: ", x, " addr: ", y) +# if x == 0 and y == 0x45: # print("Reading INA219 in MoPower Board") - i2c_bus = I2C(1) - ina219 = INA219(i2c_bus, 0x4a) - else: - ina219 = INA219(i2c_bus, y) - -# print("ina219 test") - if config: -# print("Configuring") +# i2c_bus = I2C(1) +# ina219 = INA219(i2c_bus, 0x4a) +# else: +# ina219 = INA219(i2c_bus, y) +# print("ina219 test") + +# print("Configuring") # optional : change configuration to use 32 samples averaging for both bus voltage and shunt voltage - ina219.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S +# ina219.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S +# ina219.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S # optional : change voltage range to 16V - ina219.bus_voltage_range = BusVoltageRange.RANGE_16V +# ina219.bus_voltage_range = BusVoltageRange.RANGE_16V +# except: +# print("Python Error 2", file=sys.stderr, flush=True) +# except: +# print("Python Error 1", file=sys.stderr, flush=True) +# No try checking yet + +# if buses[0] == 0 and addresses[0] == 0x45: +# print("Reading INA219 in MoPower Board") +# ina219_one = INA219(I2C(1), 0x4a) +# else: + if (buses[0] != -1): + try: + i2c_one = I2C(buses[0]) + try: + ina219_one = INA219(i2c_one, addresses[0]) + ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + one = 1 + except: +# print("Python Error 3", file=sys.stderr, flush=True) + one = 0 + try: + ina219_two = INA219(i2c_one, addresses[1]) + ina219_two.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_two.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + two = 1 + except: +# print("Python Error 3", file=sys.stderr, flush=True) + two = 0 + + try: + ina219_three = INA219(i2c_one, addresses[2]) + ina219_three.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_three.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + three = 1 + except: +# print("Python Error 3", file=sys.stderr, flush=True) + three = 0 + + try: + ina219_four= INA219(i2c_one, addresses[3]) + ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + four = 1 + except: + four = 0 +# print("Python Error 3", file=sys.stderr, flush=True) + except: + print("Python Error 5", file=sys.stderr, flush=True) + + if (buses[1] != -1): + try: + i2c_two = I2C(buses[1]) +# print(i2c_two) + try: + ina219_five = INA219(i2c_two, addresses[0]) + ina219_five.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_five.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + five = 1 + except: +# print("Python Error 3", file=sys.stderr, flush=True) + five = 0 + try: + ina219_six = INA219(i2c_two, addresses[1]) + ina219_six.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_six.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + six = 1 + except: +# print("Python Error 3", file=sys.stderr, flush=True) + six = 0 + try: + ina219_seven = INA219(i2c_two, addresses[2]) + ina219_seven.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_seven.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + seven = 1 + except: +# print("Python Error 3", file=sys.stderr, flush=True) + seven = 0 + try: + ina219_eight = INA219(i2c_two, addresses[3]) + ina219_eight.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_eight.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + eight = 1 + except: +# print("Python Error 3", file=sys.stderr, flush=True) + eight = 0 + except: + print("Python Error 5", file=sys.stderr, flush=True) + + while True: + error = 0 + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + except: + + try: + ina219_one = INA219(i2c_one, addresses[0]) + ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + error = 1 + + except: +# print("Python Error 3", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') + except: + + try: + ina219_two = INA219(i2c_one, addresses[1]) + ina219_two.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_two.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') + error = 1 + + except: +# print("Python Error 3", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - bus_voltage = ina219.bus_voltage # voltage on V- (load side) -# shunt_voltage = ina219.shunt_voltage # voltage between V+ and V- across the shunt - current = ina219.current # current in mA - if x == 0 and y == 0x45: - current = current * 10 -# INA219 measure bus voltage on the load side. So PSU voltage = bus_voltage + shunt_voltage -# print("{:6.3f}".format(bus_voltage + shunt_voltage)) - print("{:6.3f} ".format(bus_voltage), "{:6.3f} ".format(current) , end = '') - except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') + except: + + try: + ina219_three = INA219(i2c_one, addresses[2]) + ina219_three.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_three.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') + error = 1 + + except: +# print("Python Error 3", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') + except: + + try: + ina219_four= INA219(i2c_one, addresses[3]) + ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') + error = 1 + + except: + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), "{:6.3f} ".format(0), "{:6.3f} ".format(0), "{:6.3f} ".format(0), "{:6.3f} ".format(0), "{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') -# pass - print(" ") + + try: + ina219_five = INA219(i2c_two, addresses[0]) + ina219_five.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_five.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') + error = 1 + + except: +# print("Python Error 3", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + except: + + try: + ina219_six = INA219(i2c_two, addresses[1]) + ina219_six.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_six.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + error = 1 + + except: +# print("Python Error 3", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') + except: + + try: + ina219_seven = INA219(i2c_two, addresses[2]) + ina219_seven.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_seven.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') + error = 1 + + except: +# print("Python Error 3", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current), end = '') + except: + + try: + ina219_eight = INA219(i2c_two, addresses[3]) + ina219_eight.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_eight.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + time.sleep(0.001) + ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V + time.sleep(0.01) + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current), end = '') + error = 1 + + except: +# print("Python Error 3", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + if (error == 0): + print(" ") + else: + print("Python Error Recovered!") + + if not single: + inp = input() +# print(inp) + else: + break + + diff --git a/rpitx.py b/rpitx.py index 1db4dbb2..0184f54c 100644 --- a/rpitx.py +++ b/rpitx.py @@ -3,73 +3,138 @@ import RPi.GPIO as GPIO import subprocess import time -import os +#import os import sys +from os import system GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) -GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) +GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) transmit = False if GPIO.input(12) == False: transmit = True -if GPIO.input(27) == False: +if GPIO.input(22) == False: transmit = True - txLed = 22 - txLedOn = False - txLedOff = True + txLed = 27 + txLedOn = 0 + txLedOff = 1 else: txLed = 27 - txLedOn = True - txLedOff = False - + txLedOn = 1 + txLedOff = 0 + GPIO.setup(txLed, GPIO.OUT) - +print(txLedOn) +print(txLed) +GPIO.setup(27, GPIO.OUT) +GPIO.output(27, 0) + print(transmit) -file = open("/home/pi/CubeSatSim/sim.cfg") -callsign = file.readline().split(" ")[0] +try: + file = open("/home/pi/CubeSatSim/sim.cfg") + callsign = file.readline().split(" ")[0] +except: + callsign = "AMSAT" print(callsign) +#GPIO.output(27, 1); GPIO.output(txLed, txLedOn); -os.system("echo 'de " + callsign + "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") +system("echo 'de " + callsign + "' > id.txt && sudo gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") +#GPIO.output(27, 0); GPIO.output(txLed, txLedOff); time.sleep(2) if __name__ == "__main__": - if (transmit): + if (transmit): - print 'Length: ', len(sys.argv) +# print 'Length: ', len(sys.argv) - if (len(sys.argv)) > 1: -# print("There are arguments!") - if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): - print("AFSK") - while True: - time.sleep(5) - elif (('s' == sys.argv[1]) or ('sstv' in sys.argv[1])): - print("SSTV") - GPIO.output(txLed, txLedOn); - os.system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") -# while True: -# GPIO.output(txLed, txLedOff); -# print("Sleeping") -# time.sleep(10) -# print("Transmitting SSTV") -# GPIO.output(txLed, txLedOn); -# os.system("cat /home/pi/CubeSatSim/wav/sstv.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") - elif (('b' == sys.argv[1]) or ('bpsk' in sys.argv[1])): - print("BPSK") - os.system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float") + if (len(sys.argv)) > 1: +# print("There are arguments!") + if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): + print("AFSK") + time.sleep(4) + for x in range(5): + system("sudo gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") + time.sleep(4) + while True: + try: + f = open("/home/pi/CubeSatSim/ready") + system("sudo gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") + f.close() + system("sudo rm ready") + time.sleep(0.5) + except: + time.sleep(0.5) + elif (('s' == sys.argv[1]) or ('sstv' in sys.argv[1])): + print("SSTV") + try: + from picamera import PiCamera +# from pysstv.sstv import SSTV + camera = PiCamera() + print("Camera present") + camera_present = 1 + camera.close() + except: + print("No camera") + camera_present = 0 + try: + file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") + print("First SSTV stored image detected") + system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") + print ("Sending SSTV image") + GPIO.output(txLed, txLedOn); + system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + GPIO.output(txLed, txLedOff) +# time.sleep(1) + except: + print("No first image") +# while 1: + GPIO.output(txLed, txLedOff) + if (camera_present == 1): + while 1: + system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") + print("Photo taken") + system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg") + print ("Sending SSTV image") + GPIO.output(txLed, txLedOn); + system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + GPIO.output(txLed, txLedOff) + time.sleep(1) + else: + try: + file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") + print("Second SSTV stored image detected") + system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") + while 1: + print ("Sending SSTV image") + GPIO.output(txLed, txLedOn); + system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + GPIO.output(txLed, txLedOff) + time.sleep(5) + except: + system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 &") + while 1: + GPIO.output(txLed, txLedOn) + time.sleep(60) + GPIO.output(txLed, txLedOff) + time.sleep(1) + + elif (('b' == sys.argv[1]) or ('bpsk' in sys.argv[1])): + print("BPSK") + system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float") + else: + print("FSK") + 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("FSK") + 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("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("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.") - while True: - time.sleep(5) + print("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.") + while 1: + time.sleep(5) diff --git a/rpitx.sh b/rpitx.sh index 409f9caf..afc736a2 100755 --- a/rpitx.sh +++ b/rpitx.sh @@ -8,18 +8,18 @@ if [ "$1" = "c" ]; then echo $y if [ $(($y % 4)) = 3 ]; then echo "Mode is continuous AFSK" - python -u /home/pi/CubeSatSim/rpitx.py a + python3 -u /home/pi/CubeSatSim/rpitx.py a elif [ $(($y % 4)) = 1 ]; then echo "Mode is continuous BPSK" - python -u /home/pi/CubeSatSim/rpitx.py b + python3 -u /home/pi/CubeSatSim/rpitx.py b elif [ $(($y % 4)) = 2 ]; then echo "Mode is continuous SSTV" - python -u /home/pi/CubeSatSim/rpitx.py s + python3 -u /home/pi/CubeSatSim/rpitx.py s else echo "Mode is continuous FSK" - python -u /home/pi/CubeSatSim/rpitx.py f + python3 -u /home/pi/CubeSatSim/rpitx.py f fi else - python -u /home/pi/CubeSatSim/rpitx.py $1 + python3 -u /home/pi/CubeSatSim/rpitx.py $1 fi diff --git a/spacecraft/FoxTelem_11a/CubeSatSim_PSK_maxtelemetry.csv b/spacecraft/FoxTelem_11a/CubeSatSim_PSK_maxtelemetry.csv new file mode 100644 index 00000000..c55ada57 --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSatSim_PSK_maxtelemetry.csv @@ -0,0 +1,61 @@ +60,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION +0,MAX,BATT_A_V,12,V,4,NONE,4,1,3,Cell A,Battery pair A voltage (0-2.5V scale) +1,MAX,BATT_B_V,12,V,4,NONE,4,2,3,Cell A + B,Battery pairs A+B voltage (0-3.3V scale) +2,MAX,BATT_V,12,V,cubesatsim_voltage|FLOAT2,NONE,4,1,3,Cell A+B+C Voltage,Battery A+B+C voltage (0-5.0V scale) +3,MAX,SatelliteXAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,7,4,3,Acceleration,Acceleration around X Axis +4,MAX,SatelliteYAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,8,4,3,Acceleration,Acceleration around Y Axis +5,MAX,SatelliteZAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,9,4,3,Acceleration,Acceleration around Z Axis +6,MAX,battCurr,12,mA,cubesatsim_current,NONE,4,2,3,Current,Total Battery DC current +7,MAX,Temperature,12,C,cubesatsim_temperature,NONE,6,2,3,Temp,STEM Payload Sensor Temperature +8,MAX,posXv,12,V,cubesatsim_voltage|FLOAT2,NONE,7,1,3,Voltage,+X solar Panel voltage +9,MAX,posYv,12,V,cubesatsim_voltage|FLOAT2,NONE,8,1,3,Voltage,+Y solar Panel voltage +10,MAX,posZv,12,V,cubesatsim_voltage|FLOAT2,NONE,9,1,3,Voltage,+Z solar Panel voltage +11,MAX,negXv,12,V,cubesatsim_voltage|FLOAT2,NONE,10,1,3,Voltage,-X solar Panel voltage +12,MAX,negYv,12,V,cubesatsim_voltage|FLOAT2,NONE,11,1,3,Voltage,-Y solar Panel voltage +13,MAX,negZv,12,V,cubesatsim_voltage|FLOAT2,NONE,12,1,3,Voltage,-Z solar Panel voltage +14,MAX,posXi,12,mA,cubesatsim_current,NONE,7,2,3,Current,+X solar Panel current +15,MAX,posYi,12,mA,cubesatsim_current,NONE,8,2,3,Current,+Y solar Panel current +16,MAX,posZi,12,mA,cubesatsim_current,NONE,9,2,3,Current,+Z solar Panel current +17,MAX,negXi,12,mA,cubesatsim_current,NONE,10,2,3,Current,-X solar Panel current +18,MAX,negYi,12,mA,cubesatsim_current,NONE,11,2,3,Current,-Y solar Panel current +19,MAX,negZi,12,mA,cubesatsim_current,NONE,12,2,3,Current,-Z solar Panel current +20,MAX,PSUVoltage,12,V,cubesatsim_voltage|FLOAT2,NONE,5,1,3,Board Voltage,Power Supply Voltage +21,MAX,spin,12,rpm,cubesatsim_rpm,NONE,3,1,3,Spacecraft Spin,Calculated spin rate using solar cells +22,MAX,Pressure,12,hPa,cubesatsim_pressure,NONE,6,3,3,Pressure,STEM Payload Sensor Pressure +23,MAX,Altitude,12,m,cubesatsim_altitude,NONE,6,4,3,Altitude,STEM Payload Sensor Altitude +24,MAX,Resets,12,-,12,NONE,3,2,3,Reset Count, Software Reset Count +25,MAX,rssi,12,dBm,cubesatsim_rssi|INT,NONE,1,1,3,RSSI,Received Signal Strength Indication +26,MAX,IHUcpuTemp,12,C,cubesatsim_temperature,NONE,2,1,3,Temperature,Internal Temperature of IHU +27,MAX,SatelliteXAxisAngularVelocity,12,dps,cubesatsim_rotation,NONE,7,3,3,Rotation,Angular Veolcity around X Axis +28,MAX,SatelliteYAxisAngularVelocity,12,dps,cubesatsim_rotation,NONE,8,3,3,Rotation,Angular Veolcity around Y Axis +29,MAX,SatelliteZAxisAngularVelocity,12,dps,cubesatsim_rotation,NONE,9,3,3,Rotation,Angular Veolcity around Z Axis +30,MAX,Humidity,12,%,cubesatsim_temperature,NONE,6,5,3,Humidity,Humidity +31,MAX,PSUCurrent,12,mA,cubesatsim_current,NONE,5,2,3,Current,Power Supply DC Current +32,MAX,Sensor1,12,signed raw,cubesatsim_sensor2|INT,NONE,6,6,3,Sensor 1,STEM Payload Extra Sensor 1 +33,MAX,Sensor2,12,signed raw,cubesatsim_sensor3|FLOAT2,NONE,6,7,3,Sensor 2,STEM Payload Extra Sensor 2 +34,MAX,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted +35,MAX,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V +36,MAX,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected +37,MAX,rf6,12,-,0,NONE,0,0,0,None,None +38,MAX,rf7,12,-,0,NONE,0,0,0,None,None +39,MAX,MuxTest,12,V,43,NONE,7,5,3,Sensor Power,Sensor Power Voltage at the ICR +40,MAX,LtVGACtl,12,V,42,NONE,1,4,3,VGA Control,Control Voltage to the Variable Gain Amplifier (VGA) +41,MAX,pad,4,-,34,NONE,0,0,0,None,Unused +42,MAX,IHUdiagData,32,-,18,NONE,3,2,0,Diagnostic Info,Diagnostic Data on IHU Performance +43,MAX,STEMPayloadStatus,1,-,17,NONE,6,1,0,STEM Payload Status, STEM Payload STEM Payload Board Failure Indicator +44,MAX,Nominal Mode,1,-,17,NONE,3,2,0,Nominal Mode, Nominal Mode (Not Safe Mode) +45,MAX,expFailure2,1,-,17,NONE,6,7,0,Exp 2,Experiment 2 Failure Indicator +46,MAX,expFailure3,1,-,17,NONE,6,8,0,Exp 3,Experiment 3 Failure Indicator +47,MAX,I2CfailureBatt,1,-,17,NONE,2,2,0,Battery I2C,Battery I2C Bus failure indicator +48,MAX,I2CfailurePSU1,1,-,17,NONE,2,3,0,PSU1 I2C,PSU2 I2C Bus failure indicator +49,MAX,I2CfailurePSU2,1,-,17,NONE,2,4,0,PSU2 I2C,PSU2 I2C Bus failure indicator +50,MAX,TLMresets,4,-,1,NONE,2,6,0,Ground Resets,Number of times command stations reset stored telemetry +51,MAX,RxAntDeploy,1,-,16,NONE,1,3,0,RX Antenna,2m Antenna status +52,MAX,TxAntDeploy,2,-,16,NONE,1,2,0,TX Antenna,70cm Antenna status +53,MAX,I2CfailureRF,1,-,17,NONE,2,5,0,RF I2C,RF I2C Bus failure indicator +54,MAX,pad1,1,-,0,NONE,0,0,0,NONE,Filler +55,MAX,wodSize,8,000s,36,NONE,3,3,0,WOD Stored,Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds +56,MAX,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information +57,MAX,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset +58,MAX,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset +59,MAX,pad2,28,-,0,NONE,0,0,0,NONE,Filler diff --git a/spacecraft/FoxTelem_11a/CubeSatSim_PSK_mintelemetry.csv b/spacecraft/FoxTelem_11a/CubeSatSim_PSK_mintelemetry.csv new file mode 100644 index 00000000..690b9da2 --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSatSim_PSK_mintelemetry.csv @@ -0,0 +1,61 @@ +60,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION +0,MIN,BATT_A_V,12,V,4,NONE,4,1,3,Cell A,Battery pair A voltage (0-2.5V scale) +1,MIN,BATT_B_V,12,V,4,NONE,4,2,3,Cell A + B,Battery pairs A+B voltage (0-3.3V scale) +2,MIN,BATT_V,12,V,cubesatsim_voltage|FLOAT2,NONE,4,1,3,Cell A+B+C Voltage,Battery A+B+C voltage (0-5.0V scale) +3,MIN,SatelliteXAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,7,4,3,Acceleration,Acceleration around X Axis +4,MIN,SatelliteYAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,8,4,3,Acceleration,Acceleration around Y Axis +5,MIN,SatelliteZAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,9,4,3,Acceleration,Acceleration around Z Axis +6,MIN,battCurr,12,mA,cubesatsim_current,NONE,4,2,3,Current,Total Battery DC current +7,MIN,Temperature,12,C,cubesatsim_temperature,NONE,6,2,3,Temp,STEM Payload Sensor Temperature +8,MIN,posXv,12,V,cubesatsim_voltage|FLOAT2,NONE,7,1,3,Voltage,+X solar Panel voltage +9,MIN,posYv,12,V,cubesatsim_voltage|FLOAT2,NONE,8,1,3,Voltage,+Y solar Panel voltage +10,MIN,posZv,12,V,cubesatsim_voltage|FLOAT2,NONE,9,1,3,Voltage,+Z solar Panel voltage +11,MIN,negXv,12,V,cubesatsim_voltage|FLOAT2,NONE,10,1,3,Voltage,-X solar Panel voltage +12,MIN,negYv,12,V,cubesatsim_voltage|FLOAT2,NONE,11,1,3,Voltage,-Y solar Panel voltage +13,MIN,negZv,12,V,cubesatsim_voltage|FLOAT2,NONE,12,1,3,Voltage,-Z solar Panel voltage +14,MIN,posXi,12,mA,cubesatsim_current,NONE,7,2,3,Current,+X solar Panel current +15,MIN,posYi,12,mA,cubesatsim_current,NONE,8,2,3,Current,+Y solar Panel current +16,MIN,posZi,12,mA,cubesatsim_current,NONE,9,2,3,Current,+Z solar Panel current +17,MIN,negXi,12,mA,cubesatsim_current,NONE,10,2,3,Current,-X solar Panel current +18,MIN,negYi,12,mA,cubesatsim_current,NONE,11,2,3,Current,-Y solar Panel current +19,MIN,negZi,12,mA,cubesatsim_current,NONE,12,2,3,Current,-Z solar Panel current +20,MIN,PSUVoltage,12,V,cubesatsim_voltage|FLOAT2,NONE,5,1,3,Board Voltage,Power Supply Voltage +21,MIN,spin,12,rpm,cubesatsim_rpm,NONE,3,1,3,Spacecraft Spin,Calculated spin rate using solar cells +22,MIN,Pressure,12,hPa,cubesatsim_pressure,NONE,6,3,3,Pressure,STEM Payload Sensor Pressure +23,MIN,Altitude,12,m,cubesatsim_altitude,NONE,6,4,3,Altitude,STEM Payload Sensor Altitude +24,MIN,Resets,12,-,12,NONE,3,2,3,Reset Count, Software Reset Count +25,MIN,rssi,12,dBm,cubesatsim_rssi|INT,NONE,1,1,3,RSSI,Received Signal Strength Indication +26,MIN,IHUcpuTemp,12,C,cubesatsim_temperature,NONE,2,1,3,Temperature,Internal Temperature of IHU +27,MIN,SatelliteXAxisAngularVelocity,12,dps,cubesatsim_rotation,NONE,7,3,3,Rotation,Angular Veolcity around X Axis +28,MIN,SatelliteYAxisAngularVelocity,12,dps,cubesatsim_rotation,NONE,8,3,3,Rotation,Angular Veolcity around Y Axis +29,MIN,SatelliteZAxisAngularVelocity,12,dps,cubesatsim_rotation,NONE,9,3,3,Rotation,Angular Veolcity around Z Axis +30,MIN,Humidity,12,%,cubesatsim_temperature,NONE,6,5,3,Humidity,Humidity +31,MIN,PSUCurrent,12,mA,cubesatsim_current,NONE,5,2,3,Current,Power Supply DC Current +32,MIN,Sensor1,12,signed raw,cubesatsim_sensor2|INT,NONE,6,6,3,Sensor 1,STEM Payload Extra Sensor 1 +33,MIN,Sensor2,12,signed raw,cubesatsim_sensor3|FLOAT2,NONE,6,7,3,Sensor 2,STEM Payload Extra Sensor 2 +34,MIN,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted +35,MIN,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V +36,MIN,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected +37,MIN,rf6,12,-,0,NONE,0,0,0,None,None +38,MIN,rf7,12,-,0,NONE,0,0,0,None,None +39,MIN,MuxTest,12,V,43,NONE,7,5,3,Sensor Power,Sensor Power Voltage at the ICR +40,MIN,LtVGACtl,12,V,42,NONE,1,4,3,VGA Control,Control Voltage to the Variable Gain Amplifier (VGA) +41,MIN,pad,4,-,34,NONE,0,0,0,None,Unused +42,MIN,IHUdiagData,32,-,18,NONE,3,2,0,Diagnostic Info,Diagnostic Data on IHU Performance +43,MIN,STEMPayloadStatus,1,-,17,NONE,6,1,0,STEM Payload Status, STEM Payload STEM Payload Board Failure Indicator +44,MIN,Nominal Mode,1,-,17,NONE,3,2,0,Nominal Mode, Nominal Mode (Not Safe Mode) +45,MIN,expFailure2,1,-,17,NONE,6,7,0,Exp 2,Experiment 2 Failure Indicator +46,MIN,expFailure3,1,-,17,NONE,6,8,0,Exp 3,Experiment 3 Failure Indicator +47,MIN,I2CfailureBatt,1,-,17,NONE,2,2,0,Battery I2C,Battery I2C Bus failure indicator +48,MIN,I2CfailurePSU1,1,-,17,NONE,2,3,0,PSU1 I2C,PSU2 I2C Bus failure indicator +49,MIN,I2CfailurePSU2,1,-,17,NONE,2,4,0,PSU2 I2C,PSU2 I2C Bus failure indicator +50,MIN,TLMresets,4,-,1,NONE,2,6,0,Ground Resets,Number of times command stations reset stored telemetry +51,MIN,RxAntDeploy,1,-,16,NONE,1,3,0,RX Antenna,2m Antenna status +52,MIN,TxAntDeploy,2,-,16,NONE,1,2,0,TX Antenna,70cm Antenna status +53,MIN,I2CfailureRF,1,-,17,NONE,2,5,0,RF I2C,RF I2C Bus failure indicator +54,MIN,pad1,1,-,0,NONE,0,0,0,NONE,Filler +55,MIN,wodSize,8,000s,36,NONE,3,3,0,WOD Stored,Number of WOD data payloads kept for each of Science and Housekeeping. In hundreds +56,MIN,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information +57,MIN,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset +58,MIN,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset +59,MIN,pad2,28,-,0,NONE,0,0,0,NONE,Filler diff --git a/spacecraft/FoxTelem_11a/CubeSatSim_PSK_rttelemetry.csv b/spacecraft/FoxTelem_11a/CubeSatSim_PSK_rttelemetry.csv new file mode 100644 index 00000000..98b1f107 --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSatSim_PSK_rttelemetry.csv @@ -0,0 +1,61 @@ +60,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION +0,realTime,BATT_A_V,12,V,cubesatsim_voltage|FLOAT2,NONE,4,1,3,Cell A,Battery A voltage (0-2.5V scale) +1,realTime,BATT_B_V,12,V,cubesatsim_voltage|FLOAT2,NONE,4,2,3,Cell A+B,Battery A+B voltage (0-3.3V scale) +2,realTime,BATT_V,12,V,cubesatsim_voltage|FLOAT2,Battery,4,1,3,Cell A+B+C Voltage,Battery A+B+C voltage (0-5.0V scale) +3,realTime,SatelliteXAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,+X Panel,7,4,3,Acceleration,Acceleration around X Axis +4,realTime,SatelliteYAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,+Y Panel,8,4,3,Acceleration,Acceleration around Y Axis +5,realTime,SatelliteZAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,+Z Panel,9,4,3,Acceleration,Acceleration around Z Axis +6,realTime,battCurr,12,mA,cubesatsim_current,Battery,4,2,3,Current,Total Battery DC current +7,realTime,Temperature,12,C,cubesatsim_temperature,Experiments,6,2,3,Temperature,STEM Payload sensor temperature +8,realTime,posXv,12,V,cubesatsim_voltage|FLOAT2,+X Panel,7,1,3,Voltage,+X solar panel voltage +9,realTime,posYv,12,V,cubesatsim_voltage|FLOAT2,+Y Panel,8,1,3,Voltage,+Y solar panel voltage +10,realTime,posZv,12,V,cubesatsim_voltage|FLOAT2,+Z Panel,9,1,3,Voltage,+Z solar panel voltage +11,realTime,negXv,12,V,cubesatsim_voltage|FLOAT2,-X Panel,10,1,3,Voltage,-X solar panel voltage +12,realTime,negYv,12,V,cubesatsim_voltage|FLOAT2,-Y Panel,11,1,3,Voltage,-Y solar panel voltage +13,realTime,negZv,12,V,cubesatsim_voltage|FLOAT2,-Z Panel,12,1,3,Voltage,-Z solar panel voltage +14,realTime,posXi,12,mA,cubesatsim_current,+X Panel,7,2,3,Current,+X solar panel current +15,realTime,posYi,12,mA,cubesatsim_current,+Y Panel,8,2,3,Current,+Y solar panel current +16,realTime,posZi,12,mA,cubesatsim_current,+Z Panel,9,2,3,Current,+Z solar panel current +17,realTime,negXi,12,mA,cubesatsim_current,-X Panel,10,2,3,Current,-X solar panel current +18,realTime,negYi,12,mA,cubesatsim_current,-Y Panel,11,2,3,Current,-Y solar panel current +19,realTime,negZi,12,mA,cubesatsim_current,-Z Panel,12,2,3,Current,-Z solar panel current +20,realTime,PSUVoltage,12,V,cubesatsim_voltage|FLOAT2,PSU,5,1,3,Voltage,Power Supply voltage +21,realTime,spin,12,rpm,cubesatsim_rpm,Computer Software,3,1,3,Spacecraft Spin,Calculated spin rate using solar cells +22,realTime,Pressure,12,hPa,cubesatsim_pressure,Experiments,6,3,3,Pressure,STEM Payload sensor pressure +23,realTime,Altitude,12,m,cubesatsim_altitude,Experiments,6,4,3,Altitude,STEM Payload sensor altitude +24,realTime,Resets,12,-,12,NONE,3,2,3,Reset Count, Software Reset Count +25,realTime,rssi,12,dBm,cubesatsim_rssi|INT,Radio,1,1,3,RSSI,Received Signal Strength Indication +26,realTime,IHUcpuTemp,12,C,cubesatsim_temperature,Computer Hardware,2,1,3,Temperature,Internal temperature of IHU from Pi +27,realTime,SatelliteXAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,+X Panel,7,3,3,Rotation,Angular veolcity around X Axis +28,realTime,SatelliteYAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,+Y Panel,8,3,3,Rotation,Angular veolcity around Y Axis +29,realTime,SatelliteZAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,+Z Panel,9,3,3,Rotation,Angular veolcity around Z Axis +30,realTime,Humidity,12,%,cubesatsim_temperature,Experiments,6,5,3,Humidity,Humidity +31,realTime,PSUCurrent,12,mA,cubesatsim_current,PSU,5,2,3,Current,Power Supply DC Current +32,realTime,Sensor1,12,signed raw,cubesatsim_sensor2|INT,Experiments,6,6,3,Sensor 1,STEM Payload extra Sensor 1 +33,realTime,Sensor2,12,signed scaled,cubesatsim_sensor3|FLOAT2,Experiments,6,7,3,Sensor 2,STEM Payload extra Sensor 2 +34,realTime,STEMPayloadStatus,1,-,17,Experiments,6,1,0,STEM Payload, STEM Payload STEM Payload board failure indicator +35,realTime,Nominal Mode,1,-,17,Computer Software,3,2,0,Nominal Mode, Nominal Mode (Not Safe Mode) +36,realTime,SimulatedTelemetry,1,-,17,Computer Software,3,4,0,Simulated Telemetry,Simulated Telemetry indicator +37,realTime,PayloadStatus1,1,-,17,NONE,6,8,0,Exp 3,STEM Payload status 1 failure indicator +38,realTime,I2CBus0Failure,1,-,17,Computer Hardware,2,2,0,I2C Bus 0,I2C bus 0 failure indicator +39,realTime,I2CBus1Failure,1,-,17,Computer Hardware,2,3,0,I2C Bus 1,I2C bus 1 failure indicator +40,realTime,I2CBus3Failure,1,-,17,Computer Hardware,2,4,0,I2C Bus 3,I2C bus 3 failure indicator +41,realTime,CameraFailure,1,-,17,Computer Hardware,2,5,0,Camera,Camera failure indicator +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,2,-,16,Radio,1,2,0,TX Antenna,Transmit antenna status +45,realTime,ICR3VProt,12,V,43,NONE,7,2,3,3V Prot,ICR 3V Proteted +46,realTime,ICR2dot5V,12,V,43,NONE,7,3,3,2.5V,ICR 2.5V +47,realTime,ICR2dot5VProt,12,V,43,NONE,7,4,3,2.5V Prot,ICR 2.5V Protected +48,realTime,rf6,12,-,0,NONE,0,0,0,None,None +49,realTime,rf7,12,-,0,NONE,0,0,0,None,None +50,realTime,MuxTest,12,V,43,NONE,7,5,3,Sensor Power,Sensor Power Voltage at the ICR +51,realTime,LtVGACtl,12,V,42,NONE,1,4,3,VGA Control,Control Voltage to the Variable Gain Amplifier (VGA) +52,realTime,pad,4,-,34,NONE,0,0,0,None,Unused +53,realTime,IHUdiagData,32,-,18,NONE,3,2,0,Diagnostic Info,Diagnostic Data on IHU Performance +54,realTime,pad1,1,-,0,NONE,0,0,0,NONE,Filler +55,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 +56,realTime,swCmds,32,-,35,NONE,7,6,0,Diagnostic,ICR Diagnostic information +57,realTime,hwCmdCnt,6,-,1,NONE,7,7,0,HW Command Count,Number of hardware commands since last reset +58,realTime,swCmdCnt,6,-,1,NONE,7,8,0,SW Command Count,Number of software commands since last reset +59,realTime,pad2,28,-,0,NONE,0,0,0,NONE,Filler diff --git a/spacecraft/FoxTelem_11a/CubeSatSim_conversion_curves.csv b/spacecraft/FoxTelem_11a/CubeSatSim_conversion_curves.csv new file mode 100644 index 00000000..30f05985 --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSatSim_conversion_curves.csv @@ -0,0 +1,13 @@ +CurveName,a,bx,cx^2,dx^3,ex^4,fx^5,Description +cubesatsim_voltage,0,0.01,0,0,0,0,Converts voltages read from the INA219 sensors +cubesatsim_current,-2048,1,0,0,0,0,Converts positive and negative currents read from the INA219 sensors +cubesatsim_temperature,0,0.1,0,0,0,0,Converts temperature of Pi +cubesatsim_rotation,-2048,1,0,0,0,0,Converts positive and negative dps rotation +cubesatsim_acceleration,-20.48,0.01,0,0,0,0,Converts positive and negative g acceleration +cubesatsim_altitude,0,0.1,0,0,0,0,Converts altitude +cubesatsim_pressure,0,1,0,0,0,0,Converts pressure +cubesatsim_sensor1,0,1,0,0,0,0,Conversion of Sensor 1 +cubesatsim_sensor2,-2048,1,0,0,0,0,Conversion of Sensor 2 +cubesatsim_sensor3,-20.48,0.01,0,0,0,0,Conversion of Sensor 3 +cubesatsim_rpm,-204.8,0.1,0,0,0,0,Conversion of calculated RPM +cubesatsim_rssi,-2048,1,0,0,0,0,Conversion of Received Signal Strength diff --git a/spacecraft/FoxTelem_11a/CubeSatSim_maxtelemetry.csv b/spacecraft/FoxTelem_11a/CubeSatSim_maxtelemetry.csv new file mode 100644 index 00000000..57fe1706 --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSatSim_maxtelemetry.csv @@ -0,0 +1,47 @@ +46,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHOMAX_NAME,DESCRIPTION +0,MAX,BATT_A_V,12,V,cubesatsim_voltage|FLOAT2,NONE,0,0,3,Cell A,Battery A voltage (0-2.5V scale) +1,MAX,BATT_B_V,12,V,cubesatsim_voltage|FLOAT2,NONE,0,0,3,Cell A+B,Battery A+B voltage (0-3.3V scale) +2,MAX,BATT_V,12,V,cubesatsim_voltage|FLOAT2,NONE,4,1,3,Cell A+B+C Voltage,Battery A+B+C voltage (0-5.0V scale) +3,MAX,SatelliteXAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,7,4,3,Acceleration,Acceleration around X Axis +4,MAX,SatelliteYAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,8,4,3,Acceleration,Acceleration around Y Axis +5,MAX,SatelliteZAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,9,4,3,Acceleration,Acceleration around Z Axis +6,MAX,TOTAL_BATT_I,12,mA,cubesatsim_current,NONE,4,2,3,Current,Total Battery DC current +7,MAX,Temperature,12,C,cubesatsim_temperature,NONE,6,2,3,Temperature,STEM Payload Sensor Temperature +8,MAX,PANEL_PLUS_X_V,12,V,cubesatsim_voltage|FLOAT2,NONE,7,1,3,Voltage,+X Panel +9,MAX,PANEL_MINUS_X_V,12,V,cubesatsim_voltage|FLOAT2,NONE,10,1,3,Voltage,-X Panel +10,MAX,PANEL_PLUS_Y_V,12,V,cubesatsim_voltage|FLOAT2,NONE,8,1,3,Voltage,+Y Panel +11,MAX,PANEL_MINUS_Y_V,12,V,cubesatsim_voltage|FLOAT2,NONE,11,1,3,Voltage,-Y Panel +12,MAX,PANEL_PLUS_Z_V,12,V,cubesatsim_voltage|FLOAT2,NONE,9,1,3,Voltage,+Z Panel +13,MAX,PANEL_MINUS_Z_V,12,V,cubesatsim_voltage|FLOAT2,NONE,12,1,3,Voltage,-Z Panel +14,MAX,PANEL_PLUS_X_I,12,mA,cubesatsim_current,NONE,7,2,3,Current,+X Panel +15,MAX,PANEL_MINUS_X_I,12,mA,cubesatsim_current,NONE,10,2,3,Current,-X Panel +16,MAX,PANEL_PLUS_Y_I,12,mA,cubesatsim_current,NONE,8,2,3,Current,+Y Panel +17,MAX,PANEL_MINUS_Y_I,12,mA,cubesatsim_current,NONE,11,2,3,Current,-Y Panel +18,MAX,PANEL_PLUS_Z_I,12,mA,cubesatsim_current,NONE,9,2,3,Current,+Z Panel +19,MAX,PANEL_MINUS_Z_I,12,mA,cubesatsim_current,NONE,12,2,3,Current,-Z Panel +20,MAX,PSUVoltage,12,V,cubesatsim_voltage|FLOAT2,NONE,5,1,3,Voltage,Power Supply Voltage +21,MAX,SPIN,12,rpm,cubesatsim_rpm,NONE,3,1,3,Spacecraft Spin,Calculated spin rate using solar cells +22,MAX,Pressure,12,bar,cubesatsim_pressure,NONE,6,3,3,Pressure,STEM Payload Sensor Pressure +23,MAX,Altitude,12,m,cubesatsim_altitude,NONE,6,4,3,Altitude,STEM Payload Sensor Altitude +24,MAX,Resets,12,-,12,NONE,3,2,3,Reset Count, Software Reset Count +25,MAX,RSSI,12,dBm,cubesatsim_rssi|INT,NONE,1,1,3,RSSI,Received Signal Strength Indication +26,MAX,IHUTemperature,12,C,cubesatsim_temperature,NONE,2,1,3,Temperature,Internal Temperature of IHU +27,MAX,SatelliteXAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,NONE,7,3,3,Rotation,Angular Veolcity around X Axis +28,MAX,SatelliteYAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,NONE,8,3,3,Rotation,Angular Veolcity around Y Axis +29,MAX,SatelliteZAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,NONE,9,3,3,Rotation,Angular Veolcity around Z Axis +30,MAX,Humidity,12,%,cubesatsim_temperature,NONE,6,5,3,Sensor 1,STEM Payload Sensor Humidity +31,MAX,PSUCurrent,12,mA,cubesatsim_current,NONE,5,2,3,Current,Power Supply DC Current +32,MAX,Sensor1,12,signed raw,cubesatsim_sensor2|INT,NONE,6,6,3,Sensor 1,STEM Payload Extra Sensor 1 +33,MAX,Sensor2,12,signed scaled,cubesatsim_sensor3|FLOAT2,NONE,6,7,3,Sensor 2,STEM Payload Extra Sensor 2 +34,MAX,STEMPayloadStatus,1,-,17,NONE,6,1,0,STEM Payload Status,STEM Payload Board Status +35,MAX,Nominal Mode,1,-,17,NONE,3,2,0,Nominal Mode, Nominal Mode (Not Safe Mode) +36,MAX,PayloadStatus1,1,-,17,NONE,6,7,0,Exp 2,STEM Payload status 1 failure indicator +37,MAX,PayloadStatus2,1,-,17,NONE,6,8,0,Exp 3,STEM Payload status 2 failure indicator +38,MAX,I2CBus0Failure,1,-,17,NONE,2,2,0,I2C Bus 0,I2C bus 0 failure indicator +39,MAX,I2CBus1Failure,1,-,17,NONE,2,3,0,I2C Bus 1,I2C bus 1 failure indicator +40,MAX,I2CBus3Failure,1,-,17,NONE,2,4,0,I2C Bus 3,I2C bus 3 failure indicator +41,MAX,CameraFailure,1,-,17,NONE,2,5,0,Camera,Camera failure indicator +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,Pad,58,-,0,NONE,0,0,0,NONE,NONE diff --git a/spacecraft/FoxTelem_11a/CubeSatSim_mintelemetry.csv b/spacecraft/FoxTelem_11a/CubeSatSim_mintelemetry.csv new file mode 100644 index 00000000..006ab3ef --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSatSim_mintelemetry.csv @@ -0,0 +1,47 @@ +46,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHOMIN_NAME,DESCRIPTION +0,MIN,BATT_A_V,12,V,cubesatsim_voltage|FLOAT2,NONE,0,0,3,Cell A,Battery A voltage (0-2.5V scale) +1,MIN,BATT_B_V,12,V,cubesatsim_voltage|FLOAT2,NONE,0,0,3,Cell A+B,Battery A+B voltage (0-3.3V scale) +2,MIN,BATT_V,12,V,cubesatsim_voltage|FLOAT2,NONE,4,1,3,Cell A+B+C Voltage,Battery A+B+C voltage (0-5.0V scale) +3,MIN,SatelliteXAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,7,4,3,Acceleration,Acceleration around X Axis +4,MIN,SatelliteYAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,8,4,3,Acceleration,Acceleration around Y Axis +5,MIN,SatelliteZAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,NONE,9,4,3,Acceleration,Acceleration around Z Axis +6,MIN,TOTAL_BATT_I,12,mA,cubesatsim_current,NONE,4,2,3,Current,Total Battery DC current +7,MIN,Temperature,12,C,cubesatsim_temperature,NONE,6,2,3,Temperature,STEM Payload Sensor Temperature +8,MIN,PANEL_PLUS_X_V,12,V,cubesatsim_voltage|FLOAT2,NONE,7,1,3,Voltage,+X Panel +9,MIN,PANEL_MINUS_X_V,12,V,cubesatsim_voltage|FLOAT2,NONE,10,1,3,Voltage,-X Panel +10,MIN,PANEL_PLUS_Y_V,12,V,cubesatsim_voltage|FLOAT2,NONE,8,1,3,Voltage,+Y Panel +11,MIN,PANEL_MINUS_Y_V,12,V,cubesatsim_voltage|FLOAT2,NONE,11,1,3,Voltage,-Y Panel +12,MIN,PANEL_PLUS_Z_V,12,V,cubesatsim_voltage|FLOAT2,NONE,9,1,3,Voltage,+Z Panel +13,MIN,PANEL_MINUS_Z_V,12,V,cubesatsim_voltage|FLOAT2,NONE,12,1,3,Voltage,-Z Panel +14,MIN,PANEL_PLUS_X_I,12,mA,cubesatsim_current,NONE,7,2,3,Current,+X Panel +15,MIN,PANEL_MINUS_X_I,12,mA,cubesatsim_current,NONE,10,2,3,Current,-X Panel +16,MIN,PANEL_PLUS_Y_I,12,mA,cubesatsim_current,NONE,8,2,3,Current,+Y Panel +17,MIN,PANEL_MINUS_Y_I,12,mA,cubesatsim_current,NONE,11,2,3,Current,-Y Panel +18,MIN,PANEL_PLUS_Z_I,12,mA,cubesatsim_current,NONE,9,2,3,Current,+Z Panel +19,MIN,PANEL_MINUS_Z_I,12,mA,cubesatsim_current,NONE,12,2,3,Current,-Z Panel +20,MIN,PSUVoltage,12,V,cubesatsim_voltage|FLOAT2,NONE,5,1,3,Voltage,Power Supply Voltage +21,MIN,SPIN,12,rpm,cubesatsim_rpm,NONE,3,1,3,Spacecraft Spin,Calculated spin rate using solar cells +22,MIN,Pressure,12,bar,cubesatsim_pressure,NONE,6,3,3,Pressure,STEM Payload Sensor Pressure +23,MIN,Altitude,12,m,cubesatsim_altitude,NONE,6,4,3,Altitude,STEM Payload Sensor Altitude +24,MIN,Resets,12,-,12,NONE,3,2,3,Reset Count, Software Reset Count +25,MIN,RSSI,12,dBm,cubesatsim_rssi|INT,NONE,1,1,3,RSSI,Received Signal Strength Indication +26,MIN,IHUTemperature,12,C,cubesatsim_temperature,NONE,2,1,3,Temperature,Internal Temperature of IHU +27,MIN,SatelliteXAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,NONE,7,3,3,Rotation,Angular Veolcity around X Axis +28,MIN,SatelliteYAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,NONE,8,3,3,Rotation,Angular Veolcity around Y Axis +29,MIN,SatelliteZAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,NONE,9,3,3,Rotation,Angular Veolcity around Z Axis +30,MIN,Humidity,12,%,cubesatsim_temperature,NONE,6,5,3,Humidity,STEM Payload Sensor Humidity +31,MIN,PSUCurrent,12,mA,cubesatsim_current,NONE,5,2,3,Current,Power Supply DC Current +32,MIN,Sensor1,12,signed raw,cubesatsim_sensor2|INT,NONE,6,6,3,Sensor 1,STEM Payload Extra Sensor 1 +33,MIN,Sensor2,12,signed scaled,cubesatsim_sensor3|FLOAT2,NONE,6,7,3,Sensor 2,STEM Payload Extra Sensor 2 +34,MIN,STEMPayloadStatus,1,-,17,NONE,6,1,0,STEM Payload Status,STEM Payload Board Status +35,MIN,Nominal Mode,1,-,17,NONE,3,2,0,Nominal Mode, Nominal Mode (Not Safe Mode) +36,MIN,PayloadStatus1,1,-,17,NONE,6,7,0,Exp 2,STEM Payload status 1 failure indicator +37,MIN,PayloadStatus2,1,-,17,NONE,6,8,0,Exp 3,STEM Payload status 2 failure indicator +38,MIN,I2CBus0Failure,1,-,17,NONE,2,2,0,I2C Bus 0,I2C bus 0 failure indicator +39,MIN,I2CBus1Failure,1,-,17,NONE,2,3,0,I2C Bus 1,I2C bus 1 failure indicator +40,MIN,I2CBus3Failure,1,-,17,NONE,2,4,0,I2C Bus 3,I2C bus 3 failure indicator +41,MIN,CameraFailure,1,-,17,NONE,2,5,0,Camera,Camera failure indicator +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,Pad,58,-,0,NONE,0,0,0,NONE,NONE diff --git a/spacecraft/FoxTelem_11a/CubeSatSim_rttelemetry.csv b/spacecraft/FoxTelem_11a/CubeSatSim_rttelemetry.csv new file mode 100644 index 00000000..a74fe830 --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSatSim_rttelemetry.csv @@ -0,0 +1,47 @@ +46,TYPE,FIELD,BITS,UNIT,CONVERSION,MODULE,MODULE_NUM,MODULE_LINE,LINE_TYPE,SHORT_NAME,DESCRIPTION +0,RT,BATT_A_V,12,V,cubesatsim_voltage|FLOAT2,NONE,0,0,3,Cell A,Battery A voltage (0-2.5V scale) +1,RT,BATT_B_V,12,V,cubesatsim_voltage|FLOAT2,NONE,0,0,3,Cell A+B,Battery A+B voltage (0-3.3V scale) +2,RT,BATT_V,12,V,cubesatsim_voltage|FLOAT2,Battery,4,1,3,Cell A+B+C Voltage,Battery A+B+C voltage (0-5.0V scale) +3,RT,SatelliteXAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,+X Panel,7,4,3,Acceleration,Acceleration around X Axis +4,RT,SatelliteYAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,+Y Panel,8,4,3,Acceleration,Acceleration around Y Axis +5,RT,SatelliteZAxisAcceleration,12,g,cubesatsim_acceleration|FLOAT2,+Z Panel,9,4,3,Acceleration,Acceleration around Z Axis +6,RT,TOTAL_BATT_I,12,mA,cubesatsim_current,Battery,4,2,3,Current,Total Battery DC current +7,RT,Temperature,12,C,cubesatsim_temperature,Experiments,6,2,3,Temperature,STEM Payload Sensor Temperature +8,RT,PANEL_PLUS_X_V,12,V,cubesatsim_voltage|FLOAT2,+X Panel,7,1,3,Voltage,+X Panel +9,RT,PANEL_MINUS_X_V,12,V,cubesatsim_voltage|FLOAT2,-X Panel,10,1,3,Voltage,-X Panel +10,RT,PANEL_PLUS_Y_V,12,V,cubesatsim_voltage|FLOAT2,+Y Panel,8,1,3,Voltage,+Y Panel +11,RT,PANEL_MINUS_Y_V,12,V,cubesatsim_voltage|FLOAT2,-Y Panel,11,1,3,Voltage,-Y Panel +12,RT,PANEL_PLUS_Z_V,12,V,cubesatsim_voltage|FLOAT2,+Z Panel,9,1,3,Voltage,+Z Panel +13,RT,PANEL_MINUS_Z_V,12,V,cubesatsim_voltage|FLOAT2,-Z Panel,12,1,3,Voltage,-Z Panel +14,RT,PANEL_PLUS_X_I,12,mA,cubesatsim_current,+X Panel,7,2,3,Current,+X Panel +15,RT,PANEL_MINUS_X_I,12,mA,cubesatsim_current,-X Panel,10,2,3,Current,-X Panel +16,RT,PANEL_PLUS_Y_I,12,mA,cubesatsim_current,+Y Panel,8,2,3,Current,+Y Panel +17,RT,PANEL_MINUS_Y_I,12,mA,cubesatsim_current,-Y Panel,11,2,3,Current,-Y Panel +18,RT,PANEL_PLUS_Z_I,12,mA,cubesatsim_current,+Z Panel,9,2,3,Current,+Z Panel +19,RT,PANEL_MINUS_Z_I,12,mA,cubesatsim_current,-Z Panel,12,2,3,Current,-Z Panel +20,RT,PSUVoltage,12,V,cubesatsim_voltage|FLOAT2,PSU,5,1,3,Voltage,Power Supply Voltage +21,RT,SPIN,12,rpm,cubesatsim_rpm,Computer Software,3,1,3,Spacecraft Spin,Calculated spin rate using solar cells +22,RT,Pressure,12,bar,cubesatsim_pressure,Experiments,6,3,3,Pressure,STEM Payload Sensor Pressure +23,RT,Altitude,12,m,cubesatsim_altitude,Experiments,6,4,3,Altitude,STEM Payload Sensor Altitude +24,RT,Resets,12,-,12,NONE,3,2,3,Reset Count, Software Reset Count +25,RT,RSSI,12,dBm,cubesatsim_rssi|INT,Radio,1,1,3,RSSI,Received Signal Strength Indication +26,RT,IHUTemperature,12,C,cubesatsim_temperature,Computer Hardware,2,1,3,Temperature,Internal Temperature of IHU +27,RT,SatelliteXAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,+X Panel,7,3,3,Rotation,Angular Veolcity around X Axis +28,RT,SatelliteYAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,+Y Panel,8,3,3,Rotation,Angular Veolcity around Y Axis +29,RT,SatelliteZAxisAngularVelocity,12,dps,cubesatsim_rotation|INT,+Z Panel,9,3,3,Rotation,Angular Veolcity around Z Axis +30,RT,Humidity,12,%,cubesatsim_temperature,Experiments,6,5,3,Humidity,STEM Payload Sensor Humidity +31,RT,PSUCurrent,12,mA,cubesatsim_current,PSU,5,2,3,Current,Power Supply DC Current +32,RT,Sensor1,12,signed raw,cubesatsim_sensor2|INT,Experiments,6,6,3,Sensor 1,STEM Payload Extra Sensor 1 +33,RT,Sensor2,12,signed scaled,cubesatsim_sensor3|FLOAT2,Experiments,6,7,3,Sensor 2,STEM Payload Extra Sensor 2 +34,RT,STEMPayloadStatus,1,-,17,Experiments,6,1,0,STEM Payload,STEM Payload Board Status +35,RT,Nominal Mode,1,-,17,Computer Software,3,2,0,Nominal Mode, Nominal Mode (Not Safe Mode) +36,RT,SimulatedTelemetry,1,-,17,Computer Software,3,4,0,Simulated Telemetry, Simulated Telemetry indicator +37,RT,PayloadStatus1,1,-,17,NONE,6,8,0,Exp 3,STEM Payload status 1 failure indicator +38,RT,I2CBus0Failure,1,-,17,Computer Hardware,2,2,0,I2C Bus 0,I2C bus 0 failure indicator +39,RT,I2CBus1Failure,1,-,17,Computer Hardware,2,3,0,I2C Bus 1,I2C bus 1 failure indicator +40,RT,I2CBus3Failure,1,-,17,Computer Hardware,2,4,0,I2C Bus 3,I2C bus 3 failure indicator +41,RT,CameraFailure,1,-,17,Computer Hardware,2,5,0,Camera,Camera failure indicator +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,Pad,58,-,0,NONE,0,0,0,NONE,NONE diff --git a/spacecraft/FoxTelem_11a/CubeSat_Simulator_PSK.MASTER b/spacecraft/FoxTelem_11a/CubeSat_Simulator_PSK.MASTER new file mode 100644 index 00000000..50a8b142 --- /dev/null +++ b/spacecraft/FoxTelem_11a/CubeSat_Simulator_PSK.MASTER @@ -0,0 +1,72 @@ +#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 +maxFreqBoundkHz=434950 +measurementsFileName=measurements.csv +memsRestValueX=2129 +memsRestValueY=2131 +memsRestValueZ=2103 +minFreqBoundkHz=434850 +passMeasurementsFileName=passmeasurements.csv +telemetryDownlinkFreqkHz=434900 +track=false +useIHUVBatt=false +numberOfSources=1 +source0.name=amsat.cubesat_simulator.ihu.bpsk +user_format=0 +useConversionCoeffs=true +conversionCurvesFileName=CubeSatSim_conversion_curves.csv diff --git a/sstv/sstv_image_1_320_x_256.jpg b/sstv/sstv_image_1_320_x_256.jpg new file mode 100644 index 00000000..0cfbf999 Binary files /dev/null and b/sstv/sstv_image_1_320_x_256.jpg differ diff --git a/sstv/sstv_image_2_320_x_256.jpg b/sstv/sstv_image_2_320_x_256.jpg new file mode 100644 index 00000000..7eb43eb9 Binary files /dev/null and b/sstv/sstv_image_2_320_x_256.jpg differ diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index 633f689d..e704d5b8 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -10,6 +10,8 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root +CPUAccounting=true +CPUQuota=5% [Install] WantedBy=default.target diff --git a/update b/update new file mode 100755 index 00000000..4e9e29b9 --- /dev/null +++ b/update @@ -0,0 +1,125 @@ +#!/bin/bash + +echo -e "\nupdate script for CubeSatSim\n" + +if [ "$1" = "u" ]; then + + sudo apt-get update && sudo apt-get dist-upgrade -y + + sudo apt-get install -y wiringpi git libasound2-dev i2c-tools cpulimit python-picamera python3-picamera build-essential libgd-dev libmagic-dev + +fi + +sudo sed -i 's/update.sh/update /g' /etc/motd + +sudo sed -i 's/installed and/installed\nand/g' /etc/motd + +sudo sed -i 's/more information/more\ninformation/g' /etc/motd + +sudo sed -i 's/update to/update\nto/g' /etc/motd + +cd /home/pi/CubeSatSim + +git pull > .updated + +make debug + +FLAG=0 + +if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then + echo "changed cubesatsim.service" + sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service + FLAG=1 +else + echo "no changes to cubesatsim.service" +fi + +if [[ $(diff systemd/rpitx.service /etc/systemd/system/rpitx.service) ]]; then + echo "changed rpitx.service" + sudo cp /home/pi/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service + FLAG=1 +else + echo "no changes to rpitx.service" +fi + +FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg +if [ ! -f "$FILE" ]; then + echo "Copying SSTV image 1" + cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg +fi + +FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg +if [ ! -f "$FILE" ]; then + echo "Copying SSTV image 2" + cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg +fi + +grep 'update' /home/pi/CubeSatSim/.updated +if [[ $(grep 'update' /home/pi/CubeSatSim/.updated) ]]; then + echo "update script updated, running again" + /home/pi/CubeSatSim/update +fi + +if [ $FLAG -eq 1 ]; then + echo "systemctl daemon-reload and restart" + sudo systemctl daemon-reload + sudo systemctl restart cubesatsim +else + grep 'changed' /home/pi/CubeSatSim/.updated + if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then + echo "systemctl restart cubesatsim" + sudo systemctl restart cubesatsim + else + echo "nothing to do" + fi +fi + +if [ ! -d "/home/pi/PiSSTVpp" ]; then + + sudo apt-get update && sudo apt-get dist-upgrade -y + + sudo apt-get install -y python-picamera python3-picamera build-essential libgd-dev libmagic-dev + + + cd + + git clone https://github.com/alanbjohnston/PiSSTVpp.git + + cd PiSSTVpp + + make pisstvpp + + cd + + + sudo raspi-config nonint do_camera 0 + + + FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg + if [ ! -f "$FILE" ]; then + echo "Copying SSTV image 1" + cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg + fi + + FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg + if [ ! -f "$FILE" ]; then + echo "Copying SSTV image 2" + cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg + fi + + echo "You need to reboot to complete the installation. Reboot now (y/n)?" + + read -r ANS + + if [ "$ANS" = "y" ]; then + + sudo reboot now + + else + + echo "The CubeSatSim software may not work correctly until you reboot." + + fi + + +fi