From 6da1423650e903497907c6476fddd2c08c3086f6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:02:03 -0500 Subject: [PATCH 001/210] moved initialization of FSK and BPSK values --- afsk/main.c | 56 +++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f4619065..1910d60e 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -489,31 +489,7 @@ int main(int argc, char * argv[]) { 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,6 +532,32 @@ int main(int argc, char * argv[]) { bufLen, bufLen / (samples * frameCnt), bitRate, bufLen / (samples * frameCnt * bitRate), samplePeriod); } + + + 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); + } + // sleep(1); // Delay 1 second ctr = 0; #ifdef DEBUG_LOGGING @@ -1046,10 +1048,10 @@ void get_tlm_fox() { #ifdef DEBUG_LOGGING printf("Tx LED On\n"); #endif - +/* while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); - +*/ digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING printf("Tx LED Off\n"); From 8b28cf1c17ab2ee043482adafaf638ef4cd3f117 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:07:05 -0500 Subject: [PATCH 002/210] added time printf --- afsk/main.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 1910d60e..8a9a1095 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -482,7 +482,7 @@ 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; @@ -532,11 +532,15 @@ int main(int argc, char * argv[]) { bufLen, bufLen / (samples * frameCnt), bitRate, bufLen / (samples * frameCnt * bitRate), samplePeriod); } - + long int loopTime; + loopTime = millis(); while (loop-- != 0) { - frames_sent++; - +// 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 @@ -1273,7 +1277,7 @@ void get_tlm_fox() { if (current[count1] > current_max[count1]) current_max[count1] = current[count1]; - printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); + // printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); } if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { @@ -1283,7 +1287,7 @@ void get_tlm_fox() { if (sensor[count1] > sensor_max[count1]) sensor_max[count1] = sensor[count1]; - printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); + // printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); } } @@ -1293,7 +1297,7 @@ void get_tlm_fox() { if (other[count1] > other_max[count1]) other_max[count1] = other[count1]; - printf("Other min %f max %f \n", other_min[count1], other_max[count1]); + // printf("Other min %f max %f \n", other_min[count1], other_max[count1]); } if (mode == FSK) { From 642f625363d5d3dda0cb0cf1513fd996bebda365 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:10:10 -0500 Subject: [PATCH 003/210] removed sensor printf --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 8a9a1095..2678b065 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1182,7 +1182,7 @@ void get_tlm_fox() { if (token != NULL) { sensor[count1] = (float) atof(token); #ifdef DEBUG_LOGGING - printf("sensor: %f ", sensor[count1]); + // printf("sensor: %f ", sensor[count1]); #endif token = strtok(NULL, space); } @@ -1686,10 +1686,10 @@ 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; } From af945401f796486fd4ff965b319988ccd2bf3220 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:16:33 -0500 Subject: [PATCH 004/210] moved sim_mode code --- afsk/main.c | 161 +++++++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 78 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 2678b065..899c2d58 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1065,7 +1065,88 @@ void get_tlm_fox() { sampleTime = (int) millis(); } else printf("first time - no sleep\n"); + + + float voltage[9], current[9], sensor[17], other[3]; + memset(voltage, 0, sizeof(voltage)); + memset(current, 0, sizeof(current)); + memset(sensor, 0, sizeof(sensor)); + memset(other, 0, sizeof(other)); + + if (sim_mode) { + // simulated telemetry + + double time = ((long int)millis() - time_start) / 1000.0; + + if ((time - eclipse_time) > period) { + eclipse = (eclipse == 1) ? 0 : 1; + eclipse_time = time; + 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); + + double Xv = eclipse * volts_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-0.2, 0.2); + double Yv = eclipse * volts_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2); + double Zv = 2.0 * eclipse * volts_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2); + // printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv); + + current[map[PLUS_X]] = (Xi >= 0) ? Xi : 0; + current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi); + current[map[PLUS_Y]] = (Yi >= 0) ? Yi : 0; + current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0f) * Yi); + current[map[PLUS_Z]] = (Zi >= 0) ? Zi : 0; + current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi); + + voltage[map[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1); + voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1); + voltage[map[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1); + voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1); + voltage[map[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1); + voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1); + + // printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); + + tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0f) : ((temp_min - tempS) / 50.0f); + tempS += +rnd_float(-1.0, 1.0); + // IHUcpuTemp = (int)((tempS + rnd_float(-1.0, 1.0)) * 10 + 0.5); + other[IHU_TEMP] = tempS; + + voltage[map[BUS]] = rnd_float(5.0, 5.005); + current[map[BUS]] = rnd_float(158, 171); + + // float charging = current[map[PLUS_X]] + current[map[MINUS_X]] + current[map[PLUS_Y]] + current[map[MINUS_Y]] + current[map[PLUS_Z]] + current[map[MINUS_Z]]; + float charging = eclipse * (fabs(amps_max[0] * 0.707) + fabs(amps_max[1] * 0.707) + rnd_float(-4.0, 4.0)); + + current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / batt) - charging; + + // printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BUS]], batt, voltage[map[BUS]]); + + batt -= (batt > 3.5) ? current[map[BAT]] / 30000 : current[map[BAT]] / 3000; + if (batt < 3.0) { + batt = 3.0; + NormalModeFailure = 1; + printf("Safe Mode!\n"); + } else + NormalModeFailure = 0; + + if (batt > 4.5) + batt = 4.5; + + voltage[map[BAT]] = batt + rnd_float(-0.01, 0.01); + + // end of simulated telemetry + } + +else { int count1; char * token; char cmdbuffer[1000]; @@ -1078,11 +1159,7 @@ void get_tlm_fox() { const char space[2] = " "; token = strtok(cmdbuffer, space); - float voltage[9], current[9], sensor[17], other[3]; - 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) { @@ -1192,79 +1269,7 @@ void get_tlm_fox() { } } - - if (sim_mode) { - // simulated telemetry - - double time = ((long int)millis() - time_start) / 1000.0; - - if ((time - eclipse_time) > period) { - eclipse = (eclipse == 1) ? 0 : 1; - eclipse_time = time; - 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); - - double Xv = eclipse * volts_max[0] * (float) sin(2.0 * 3.14 * time / (46.0 * speed)) + rnd_float(-0.2, 0.2); - double Yv = eclipse * volts_max[1] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + (3.14 / 2.0)) + rnd_float(-0.2, 0.2); - double Zv = 2.0 * eclipse * volts_max[2] * (float) sin((2.0 * 3.14 * time / (46.0 * speed)) + 3.14 + angle[2]) + rnd_float(-0.2, 0.2); - - // printf("Yi: %f Zi: %f %f %f Zv: %f \n", Yi, Zi, amps_max[2], angle[2], Zv); - - current[map[PLUS_X]] = (Xi >= 0) ? Xi : 0; - current[map[MINUS_X]] = (Xi >= 0) ? 0 : ((-1.0f) * Xi); - current[map[PLUS_Y]] = (Yi >= 0) ? Yi : 0; - current[map[MINUS_Y]] = (Yi >= 0) ? 0 : ((-1.0f) * Yi); - current[map[PLUS_Z]] = (Zi >= 0) ? Zi : 0; - current[map[MINUS_Z]] = (Zi >= 0) ? 0 : ((-1.0f) * Zi); - - voltage[map[PLUS_X]] = (Xv >= 1) ? Xv : rnd_float(0.9, 1.1); - voltage[map[MINUS_X]] = (Xv <= -1) ? ((-1.0f) * Xv) : rnd_float(0.9, 1.1); - voltage[map[PLUS_Y]] = (Yv >= 1) ? Yv : rnd_float(0.9, 1.1); - voltage[map[MINUS_Y]] = (Yv <= -1) ? ((-1.0f) * Yv) : rnd_float(0.9, 1.1); - voltage[map[PLUS_Z]] = (Zv >= 1) ? Zv : rnd_float(0.9, 1.1); - voltage[map[MINUS_Z]] = (Zv <= -1) ? ((-1.0f) * Zv) : rnd_float(0.9, 1.1); - - // printf("temp: %f Time: %f Eclipse: %d : %f %f | %f %f | %f %f\n",tempS, time, eclipse, voltage[map[PLUS_X]], voltage[map[MINUS_X]], voltage[map[PLUS_Y]], voltage[map[MINUS_Y]], current[map[PLUS_Z]], current[map[MINUS_Z]]); - - tempS += (eclipse > 0) ? ((temp_max - tempS) / 50.0f) : ((temp_min - tempS) / 50.0f); - tempS += +rnd_float(-1.0, 1.0); - // IHUcpuTemp = (int)((tempS + rnd_float(-1.0, 1.0)) * 10 + 0.5); - other[IHU_TEMP] = tempS; - - voltage[map[BUS]] = rnd_float(5.0, 5.005); - current[map[BUS]] = rnd_float(158, 171); - - // float charging = current[map[PLUS_X]] + current[map[MINUS_X]] + current[map[PLUS_Y]] + current[map[MINUS_Y]] + current[map[PLUS_Z]] + current[map[MINUS_Z]]; - float charging = eclipse * (fabs(amps_max[0] * 0.707) + fabs(amps_max[1] * 0.707) + rnd_float(-4.0, 4.0)); - - current[map[BAT]] = ((current[map[BUS]] * voltage[map[BUS]]) / batt) - charging; - - // printf("charging: %f bat curr: %f bus curr: %f bat volt: %f bus volt: %f \n",charging, current[map[BAT]], current[map[BUS]], batt, voltage[map[BUS]]); - - batt -= (batt > 3.5) ? current[map[BAT]] / 30000 : current[map[BAT]] / 3000; - if (batt < 3.0) { - batt = 3.0; - NormalModeFailure = 1; - printf("Safe Mode!\n"); - } else - NormalModeFailure = 0; - - if (batt > 4.5) - batt = 4.5; - - voltage[map[BAT]] = batt + rnd_float(-0.01, 0.01); - - // end of simulated telemetry - } + } for (count1 = 0; count1 < 8; count1++) { if (voltage[count1] < voltage_min[count1]) From 5a8adeea2f5cf9f7318a9fe89b03b793b286f944 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:19:25 -0500 Subject: [PATCH 005/210] typos --- afsk/main.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 899c2d58..9d89271d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1068,6 +1068,7 @@ void get_tlm_fox() { 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)); @@ -1205,7 +1206,7 @@ else { } fclose(cpuTempSensor); - char sensor_payload[500]; + if (payload == ON) { STEMBoardFailure = 0; @@ -1269,9 +1270,18 @@ else { } } + 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]); + } - for (count1 = 0; count1 < 8; count1++) { + for (int count1 = 0; count1 < 8; count1++) { if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1]; if (current[count1] < current_min[count1]) @@ -1285,14 +1295,7 @@ else { // printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_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]); } } From 1271e7b62c370e49255caf5ce47b2a29849490cd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:20:20 -0500 Subject: [PATCH 006/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 9d89271d..779fe8f6 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1299,7 +1299,7 @@ else { } } - for (count1 = 0; count1 < 3; 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]) From 67bda7538bdf324902ad2096d77ff3f1423dd4c1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:21:01 -0500 Subject: [PATCH 007/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 779fe8f6..497c981b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1312,7 +1312,7 @@ else { if (loop % 8 == 0) { printf("Sending MIN frame \n"); frm_type = 0x03; - for (count1 = 0; count1 < 17; count1++) { + for (int count1 = 0; count1 < 17; count1++) { if (count1 < 3) other[count1] = other_min[count1]; if (count1 < 8) { From 82a96e1c5f8c690fad32c18623efea317d47012c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:25:39 -0500 Subject: [PATCH 008/210] turned off payload --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 497c981b..bd697609 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1208,7 +1208,7 @@ else { - if (payload == ON) { + if (payload == -55) { // ON STEMBoardFailure = 0; char c; From 162ecb1b3379ce9e22318770d5d6adea219e2482 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:26:21 -0500 Subject: [PATCH 009/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index bd697609..04f3e888 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1326,7 +1326,7 @@ else { if ((loop + 4) % 8 == 0) { printf("Sending MAX frame \n"); frm_type = 0x02; - for (count1 = 0; count1 < 17; count1++) { + for (int count1 = 0; count1 < 17; count1++) { if (count1 < 3) other[count1] = other_max[count1]; if (count1 < 8) { From 4ec37242cd462203c2beed71adf23073493ecd20 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:33:17 -0500 Subject: [PATCH 010/210] no python sensor read --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 04f3e888..2cae01a8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1050,7 +1050,7 @@ 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) @@ -1058,7 +1058,7 @@ void get_tlm_fox() { */ 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); @@ -1151,12 +1151,12 @@ else { 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); From 75606058f157ac46b479ee68a7adceaac20de050 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 26 Dec 2020 16:39:29 -0500 Subject: [PATCH 011/210] added 3x sleep(1) --- afsk/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 2cae01a8..c1315057 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1160,8 +1160,6 @@ else { const char space[2] = " "; token = strtok(cmdbuffer, space); - - for (count1 = 0; count1 < 8; count1++) { if (token != NULL) { voltage[count1] = (float) atof(token); @@ -1182,7 +1180,10 @@ else { } // printf("\n"); - + + sleep(1); + printf("Sleep over\n"); + batteryVoltage = voltage[map[BAT]]; if (batteryVoltage < 3.5) { NormalModeFailure = 1; @@ -1346,6 +1347,9 @@ else { 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]); @@ -1532,6 +1536,9 @@ else { printf("\n"); */ #endif + + sleep(1); + printf("Sleep over\n"); int ctr2 = 0; memset(data10, 0, sizeof(data10)); From 3cf57030810ed77b4b3bf5bfbfcc74cc24bc5277 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 09:31:53 -0500 Subject: [PATCH 012/210] added sleep(0.6) --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index c1315057..bdd2106f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1066,6 +1066,7 @@ void get_tlm_fox() { } else printf("first time - no sleep\n"); + sleep(0.6); float voltage[9], current[9], sensor[17], other[3]; char sensor_payload[500]; @@ -1181,7 +1182,7 @@ else { // printf("\n"); - sleep(1); + sleep(0.5); printf("Sleep over\n"); batteryVoltage = voltage[map[BAT]]; From 4deeee6e90fb944058d4dd6de9202108d8568c82 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 09:36:51 -0500 Subject: [PATCH 013/210] changed to sleep(2.5) --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index bdd2106f..6f9b53ea 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1066,7 +1066,7 @@ void get_tlm_fox() { } else printf("first time - no sleep\n"); - sleep(0.6); + sleep(2.5); float voltage[9], current[9], sensor[17], other[3]; char sensor_payload[500]; From 47584fd4795fbe52f8f72aad7a028e3dbfce1641 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 09:42:25 -0500 Subject: [PATCH 014/210] consolidated all into a sleep(4.5) --- afsk/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 6f9b53ea..c845fa66 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1066,7 +1066,7 @@ void get_tlm_fox() { } else printf("first time - no sleep\n"); - sleep(2.5); + sleep(4.5); float voltage[9], current[9], sensor[17], other[3]; char sensor_payload[500]; @@ -1349,8 +1349,8 @@ else { fclose(uptime_file); printf("Reset Count: %d Uptime since Reset: %ld \n", reset_count, uptime); - sleep(1); - printf("Sleep over\n"); + //sleep(1); + //printf("Sleep over\n"); h[0] = (short int) ((h[0] & 0xf8) | (id & 0x07)); // 3 bits // printf("h[0] %x\n", h[0]); @@ -1538,8 +1538,8 @@ else { */ #endif - sleep(1); - printf("Sleep over\n"); + //sleep(1); + //printf("Sleep over\n"); int ctr2 = 0; memset(data10, 0, sizeof(data10)); From dfac052acd9e4eb8073be511e5d7d122cdedb0b7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 09:50:09 -0500 Subject: [PATCH 015/210] Two sleep(2.5) --- afsk/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index c845fa66..8b175f6c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1066,7 +1066,7 @@ void get_tlm_fox() { } else printf("first time - no sleep\n"); - sleep(4.5); + sleep(2.5); float voltage[9], current[9], sensor[17], other[3]; char sensor_payload[500]; @@ -1679,11 +1679,13 @@ else { 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); - + + sleep(2.5); + if (sock_ret < (ctr * 2 + 2)) { printf("Not resending\n"); // sock_ret = send(sock, buffer[sock_ret], ctr * 2 + 2 - sock_ret, 0); From 8befb7cf1422cdd41d7ab140cb45cbe6350ba0b4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 10:38:56 -0500 Subject: [PATCH 016/210] loop time test --- afsk/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 8b175f6c..d1b1151f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -537,7 +537,9 @@ int main(int argc, char * argv[]) { while (loop-- != 0) { // frames_sent++; - + + loopTime = millis(); + sleep(2.0); printf("++++ Loop time: %d +++++\n", millis() - loopTime); loopTime = millis(); From bd5312165516daf16f301754108139322c362b7b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 10:44:05 -0500 Subject: [PATCH 017/210] more testing --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index d1b1151f..6573826b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -539,7 +539,7 @@ int main(int argc, char * argv[]) { // frames_sent++; loopTime = millis(); - sleep(2.0); + sleep(2); printf("++++ Loop time: %d +++++\n", millis() - loopTime); loopTime = millis(); @@ -551,6 +551,7 @@ int main(int argc, char * argv[]) { 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); From f2e0854b12f40d0cc47c66f30f4e7b601f95c68e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 10:52:26 -0500 Subject: [PATCH 018/210] all together again one sleep --- afsk/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 6573826b..875b41e0 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -538,8 +538,6 @@ int main(int argc, char * argv[]) { while (loop-- != 0) { // frames_sent++; - loopTime = millis(); - sleep(2); printf("++++ Loop time: %d +++++\n", millis() - loopTime); loopTime = millis(); @@ -1059,6 +1057,8 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ + sleep(3.5); + digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING // printf("Tx LED Off\n"); @@ -1069,7 +1069,7 @@ void get_tlm_fox() { } else printf("first time - no sleep\n"); - sleep(2.5); + float voltage[9], current[9], sensor[17], other[3]; char sensor_payload[500]; @@ -1185,8 +1185,9 @@ else { // printf("\n"); - sleep(0.5); - printf("Sleep over\n"); + +// sleep(0.5); +// printf("Sleep over\n"); batteryVoltage = voltage[map[BAT]]; if (batteryVoltage < 3.5) { @@ -1687,7 +1688,7 @@ else { 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); - sleep(2.5); +// sleep(2.5); if (sock_ret < (ctr * 2 + 2)) { printf("Not resending\n"); From 3d817f438243588dccb94360defbcb55f81268e5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 11:02:10 -0500 Subject: [PATCH 019/210] Almost every frame decoded, still buffer filling, try turning off first time --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 875b41e0..652bf6db 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -98,7 +98,7 @@ static int init_rf(); int socket_open = 0; int sock = 0; int loop = -1, loop_count = 0; -int firstTime = ON; +int firstTime = 0; // ON; long start; int testCount = 0; long time_start; From fffdff6b1057fdd13d7b9b5fc12acdb8b400c2ea Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 11:16:10 -0500 Subject: [PATCH 020/210] reduced sleep from 3.5 to 3.2 to avoid buffer overflow --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 652bf6db..8b5d0ef1 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1057,7 +1057,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(3.5); + sleep(3.2); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From 3ae7a2269125def18a5f3b21b7e4234e45be3f3c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 11:21:02 -0500 Subject: [PATCH 021/210] reduce to 3.0 --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 8b5d0ef1..1665c890 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1057,7 +1057,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(3.2); + sleep(3.0); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From 5013b81bc07ea1de8f006a52f7988b37741a3594 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 11:26:57 -0500 Subject: [PATCH 022/210] reduced to 2.5 --- afsk/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 1665c890..30543d92 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -134,7 +134,8 @@ char call[5]; 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; @@ -1057,7 +1058,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(3.0); + sleep(2.5); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING @@ -1065,7 +1066,7 @@ void get_tlm_fox() { #endif printf("Sample period: %d\n", millis() - (unsigned int)sampleTime); - sampleTime = (int) millis(); + sampleTime = (unsigned int) millis(); } else printf("first time - no sleep\n"); From 41fe5ffebb7cc88c9ce685eebec9bf8a0ed78c1d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 11:27:39 -0500 Subject: [PATCH 023/210] typo --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 30543d92..bb926634 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -134,7 +134,7 @@ char call[5]; int bitRate, mode, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; float sleepTime; -unsigned int sampleTime = 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; From 93a1f6da2ea1be4b151cdf80486e4a472e4a3436 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 15:19:44 -0500 Subject: [PATCH 024/210] added CPUQuota=5% --- systemd/cubesatsim.service | 1 + 1 file changed, 1 insertion(+) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index 633f689d..c724ae7e 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -10,6 +10,7 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root +CPUQuota=5% [Install] WantedBy=default.target From 315c8eadf4f3bef5c2195dabd2dae09f427a289f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 15:23:50 -0500 Subject: [PATCH 025/210] 2.5% --- systemd/cubesatsim.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index c724ae7e..0ecfd02c 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -10,7 +10,7 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root -CPUQuota=5% +CPUQuota=2.5% [Install] WantedBy=default.target From 33bdccde3da7a42fd5f8407a9af7d07eb0395039 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 15:32:51 -0500 Subject: [PATCH 026/210] tried CPUQuota 15% --- systemd/rpitx.service | 1 + 1 file changed, 1 insertion(+) diff --git a/systemd/rpitx.service b/systemd/rpitx.service index c58b7bd1..0e628e4a 100644 --- a/systemd/rpitx.service +++ b/systemd/rpitx.service @@ -10,6 +10,7 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root +CPUQuota=15% [Install] WantedBy=default.target From b08449fc9b67c6842eca610ed136b182a5a231d9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 15:44:06 -0500 Subject: [PATCH 027/210] added CPUAccounting=true --- systemd/cubesatsim.service | 1 + 1 file changed, 1 insertion(+) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index 0ecfd02c..d43b3cac 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -10,6 +10,7 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root +CPUAccounting=true CPUQuota=2.5% [Install] From b44c8defeff19565360cab23bc08e335e32f4d08 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Dec 2020 15:47:00 -0500 Subject: [PATCH 028/210] removed CPU quota --- systemd/rpitx.service | 1 - 1 file changed, 1 deletion(-) diff --git a/systemd/rpitx.service b/systemd/rpitx.service index 0e628e4a..c58b7bd1 100644 --- a/systemd/rpitx.service +++ b/systemd/rpitx.service @@ -10,7 +10,6 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root -CPUQuota=15% [Install] WantedBy=default.target From 739d111da5ab06353ab115a904fcda4381c320a2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 10:34:49 -0500 Subject: [PATCH 029/210] removed sleep --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index bb926634..5d4fd01d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1058,7 +1058,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(2.5); +// sleep(2.5); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From e1ba9661537d824e5e467f553bea292b0d76516d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 10:42:33 -0500 Subject: [PATCH 030/210] No sleep, buffer always full, almost 100% frames --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 5d4fd01d..5684a4e9 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1058,7 +1058,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ -// sleep(2.5); +// sleep(2.5); // No sleep at all! digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From 729fe608a0a4db78d639e0fddb6398f8da625e50 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 10:57:08 -0500 Subject: [PATCH 031/210] changed to delay(2.5) --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index 5684a4e9..abb88b17 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1690,6 +1690,7 @@ else { printf("Millis5: %d Result of socket send: %d \n", (unsigned int)millis() - start, sock_ret); // sleep(2.5); + delsy(2.5); if (sock_ret < (ctr * 2 + 2)) { printf("Not resending\n"); From f081a668e0f6187337e47be7b3905b306baa273e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 10:59:21 -0500 Subject: [PATCH 032/210] delay --- afsk/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index abb88b17..7c18a475 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -556,7 +556,7 @@ int main(int argc, char * argv[]) { sleep(1); digitalWrite(onLed, onLedOff); sleep(1); - digitalWrite(onLed, onLedOn); + digitalWrite(onLed, onLedOn);slee sleep(1); digitalWrite(onLed, onLedOff); @@ -1059,6 +1059,7 @@ void get_tlm_fox() { sleep((unsigned int)sleepTime); */ // sleep(2.5); // No sleep at all! + delay(2.5); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING @@ -1690,7 +1691,7 @@ else { printf("Millis5: %d Result of socket send: %d \n", (unsigned int)millis() - start, sock_ret); // sleep(2.5); - delsy(2.5); + if (sock_ret < (ctr * 2 + 2)) { printf("Not resending\n"); From b89ba8c0ce49109de3b8d719ba56aa8c866bcf87 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 11:00:04 -0500 Subject: [PATCH 033/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 7c18a475..9fd51a5d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -556,7 +556,7 @@ int main(int argc, char * argv[]) { sleep(1); digitalWrite(onLed, onLedOff); sleep(1); - digitalWrite(onLed, onLedOn);slee + digitalWrite(onLed, onLedOn); sleep(1); digitalWrite(onLed, onLedOff); From 55fbb3c52b2d8f13f472c5fed134047123a055c6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 11:04:40 -0500 Subject: [PATCH 034/210] delay(3) --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 9fd51a5d..124d8dec 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1059,7 +1059,7 @@ void get_tlm_fox() { sleep((unsigned int)sleepTime); */ // sleep(2.5); // No sleep at all! - delay(2.5); + delay(3); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From 71234ff24f8ee2d09a98e4d00c4aff1a85b76f77 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 11:30:24 -0500 Subject: [PATCH 035/210] back to sleep(2.5) --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 124d8dec..e8d12042 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1058,8 +1058,8 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ -// sleep(2.5); // No sleep at all! - delay(3); + sleep(2.5); // No sleep at all! + digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From 42f9b0b82f2ff0de1e51e0a7c6280569cfb7fe99 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 16:45:37 -0500 Subject: [PATCH 036/210] added sleep(0.1) --- python/voltcurrent.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index f34e9e52..2794f18b 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -1,12 +1,15 @@ """Sample code and test for adafruit_in219""" # Reads all voltage and current sensors for two I2C buses - +import time import sys +time.sleep(0.1) #import board import busio +time.sleep(0.1) from adafruit_extended_bus import ExtendedI2C as I2C +time.sleep(0.1) from adafruit_ina219 import INA219 - +time.sleep(0.1) if __name__ == "__main__": # print 'Length: ', len(sys.argv) From 6c1b63be40680c04ea5e1f2baeb650c9b608722e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 16:50:58 -0500 Subject: [PATCH 037/210] sleep 1.5 and python telem --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index e8d12042..de9da6e2 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1058,7 +1058,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(2.5); // No sleep at all! + sleep(1.5); // No sleep at all! digitalWrite(txLed, txLedOff); @@ -1157,12 +1157,12 @@ else { 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); From 40230331b683904a40947aed5a4a38a10d9263e0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 16:53:07 -0500 Subject: [PATCH 038/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index de9da6e2..31037d53 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1162,7 +1162,7 @@ else { fgets(cmdbuffer, 1000, file); // printf("result: %s\n", cmdbuffer); pclose(file); -**/ +/**/ const char space[2] = " "; token = strtok(cmdbuffer, space); From 0ea71118cde160baf5c03a0d30862758ee2e1cac Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 17:14:56 -0500 Subject: [PATCH 039/210] added input test --- python/voltcurrent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 2794f18b..c43dbb2c 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -2,14 +2,11 @@ # Reads all voltage and current sensors for two I2C buses import time import sys -time.sleep(0.1) #import board import busio -time.sleep(0.1) from adafruit_extended_bus import ExtendedI2C as I2C -time.sleep(0.1) from adafruit_ina219 import INA219 -time.sleep(0.1) + if __name__ == "__main__": # print 'Length: ', len(sys.argv) @@ -67,3 +64,6 @@ if __name__ == "__main__": 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(" ") + inp = input("Next?") + print(inp) + From 33cffd9fc4beba8233fc82ae161cdaa94e884f36 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 17:18:37 -0500 Subject: [PATCH 040/210] added while loop --- python/voltcurrent.py | 65 ++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index c43dbb2c..550552bf 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -26,44 +26,45 @@ if __name__ == "__main__": 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: + while (True): + for x in buses: + try: + i2c_bus = I2C(x) # Device is /dev/i2c-x + for y in addresses: # print(x,y) - try: + try: # Create library object using Extended Bus I2C port # 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) + 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") +# print("ina219 test") + if config: +# 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 - 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 + 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 = '') - 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(" ") - inp = input("Next?") - print(inp) +# 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 = '') + 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(" ") + inp = input() + print(inp) From 97c381bed246534ee646df83bb8a997a2e9aece0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 17:22:37 -0500 Subject: [PATCH 041/210] removed print --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 550552bf..e2ecf8af 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -66,5 +66,5 @@ if __name__ == "__main__": # pass print(" ") inp = input() - print(inp) +# print(inp) From d8cedd9f212a308779386b22be9976215bd16144 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 17:29:48 -0500 Subject: [PATCH 042/210] try new python --- afsk/main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 31037d53..e88a20db 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -346,9 +346,21 @@ int main(int argc, char * argv[]) { 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); +// pclose(file1); Try new python + sleep(5); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result2: %s\n", cmdbuffer); + + + sleep(5); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result3: %s\n", cmdbuffer); + + // try connecting to Arduino payload using UART if (!ax5043 && !vB3) // don't test if AX5043 is present From 6b67bf70a69e9f2f433569bdf0ea72b6af2225c8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 17:52:39 -0500 Subject: [PATCH 043/210] changed popen to rw --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index e88a20db..5291dca9 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -343,7 +343,7 @@ int main(int argc, char * argv[]) { strcat(pythonConfigStr, " c"); // FILE* file1 = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11 c", "r"); - FILE * file1 = popen(pythonConfigStr, "r"); + FILE * file1 = popen(pythonConfigStr, "rw"); char cmdbuffer[1000]; fgets(cmdbuffer, 1000, file1); printf("pythonStr result: %s\n", cmdbuffer); From 444ba6992d5b623c209e47243305f130184e7250 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 17:55:57 -0500 Subject: [PATCH 044/210] try r+ --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 5291dca9..7731cf25 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -343,7 +343,7 @@ int main(int argc, char * argv[]) { strcat(pythonConfigStr, " c"); // FILE* file1 = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11 c", "r"); - FILE * file1 = popen(pythonConfigStr, "rw"); + FILE * file1 = popen(pythonConfigStr, "r+"); char cmdbuffer[1000]; fgets(cmdbuffer, 1000, file1); printf("pythonStr result: %s\n", cmdbuffer); From a3e34d9ea55e6aa11ae94638d0291f780eb032a9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:16:36 -0500 Subject: [PATCH 045/210] Try start process --- afsk/main.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 7731cf25..36cd9e2d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -126,6 +126,7 @@ int nrd; void write_to_buffer(int i, int symbol, int val); void write_wave(int i, short int * buffer); int uart_fd; +start_subprocess(char *const command[], int *pid, int *infd, int *outfd); int reset_count; float uptime_sec; @@ -343,12 +344,15 @@ int main(int argc, char * argv[]) { strcat(pythonConfigStr, " c"); // FILE* file1 = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11 c", "r"); - FILE * file1 = popen(pythonConfigStr, "r+"); + FILE * file1 = popen(pythonConfigStr, "r"); char cmdbuffer[1000]; fgets(cmdbuffer, 1000, file1); printf("pythonStr result: %s\n", cmdbuffer); -// pclose(file1); Try new python + pclose(file1); +int pid, infd, outfd; +printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, int *pid, int *infd, int *outfd), pid, infd, outfd); +/* sleep(5); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); @@ -359,7 +363,7 @@ int main(int argc, char * argv[]) { fputc('\n', file1); fgets(cmdbuffer, 1000, file1); printf("pythonStr result3: %s\n", cmdbuffer); - +*/ // try connecting to Arduino payload using UART @@ -997,6 +1001,43 @@ void get_tlm(void) { return; } +// code by https://stackoverflow.com/users/2876370/pavel-%c5%a0imerda + +static bool start_subprocess(char *const command[], int *pid, int *infd, int *outfd) +{ + int p1[2], p2[2]; + + if (!pid || !infd || !outfd) + return false; + + if (pipe(p1) == -1) + goto err_pipe1; + if (pipe(p2) == -1) + goto err_pipe2; + if ((*pid = fork()) == -1) + goto err_fork; + + if (*pid) { + /* Parent process. */ + *infd = p1[1]; + *outfd = p2[0]; + close(p1[0]); + close(p2[1]); + return true; + } else { + /* Child process. */ + dup2(p1[0], 0); + dup2(p2[1], 1); + close(p1[0]); + close(p1[1]); + close(p2[0]); + close(p2[1]); + execvp(*command, command); + /* Error occured. */ + fprintf(stderr, "error running %s: %s", *command, strerror(errno)); + abort(); + } + void get_tlm_fox() { // Reading I2C voltage and current sensors From 100aabd8f13dbeb1242cb290da48c42a4082f50d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:17:56 -0500 Subject: [PATCH 046/210] bool to int --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 36cd9e2d..bd61438d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -126,7 +126,7 @@ int nrd; void write_to_buffer(int i, int symbol, int val); void write_wave(int i, short int * buffer); int uart_fd; -start_subprocess(char *const command[], int *pid, int *infd, int *outfd); +int start_subprocess(char *const command[], int *pid, int *infd, int *outfd); int reset_count; float uptime_sec; @@ -1003,7 +1003,7 @@ void get_tlm(void) { // code by https://stackoverflow.com/users/2876370/pavel-%c5%a0imerda -static bool start_subprocess(char *const command[], int *pid, int *infd, int *outfd) +int start_subprocess(char *const command[], int *pid, int *infd, int *outfd) { int p1[2], p2[2]; From b8fe0cef95597f182ce099a7d84e4f483028bd72 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:19:43 -0500 Subject: [PATCH 047/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index bd61438d..444e96ba 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -351,7 +351,7 @@ int main(int argc, char * argv[]) { pclose(file1); int pid, infd, outfd; -printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, int *pid, int *infd, int *outfd), pid, infd, outfd); +printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); /* sleep(5); fputc('\n', file1); From 27399f202283dbe0ead6dc956387d5491726df20 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:21:01 -0500 Subject: [PATCH 048/210] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 444e96ba..a02ad5e7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1008,7 +1008,7 @@ int start_subprocess(char *const command[], int *pid, int *infd, int *outfd) int p1[2], p2[2]; if (!pid || !infd || !outfd) - return false; + return 0; if (pipe(p1) == -1) goto err_pipe1; @@ -1023,7 +1023,7 @@ int start_subprocess(char *const command[], int *pid, int *infd, int *outfd) *outfd = p2[0]; close(p1[0]); close(p2[1]); - return true; + return 1; } else { /* Child process. */ dup2(p1[0], 0); From 4ee4fe78475bfc49b942c93f7003c0d3d59abb0d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:22:28 -0500 Subject: [PATCH 049/210] Update main.c --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index a02ad5e7..f04fc010 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1037,6 +1037,7 @@ int start_subprocess(char *const command[], int *pid, int *infd, int *outfd) fprintf(stderr, "error running %s: %s", *command, strerror(errno)); abort(); } +} void get_tlm_fox() { From 203f9cee90bb4044fa795a3d1e2bf62c916d4f37 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:24:43 -0500 Subject: [PATCH 050/210] handled errors --- afsk/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f04fc010..74aa5bee 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1010,12 +1010,16 @@ int start_subprocess(char *const command[], int *pid, int *infd, int *outfd) if (!pid || !infd || !outfd) return 0; - if (pipe(p1) == -1) - goto err_pipe1; - if (pipe(p2) == -1) - goto err_pipe2; - if ((*pid = fork()) == -1) - goto err_fork; + if (pipe(p1) == -1) { + printf("Error pipe1\n"); + return 0; + } if (pipe(p2) == -1) { + printf("Error pipe2\n"); + return 0; + } if ((*pid = fork()) == -1) { + printf("Error fork\n"); + return 0; + } if (*pid) { /* Parent process. */ From a6a48b52a69e24d10062c649dba66290fcda4f96 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:27:23 -0500 Subject: [PATCH 051/210] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 74aa5bee..5e37d96a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -342,14 +342,14 @@ int main(int argc, char * argv[]) { strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); strcat(pythonConfigStr, " c"); - +/* // 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); - +*/ int pid, infd, outfd; printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); /* From 817e20da8abc30cce6a14e174a124001a133ba0a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:31:20 -0500 Subject: [PATCH 052/210] try in and out --- afsk/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 5e37d96a..5b3a8e7e 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -352,17 +352,19 @@ int main(int argc, char * argv[]) { */ int pid, infd, outfd; printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); -/* + fgets(cmdbuffer, 1000, outfd); + printf("pythonStr result: %s\n", cmdbuffer); + sleep(5); - fputc('\n', file1); - fgets(cmdbuffer, 1000, file1); + fputc('\n', infd); + fgets(cmdbuffer, 1000, outfd); printf("pythonStr result2: %s\n", cmdbuffer); sleep(5); - fputc('\n', file1); - fgets(cmdbuffer, 1000, file1); - printf("pythonStr result3: %s\n", cmdbuffer); + fputc('\n', infd); + fgets(cmdbuffer, 1000, outfd); + printf("pythonStr result2: %s\n", cmdbuffer); */ // try connecting to Arduino payload using UART From 1f7aa9b4024625190b20bc6245cfc4af38be48d8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:32:04 -0500 Subject: [PATCH 053/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 5b3a8e7e..0964911b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -365,7 +365,7 @@ printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, fputc('\n', infd); fgets(cmdbuffer, 1000, outfd); printf("pythonStr result2: %s\n", cmdbuffer); -*/ + // try connecting to Arduino payload using UART From 036a850aae737bb8d76775b05884fd1bd3dc3d9d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:33:49 -0500 Subject: [PATCH 054/210] Update main.c --- afsk/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 0964911b..4a790333 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -352,18 +352,18 @@ int main(int argc, char * argv[]) { */ int pid, infd, outfd; printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); - fgets(cmdbuffer, 1000, outfd); + fgets(cmdbuffer, 1000, FILE *outfd); printf("pythonStr result: %s\n", cmdbuffer); sleep(5); - fputc('\n', infd); - fgets(cmdbuffer, 1000, outfd); + fputc('\n', FILE *infd); + fgets(cmdbuffer, 1000, FILE *outfd); printf("pythonStr result2: %s\n", cmdbuffer); sleep(5); - fputc('\n', infd); - fgets(cmdbuffer, 1000, outfd); + fputc('\n', FILE*infd); + fgets(cmdbuffer, 1000, FILE *outfd); printf("pythonStr result2: %s\n", cmdbuffer); From 36706a6c81f9997370cdde446855829beeeae556 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 18:35:25 -0500 Subject: [PATCH 055/210] Update main.c --- afsk/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 4a790333..20d7a73b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -342,28 +342,30 @@ int main(int argc, char * argv[]) { strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); strcat(pythonConfigStr, " c"); + + char cmdbuffer[1000]; /* // 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); */ int pid, infd, outfd; printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); - fgets(cmdbuffer, 1000, FILE *outfd); + fgets(cmdbuffer, 1000, (FILE *)outfd); printf("pythonStr result: %s\n", cmdbuffer); sleep(5); - fputc('\n', FILE *infd); - fgets(cmdbuffer, 1000, FILE *outfd); + fputc('\n', (FILE *)infd); + fgets(cmdbuffer, 1000, (FILE *)outfd); printf("pythonStr result2: %s\n", cmdbuffer); sleep(5); - fputc('\n', FILE*infd); - fgets(cmdbuffer, 1000, FILE *outfd); + fputc('\n', (FILE *)infd); + fgets(cmdbuffer, 1000, (FILE *)outfd); printf("pythonStr result2: %s\n", cmdbuffer); From 1d2f100c748f36a1151e64916dccef07eeb0245a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:13:22 -0500 Subject: [PATCH 056/210] changed to popen w --- afsk/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 20d7a73b..76078551 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -344,28 +344,28 @@ int main(int argc, char * argv[]) { strcat(pythonConfigStr, " c"); char cmdbuffer[1000]; -/* + // FILE* file1 = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11 c", "r"); - FILE * file1 = popen(pythonConfigStr, "r"); + FILE * file1 = popen(pythonConfigStr, "w"); fgets(cmdbuffer, 1000, file1); printf("pythonStr result: %s\n", cmdbuffer); - pclose(file1); -*/ -int pid, infd, outfd; -printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); - fgets(cmdbuffer, 1000, (FILE *)outfd); - printf("pythonStr result: %s\n", cmdbuffer); +// pclose(file1); + +// int pid, infd, outfd; +// printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); +// fgets(cmdbuffer, 1000, (FILE *)outfd); + // printf("pythonStr result: %s\n", cmdbuffer); sleep(5); - fputc('\n', (FILE *)infd); - fgets(cmdbuffer, 1000, (FILE *)outfd); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); printf("pythonStr result2: %s\n", cmdbuffer); sleep(5); - fputc('\n', (FILE *)infd); - fgets(cmdbuffer, 1000, (FILE *)outfd); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); printf("pythonStr result2: %s\n", cmdbuffer); From 1733e4cab7f97adf1dc5d468c28e48e0919317e6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:22:10 -0500 Subject: [PATCH 057/210] made cmdbuffer and file1 globals, keep open --- afsk/main.c | 79 ++++++++++------------------------------------------- 1 file changed, 14 insertions(+), 65 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 76078551..780f0b9e 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -102,7 +102,8 @@ int firstTime = 0; // ON; 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 #define S_RATE (48000) // (44100) @@ -126,7 +127,6 @@ int nrd; void write_to_buffer(int i, int symbol, int val); void write_wave(int i, short int * buffer); int uart_fd; -int start_subprocess(char *const command[], int *pid, int *infd, int *outfd); int reset_count; float uptime_sec; @@ -343,32 +343,23 @@ int main(int argc, char * argv[]) { strcat(pythonConfigStr, pythonStr); strcat(pythonConfigStr, " c"); - char cmdbuffer[1000]; - - // FILE* file1 = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11 c", "r"); - FILE * file1 = popen(pythonConfigStr, "w"); + file1 = popen(pythonConfigStr, "w"); fgets(cmdbuffer, 1000, file1); - printf("pythonStr result: %s\n", cmdbuffer); + printf("pythonStr result: %s\n", cmdbuffer); // pclose(file1); -// int pid, infd, outfd; -// printf("Start Process Result: %d %d %d %d \n", start_subprocess(pythonConfigStr, &pid, &infd, &outfd), pid, infd, outfd); -// fgets(cmdbuffer, 1000, (FILE *)outfd); - // printf("pythonStr result: %s\n", cmdbuffer); - sleep(5); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); - printf("pythonStr result2: %s\n", cmdbuffer); + printf("pythonStr result2: %s\n", cmdbuffer); sleep(5); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); - printf("pythonStr result2: %s\n", cmdbuffer); + printf("pythonStr result2: %s\n", cmdbuffer); - // try connecting to Arduino payload using UART if (!ax5043 && !vB3) // don't test if AX5043 is present @@ -418,12 +409,12 @@ int main(int argc, char * argv[]) { i2c_bus3 = (test_i2c_bus(3) != -1) ? ON : OFF; // check for camera - char cmdbuffer1[1000]; +// char cmdbuffer1[1000]; FILE * file4 = popen("vcgencmd get_camera", "r"); - fgets(cmdbuffer1, 1000, file4); + fgets(cmdbuffer, 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; + camera = (strstr( (const char *)& cmdbuffer, camera_present) != NULL) ? ON : OFF; // printf("Camera result:%s camera: %d \n", & cmdbuffer1, camera); pclose(file4); @@ -678,7 +669,7 @@ void get_tlm(void) { int count1; char * token; - char cmdbuffer[1000]; +// char cmdbuffer[1000]; FILE * file = popen(pythonStr, "r"); fgets(cmdbuffer, 1000, file); @@ -1005,48 +996,6 @@ void get_tlm(void) { return; } -// code by https://stackoverflow.com/users/2876370/pavel-%c5%a0imerda - -int start_subprocess(char *const command[], int *pid, int *infd, int *outfd) -{ - int p1[2], p2[2]; - - if (!pid || !infd || !outfd) - return 0; - - if (pipe(p1) == -1) { - printf("Error pipe1\n"); - return 0; - } if (pipe(p2) == -1) { - printf("Error pipe2\n"); - return 0; - } if ((*pid = fork()) == -1) { - printf("Error fork\n"); - return 0; - } - - if (*pid) { - /* Parent process. */ - *infd = p1[1]; - *outfd = p2[0]; - close(p1[0]); - close(p2[1]); - return 1; - } else { - /* Child process. */ - dup2(p1[0], 0); - dup2(p2[1], 1); - close(p1[0]); - close(p1[1]); - close(p2[0]); - close(p2[1]); - execvp(*command, command); - /* Error occured. */ - fprintf(stderr, "error running %s: %s", *command, strerror(errno)); - abort(); - } -} - void get_tlm_fox() { // Reading I2C voltage and current sensors @@ -1218,12 +1167,12 @@ void get_tlm_fox() { else { int count1; char * token; - char cmdbuffer[1000]; +// char cmdbuffer[1000]; /**/ - FILE * file = popen(pythonStr, "r"); - fgets(cmdbuffer, 1000, file); +// FILE * file = popen(pythonStr, "r"); + fgets(cmdbuffer, 1000, file1); // printf("result: %s\n", cmdbuffer); - pclose(file); +// pclose(file); /**/ const char space[2] = " "; token = strtok(cmdbuffer, space); From 211da494be30850bdad8213c467bc435bf87a079 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:25:41 -0500 Subject: [PATCH 058/210] sleep(3.5) now with quicker python sensor reads --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 780f0b9e..9a3be624 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1069,7 +1069,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(1.5); // No sleep at all! + sleep(3.5); // No sleep at all! digitalWrite(txLed, txLedOff); From 5279c8f36fba5db9e439fecb27408a1265f78e8f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:30:15 -0500 Subject: [PATCH 059/210] working with every frame, fixing telem read --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index 9a3be624..900ed293 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1170,6 +1170,7 @@ else { // char cmdbuffer[1000]; /**/ // FILE * file = popen(pythonStr, "r"); + fputc('\n', file1); fgets(cmdbuffer, 1000, file1); // printf("result: %s\n", cmdbuffer); // pclose(file); From f655d2f801ae9c693e491da2dc98984d644baf0e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:36:43 -0500 Subject: [PATCH 060/210] printf python read result --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 900ed293..1385a15d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1172,7 +1172,7 @@ else { // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); - // printf("result: %s\n", cmdbuffer); + printf("Python read Result: %s\n", cmdbuffer); // pclose(file); /**/ const char space[2] = " "; From bad0056b37d7d9ee196664adb512d1f8f4e4acbd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:40:13 -0500 Subject: [PATCH 061/210] testing python read --- afsk/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 1385a15d..2d4593da 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -347,13 +347,18 @@ int main(int argc, char * argv[]) { fgets(cmdbuffer, 1000, 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); From 2881b595cf0c9eebd6b90d33bb1a8a321eae1b58 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:43:58 -0500 Subject: [PATCH 062/210] added stdin --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 2d4593da..52e64973 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -341,7 +341,7 @@ int main(int argc, char * argv[]) { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); - strcat(pythonConfigStr, " c"); + strcat(pythonConfigStr, " c >sdtin"); // added stdin file1 = popen(pythonConfigStr, "w"); From ee66bfa171ac939d4fddb807d20a5aa656089065 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:45:35 -0500 Subject: [PATCH 063/210] typo --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 52e64973..53243729 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -341,7 +341,7 @@ int main(int argc, char * argv[]) { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); - strcat(pythonConfigStr, " c >sdtin"); // added stdin + strcat(pythonConfigStr, " c >stdin"); // added stdin file1 = popen(pythonConfigStr, "w"); From c209010fe87e19b1b6926db7c8fd55986ad4b0e1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 22:46:32 -0500 Subject: [PATCH 064/210] stdout --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 53243729..c27d24c0 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -341,7 +341,7 @@ int main(int argc, char * argv[]) { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); - strcat(pythonConfigStr, " c >stdin"); // added stdin + strcat(pythonConfigStr, " c >stdout"); // added stdin file1 = popen(pythonConfigStr, "w"); From bf44272ed20c98f961eb3051eb4bc507ab5ceb29 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 23:02:32 -0500 Subject: [PATCH 065/210] try new sopen --- afsk/main.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index c27d24c0..cf17aa20 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -105,6 +105,7 @@ 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) @@ -341,7 +342,17 @@ int main(int argc, char * argv[]) { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); - strcat(pythonConfigStr, " c >stdout"); // added stdin + strcat(pythonConfigStr, " c"); + + file1 = sopen(pythonConfigStr); // try new function + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result: %s\n", cmdbuffer); + + sleep(5); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + printf("pythonStr result2: %s\n", cmdbuffer); + file1 = popen(pythonConfigStr, "w"); @@ -1735,6 +1746,35 @@ else { 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 * From e4e148ca069851a6cfd6fee1c96706421e84fde0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 23:08:14 -0500 Subject: [PATCH 066/210] took out old file1 code --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index cf17aa20..12a9bb25 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -353,7 +353,7 @@ int main(int argc, char * argv[]) { fgets(cmdbuffer, 1000, file1); printf("pythonStr result2: %s\n", cmdbuffer); - +/* file1 = popen(pythonConfigStr, "w"); fgets(cmdbuffer, 1000, file1); @@ -375,7 +375,7 @@ int main(int argc, char * argv[]) { 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 From 18a2c69b2b37b4b5149e69e07e08673475844f63 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 28 Dec 2020 23:12:14 -0500 Subject: [PATCH 067/210] sleep(2.8) --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 12a9bb25..4e630cb0 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1085,7 +1085,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(3.5); // No sleep at all! + sleep(2.8); // No sleep at all! digitalWrite(txLed, txLedOff); From 630c6f2a0f437ff7eb6f52cb161b17ddbf6ffbaa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 09:06:41 -0500 Subject: [PATCH 068/210] removed python read --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 4e630cb0..258098a8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1184,13 +1184,13 @@ else { int count1; char * token; // char cmdbuffer[1000]; -/**/ +/* // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); printf("Python read Result: %s\n", cmdbuffer); // pclose(file); -/**/ +*/ const char space[2] = " "; token = strtok(cmdbuffer, space); From 2507048f8f4aaa4133d2f688277d961412962636 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 09:15:40 -0500 Subject: [PATCH 069/210] reduce sleep time --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 258098a8..7777d3a1 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1085,7 +1085,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(2.8); // No sleep at all! + sleep(2.3); // No sleep at all! digitalWrite(txLed, txLedOff); @@ -1184,13 +1184,13 @@ else { int count1; char * token; // char cmdbuffer[1000]; -/* +/**/ // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); - printf("Python read Result: %s\n", cmdbuffer); +// printf("Python read Result: %s\n", cmdbuffer); // pclose(file); -*/ +/**/ const char space[2] = " "; token = strtok(cmdbuffer, space); From 53f0c5a9859539fd6169af5c60ce12ab442d1e57 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 09:18:24 -0500 Subject: [PATCH 070/210] added cpulimit & --- demo.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demo.sh b/demo.sh index de318527..38aa9a74 100755 --- a/demo.sh +++ b/demo.sh @@ -15,8 +15,9 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then echo "Mode is continuous AFSK" /home/pi/CubeSatSim/radioafsk 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 5 -P radioafsk & + /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" while true; do sleep 5; done From 2a81c4d4a5369093933154deda80186f65c3f5f9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 09:22:20 -0500 Subject: [PATCH 071/210] take python read out --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 7777d3a1..ecd236a5 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1184,13 +1184,13 @@ else { int count1; char * token; // char cmdbuffer[1000]; -/**/ +/* // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); // printf("Python read Result: %s\n", cmdbuffer); // pclose(file); -/**/ +*/ const char space[2] = " "; token = strtok(cmdbuffer, space); From 115aaeff58b8efe8d57ae0f6a6437d48b8d1379d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 10:22:29 -0500 Subject: [PATCH 072/210] Update main.c --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ecd236a5..0e2d6ab2 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1086,7 +1086,7 @@ void get_tlm_fox() { sleep((unsigned int)sleepTime); */ sleep(2.3); // No sleep at all! - +// sleep(1.3); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING @@ -1184,13 +1184,13 @@ else { int count1; char * token; // char cmdbuffer[1000]; -/* +/**/ // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); // printf("Python read Result: %s\n", cmdbuffer); // pclose(file); -*/ +/**/ const char space[2] = " "; token = strtok(cmdbuffer, space); From ead8ddddca046000b365302004d397516641ab99 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:37:26 -0500 Subject: [PATCH 073/210] reogranized without looping --- python/voltcurrent.py | 89 ++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index e2ecf8af..5decd333 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -26,45 +26,62 @@ if __name__ == "__main__": addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus # print("buses: ", buses, " addr: ", addresses) - while (True): - for x in buses: - try: - i2c_bus = I2C(x) # Device is /dev/i2c-x - for y in addresses: + +# config + + for x in buses: + try: + i2c_bus = I2C(x) # Device is /dev/i2c-x + for y in addresses: # print(x,y) - try: + try: # Create library object using Extended Bus I2C port -# 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") +# 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") + +# 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 + +# No try checking yet - 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 = '') - 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(" ") - inp = input() -# print(inp) + i2c_one = I2C(buses[0]) + i2c_two = I2C(buses[1]) + if (buses[0] == 0) and (addresses[0] == 0x45)): +# print("Reading INA219 in MoPower Board") + ina219_one = INA219(I2C(1), 0x4a) + else + ina219_one = INA219(i2c_one, addresses[0]) + ina219_two = INA219(i2c_one, addresses[1]) + ina219_three = INA219(i2c_one, addresses[2]) + ina219_four= INA219(i2c_one, addresses[3]) + ina219_five= INA219(i2c_two, addresses[4]) + ina219_six = INA219(i2c_two, addresses[5]) + ina219_seven = INA219(i2c_two, addresses[6]) + ina219_eight = INA219(i2c_two, addresses[7]) + + while (True): + + print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') + print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') + print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') + print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') + + print(" ") + inp = input() +# print(inp) + From bbdc02163b11e1bba2f2e7efe07712f18bcf9bcf Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:39:42 -0500 Subject: [PATCH 074/210] Update voltcurrent.py --- python/voltcurrent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 5decd333..a0cec3c9 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -51,7 +51,8 @@ if __name__ == "__main__": ina219.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S # optional : change voltage range to 16V ina219.bus_voltage_range = BusVoltageRange.RANGE_16V - + except: + except: # No try checking yet i2c_one = I2C(buses[0]) From 918961128786be6a0aad487a283d674e624062e3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:41:01 -0500 Subject: [PATCH 075/210] Update voltcurrent.py --- python/voltcurrent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index a0cec3c9..9b50c02b 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -30,11 +30,11 @@ if __name__ == "__main__": # config for x in buses: - try: +# try: i2c_bus = I2C(x) # Device is /dev/i2c-x for y in addresses: # print(x,y) - try: + # try: # Create library object using Extended Bus I2C port # print("bus: ", x, " addr: ", y) if x == 0 and y == 0x45: @@ -51,8 +51,8 @@ if __name__ == "__main__": ina219.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S # optional : change voltage range to 16V ina219.bus_voltage_range = BusVoltageRange.RANGE_16V - except: - except: +# except: +# except: # No try checking yet i2c_one = I2C(buses[0]) From 60c9192c07d0b63f032f98abec98cbd89841d589 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:41:46 -0500 Subject: [PATCH 076/210] Update voltcurrent.py --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 9b50c02b..3ad89a68 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -58,7 +58,7 @@ if __name__ == "__main__": i2c_one = I2C(buses[0]) i2c_two = I2C(buses[1]) - if (buses[0] == 0) and (addresses[0] == 0x45)): + if buses[0] == 0 and addresses[0] == 0x45: # print("Reading INA219 in MoPower Board") ina219_one = INA219(I2C(1), 0x4a) else From 2f6edf531f385bd47b406ea92afc262e37b0df43 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:42:23 -0500 Subject: [PATCH 077/210] Update voltcurrent.py --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 3ad89a68..a3bd1f29 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -61,7 +61,7 @@ if __name__ == "__main__": if buses[0] == 0 and addresses[0] == 0x45: # print("Reading INA219 in MoPower Board") ina219_one = INA219(I2C(1), 0x4a) - else + else: ina219_one = INA219(i2c_one, addresses[0]) ina219_two = INA219(i2c_one, addresses[1]) ina219_three = INA219(i2c_one, addresses[2]) From 55f501a20292e2cd782bf1b0d6bce3cc1adf9add Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:51:19 -0500 Subject: [PATCH 078/210] Update voltcurrent.py --- python/voltcurrent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index a3bd1f29..fc6acd67 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -72,8 +72,8 @@ if __name__ == "__main__": ina219_eight = INA219(i2c_two, addresses[7]) while (True): - - print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') +# print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') From 68bdc3061f12a6ccd501ec0d7d6109e95c97926d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:52:19 -0500 Subject: [PATCH 079/210] Update voltcurrent.py --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index fc6acd67..d0865794 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -72,7 +72,7 @@ if __name__ == "__main__": ina219_eight = INA219(i2c_two, addresses[7]) while (True): - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) # print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') From 33eb137600911001bf1c460b3574240c3e762d1e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:53:22 -0500 Subject: [PATCH 080/210] Update voltcurrent.py --- python/voltcurrent.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index d0865794..a5c3f50b 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -72,15 +72,15 @@ if __name__ == "__main__": ina219_eight = INA219(i2c_two, addresses[7]) while (True): - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) -# print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') - print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') - print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') - print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') - print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') - print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') - print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') - print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') +# print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current)) # , end = '') + print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current)) # , end = '') + print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current)) # , end = '') + print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current)) # , end = '') + print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current)) # , end = '') + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current)) # , end = '') + print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current)) # , end = '') + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current)) # , end = '') print(" ") inp = input() From db780336dbceaaad0f8cafa0a8f358286f1fca0f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:57:14 -0500 Subject: [PATCH 081/210] Update voltcurrent.py --- python/voltcurrent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index a5c3f50b..e4e63b93 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -66,10 +66,10 @@ if __name__ == "__main__": ina219_two = INA219(i2c_one, addresses[1]) ina219_three = INA219(i2c_one, addresses[2]) ina219_four= INA219(i2c_one, addresses[3]) - ina219_five= INA219(i2c_two, addresses[4]) - ina219_six = INA219(i2c_two, addresses[5]) - ina219_seven = INA219(i2c_two, addresses[6]) - ina219_eight = INA219(i2c_two, addresses[7]) + ina219_five= INA219(i2c_two, addresses[0]) + ina219_six = INA219(i2c_two, addresses[1]) + ina219_seven = INA219(i2c_two, addresses[2]) + ina219_eight = INA219(i2c_two, addresses[3]) while (True): # print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) From cb7a5af64a8cdec8f9418f9fc0db9b6b817775e0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Dec 2020 11:58:10 -0500 Subject: [PATCH 082/210] typo --- python/voltcurrent.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index e4e63b93..f73da809 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -73,14 +73,14 @@ if __name__ == "__main__": while (True): # print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) - print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current)) # , end = '') - print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current)) # , end = '') - print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current)) # , end = '') - print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current)) # , end = '') - print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current)) # , end = '') - print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current)) # , end = '') - print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current)) # , end = '') - print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current)) # , end = '') + print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') + print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') + print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') + print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') print(" ") inp = input() From 4f2823b73967f0c04a59b7c3046dd60c9be6bb0a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 10:13:06 -0500 Subject: [PATCH 083/210] merged in sin_map from dev-faster --- afsk/main.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 0e2d6ab2..c7ce2a53 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -118,6 +118,7 @@ int rpitxStatus = -1; float amplitude; // = ; // 20000; // 32767/(10%amp+5%amp+100%amp) float freq_Hz = 3000; // 1200 +short int sin_samples; int smaller; int flip_ctr = 0; @@ -558,7 +559,15 @@ 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(); @@ -1316,7 +1325,7 @@ else { // printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); } - + if (mode == FSK) { for (int count1 = 0; count1 < 8; count1++) { if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1]; @@ -1344,7 +1353,7 @@ else { // printf("Other min %f max %f \n", other_min[count1], other_max[count1]); } - if (mode == FSK) { +// if (mode == FSK) { if (loop % 8 == 0) { printf("Sending MIN frame \n"); frm_type = 0x03; @@ -1975,10 +1984,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]); } From e2d9badab293f9899403fd59cb8c187f7f15f536 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 10:20:09 -0500 Subject: [PATCH 084/210] typo --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index c7ce2a53..687c6228 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -119,6 +119,7 @@ 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; From b53d2251c7ab972f74007b0460f4709452ab8825 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 10:25:02 -0500 Subject: [PATCH 085/210] sleep(3.8) --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 687c6228..321bfb16 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1095,7 +1095,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(2.3); // No sleep at all! + sleep(3.8); // No sleep at all! // sleep(1.3); digitalWrite(txLed, txLedOff); From f8cf009a956bd14cdc7d7a240369f76471ef5ad6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 10:41:08 -0500 Subject: [PATCH 086/210] changed MAX MIN --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 321bfb16..78199937 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1326,7 +1326,7 @@ else { // printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); } - if (mode == FSK) { +// if (mode == FSK) { for (int count1 = 0; count1 < 8; count1++) { if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1]; @@ -1354,7 +1354,7 @@ else { // printf("Other min %f max %f \n", other_min[count1], other_max[count1]); } -// if (mode == FSK) { + if (mode == FSK) { if (loop % 8 == 0) { printf("Sending MIN frame \n"); frm_type = 0x03; From ac36259312bfb18480377617e037ff8ce811b419 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 10:54:00 -0500 Subject: [PATCH 087/210] sleep(3.3) --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 78199937..f0aa1f1a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1095,7 +1095,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(3.8); // No sleep at all! + sleep(3.3); // No sleep at all! // sleep(1.3); digitalWrite(txLed, txLedOff); From 70597757500f883550bb4d8d118a4a5040edf617 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:04:14 -0500 Subject: [PATCH 088/210] added back in socket resend --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f0aa1f1a..810c34ef 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1726,15 +1726,15 @@ else { // 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); // sleep(2.5); 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"); + sock_ret = send(sock, buffer[sock_ret], ctr * 2 + 2 - sock_ret, 0); + printf("Millis6: %d Result of socket send: %d \n\n", millis() - start, sock_ret); } if (sock_ret == -1) { From d08054b8c3f5b03256ac5e7af257e936cb3f6a56 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:10:27 -0500 Subject: [PATCH 089/210] socket resend not working yet --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 810c34ef..841903f7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1733,7 +1733,7 @@ else { if (sock_ret < (ctr * 2 + 2)) { // printf("Not resending\n"); - sock_ret = send(sock, buffer[sock_ret], ctr * 2 + 2 - sock_ret, 0); + sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); printf("Millis6: %d Result of socket send: %d \n\n", millis() - start, sock_ret); } From 10de25168321f68dc402b9a95d665ea9739500b0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:21:54 -0500 Subject: [PATCH 090/210] added sleep(0.5) if resending --- afsk/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 841903f7..fb9684d7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1728,13 +1728,11 @@ else { int sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); printf("Millis6: %d Result of socket send: %d \n\n", (unsigned int)millis() - start, sock_ret); -// sleep(2.5); - - if (sock_ret < (ctr * 2 + 2)) { // printf("Not resending\n"); - sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); - printf("Millis6: %d Result of socket send: %d \n\n", millis() - start, sock_ret); + sleep(0.5); + sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); + printf("Millis6: %d Result of socket send: %d \n\n", millis() - start, sock_ret); } if (sock_ret == -1) { From dad7f9d13988d99e8e13a18522346a60006a6b20 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:27:09 -0500 Subject: [PATCH 091/210] Working, turning on payload --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index fb9684d7..3d929bd6 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1254,7 +1254,7 @@ else { - if (payload == -55) { // ON + if (payload == ON) { // -55 STEMBoardFailure = 0; char c; From 2b20f1170e72838ca20dd8d231a4cb7882a5b09e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:33:10 -0500 Subject: [PATCH 092/210] try turning firstTime on again --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 3d929bd6..8616b400 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -98,7 +98,7 @@ static int init_rf(); int socket_open = 0; int sock = 0; int loop = -1, loop_count = 0; -int firstTime = 0; // ON; +int firstTime = ON; // 0; long start; int testCount = 0; long time_start; From b50723f8cf540b807d39b5c258ff7db85328c126 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:39:03 -0500 Subject: [PATCH 093/210] removed python test at start --- afsk/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 8616b400..b5546611 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -349,13 +349,12 @@ int main(int argc, char * argv[]) { file1 = sopen(pythonConfigStr); // try new function fgets(cmdbuffer, 1000, file1); printf("pythonStr result: %s\n", cmdbuffer); - +/* sleep(5); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); printf("pythonStr result2: %s\n", cmdbuffer); - -/* + file1 = popen(pythonConfigStr, "w"); fgets(cmdbuffer, 1000, file1); @@ -1287,7 +1286,7 @@ else { sensor_payload[i++] = ' '; // sensor_payload[i++] = '\n'; sensor_payload[i] = '\0'; - printf("Payload string: %s \n", sensor_payload); + printf("Payload string: %s", sensor_payload); if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) // only process if valid payload response { From fd3f41e2ac0002b8a03ef5b35ec055baf8b58923 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:44:12 -0500 Subject: [PATCH 094/210] turn payload off --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index b5546611..f1b10ced 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1253,7 +1253,7 @@ else { - if (payload == ON) { // -55 + if (payload == -55) { // ON STEMBoardFailure = 0; char c; From 01067606b8b0354bee8015a1a0a6051c117c4573 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:51:25 -0500 Subject: [PATCH 095/210] no cpu limit --- demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 38aa9a74..89c96368 100755 --- a/demo.sh +++ b/demo.sh @@ -16,7 +16,7 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then /home/pi/CubeSatSim/radioafsk afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then echo "Mode is continuous BPSK" - sudo cpulimit -l 5 -P radioafsk & +# sudo cpulimit -l 5 -P radioafsk & /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" From 5b0394d782749a81d4449eadd0b817b37c7cbb6e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:57:09 -0500 Subject: [PATCH 096/210] Working OK without cpu limit, MAX MIN not correct for FSK --- afsk/main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f1b10ced..f16fe055 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -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 From b5099b6cc7a73295c4863a5f2f60191d93e23b26 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 11:57:34 -0500 Subject: [PATCH 097/210] turn on payload --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index f16fe055..ae638efe 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1251,7 +1251,7 @@ else { - if (payload == -55) { // ON + if (payload == ON) { // -55 STEMBoardFailure = 0; char c; From e36e5ff678bb0cc1e9c506e7749c914e3f24b6f1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 12:13:10 -0500 Subject: [PATCH 098/210] Working pretty well, removed duplicate Sample period printf --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index ae638efe..24329b44 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1100,7 +1100,7 @@ void get_tlm_fox() { // printf("Tx LED Off\n"); #endif - printf("Sample period: %d\n", millis() - (unsigned int)sampleTime); +// printf("Sample period: %d\n", millis() - (unsigned int)sampleTime); sampleTime = (unsigned int) millis(); } else printf("first time - no sleep\n"); From 8697d11071d8e584b37bb797426483d428295572 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 15:05:47 -0500 Subject: [PATCH 099/210] investigate Imax and min --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 24329b44..0663baa7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1335,7 +1335,7 @@ else { if (current[count1] > current_max[count1]) current_max[count1] = current[count1]; - // printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); + printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); } From 1f05cd054ff9bfd3b64d7aafcb13888d341c54a9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 15:23:55 -0500 Subject: [PATCH 100/210] fix max min --- afsk/main.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 0663baa7..e65bf48a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -612,7 +612,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 } @@ -1022,7 +1022,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; @@ -1030,7 +1030,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; @@ -1114,6 +1114,13 @@ void get_tlm_fox() { memset(sensor, 0, sizeof(sensor)); 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 @@ -1319,11 +1326,11 @@ else { sensor_min[count1] = sensor[count1]; if (sensor[count1] > sensor_max[count1]) sensor_max[count1] = sensor[count1]; - + } // just added // printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); } -// if (mode == FSK) { + if (mode == FSK) { // just added for (int count1 = 0; count1 < 8; count1++) { if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1]; @@ -1383,13 +1390,13 @@ else { } 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"); From 52652e5124d822a1ce658d9f48846e529520a140 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 15:30:48 -0500 Subject: [PATCH 101/210] formatting --- afsk/main.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index e65bf48a..37442813 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1256,8 +1256,6 @@ else { } fclose(cpuTempSensor); - - if (payload == ON) { // -55 STEMBoardFailure = 0; @@ -1316,38 +1314,33 @@ else { } } printf("\n"); - } - } - if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { + 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]; - } // just added // printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]); - - } - if (mode == FSK) { // just added - 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 %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); + } // just added } - - - } + if (mode == FSK) { // just added + 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 %f Vmax %f Imin %f Imax %f \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]) From f4155d1f0f3ac6190d9857c88977d073b4414cbe Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 15:51:39 -0500 Subject: [PATCH 102/210] trying to fix max and min --- afsk/main.c | 230 +++++++++++++++++++++++++--------------------------- 1 file changed, 110 insertions(+), 120 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 37442813..58380349 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1114,15 +1114,15 @@ void get_tlm_fox() { memset(sensor, 0, sizeof(sensor)); 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 + 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; @@ -1132,11 +1132,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); @@ -1193,139 +1188,137 @@ void get_tlm_fox() { // end of simulated telemetry } - -else { - int count1; - char * token; + else { + int count1; + char * token; // char cmdbuffer[1000]; /**/ // FILE * file = popen(pythonStr, "r"); - fputc('\n', file1); - fgets(cmdbuffer, 1000, file1); + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); // printf("Python read Result: %s\n", cmdbuffer); // pclose(file); /**/ - const char space[2] = " "; - token = strtok(cmdbuffer, space); + 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); + for (count1 = 0; count1 < 8; count1++) { if (token != NULL) { - current[count1] = (float) atof(token); - if ((current[count1] < 0) && (current[count1] > -0.5)) - current[count1] *= (-1.0f); + voltage[count1] = (float) atof(token); #ifdef DEBUG_LOGGING - // printf("current: %f\n", current[count1]); + // 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; + 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; + 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 + #ifdef DEBUG_LOGGING + printf("CPU Temp Read: %6.1f\n", cpuTemp); + #endif - other[IHU_TEMP] = (double)cpuTemp; + other[IHU_TEMP] = (double)cpuTemp; - // IHUcpuTemp = (int)((cpuTemp * 10.0) + 0.5); - } - fclose(cpuTempSensor); + // IHUcpuTemp = (int)((cpuTemp * 10.0) + 0.5); + } + fclose(cpuTempSensor); - if (payload == ON) { // -55 - STEMBoardFailure = 0; + if (payload == ON) { // -55 + STEMBoardFailure = 0; - char c; - int charss = (char) serialDataAvail(uart_fd); - if (charss != 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 + 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; + 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); + 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]; + 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); + 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"); } - printf("\n"); + } + 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 ((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]); - } // just added - } - if (mode == FSK) { // just added + if (mode == FSK) { // just moved for (int count1 = 0; count1 < 8; count1++) { if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1]; @@ -1338,19 +1331,16 @@ else { current_max[count1] = current[count1]; printf("Vmin %f Vmax %f Imin %f Imax %f \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]); - } + } + 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]); + } + } // just moved again if (mode == FSK) { if (loop % 8 == 0) { printf("Sending MIN frame \n"); From d3ec5b374942da48e978ba34269e9aa2aca27784 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 16:03:36 -0500 Subject: [PATCH 103/210] cleanup --- afsk/main.c | 60 ++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 58380349..7d61af3b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1340,37 +1340,38 @@ void get_tlm_fox() { // printf("Other min %f max %f \n", other_min[count1], other_max[count1]); } - } // just moved again - 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 (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 (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 ((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]; } - if (sensor_max[count1] != -1000.0) // make sure values are valid - sensor[count1] = sensor_max[count1]; - } - } - } + } + } + +// if (mode == FSK) { // remove this +// } memset(rs_frame, 0, sizeof(rs_frame)); memset(parities, 0, sizeof(parities)); /* @@ -1424,9 +1425,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); From 07d6e22f370c3573cb47cc14f2bbeb8e5928849f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 16:04:19 -0500 Subject: [PATCH 104/210] more cleanup --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 7d61af3b..994b4652 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1330,7 +1330,7 @@ void get_tlm_fox() { if (current[count1] > current_max[count1]) current_max[count1] = current[count1]; - printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[count1]); + // printf("Vmin %f Vmax %f Imin %f Imax %f \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]) From 06aee250658c105da56e9ab9e70d1a9b972640be Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 16:30:19 -0500 Subject: [PATCH 105/210] removed cpu fields --- systemd/cubesatsim.service | 2 -- 1 file changed, 2 deletions(-) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index d43b3cac..633f689d 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -10,8 +10,6 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root -CPUAccounting=true -CPUQuota=2.5% [Install] WantedBy=default.target From a29d36f9177ec87b8d33ecadd2ed0b02137704e4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 30 Dec 2020 16:40:42 -0500 Subject: [PATCH 106/210] put CPUquota back in --- systemd/cubesatsim.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index 633f689d..d43b3cac 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -10,6 +10,8 @@ StandardOutput=inherit StandardError=inherit Restart=always User=root +CPUAccounting=true +CPUQuota=2.5% [Install] WantedBy=default.target From 41179de447f8b253196ba5ae228ccadcffa9ebc8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 1 Jan 2021 12:55:36 -0500 Subject: [PATCH 107/210] added cpulimit for BPSK mode --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0211ae85..75e1b7ae 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Requires: - pi-power-button - Direwolf - rpitx +- cpulimit See the Wiki Software Install page for more details: https://github.com/alanbjohnston/CubeSatSim/wiki/Software-Install. Runs on a Raspberry Pi 3B, 3B+, or Pi Zero W (Does NOT work on a Pi 4 since rpitx does not work on it yet). The Pi Zero W or Pi Zero are recommended since they are draw the least power and will result in the best performance under battery power. @@ -22,7 +23,7 @@ To begin the software install, after logging in type: `sudo apt update -y && sudo apt dist-upgrade -y` -`sudo apt install -y wiringpi git libasound2-dev i2c-tools` +`sudo apt install -y wiringpi git libasound2-dev i2c-tools cpulimit` If you are installing on a Pi 4B, you will need to install the 2.52 version of wiring pi by following these steps (you can skip these steps for any other Pi version): From a27383dd617fe522be3687d522678e114242db17 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 1 Jan 2021 13:21:16 -0500 Subject: [PATCH 108/210] added missing pinMode for green and blue LEDs --- arduino/Payload_BME280_MPU6050_XS.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arduino/Payload_BME280_MPU6050_XS.ino b/arduino/Payload_BME280_MPU6050_XS.ino index 342150ed..457621b4 100644 --- a/arduino/Payload_BME280_MPU6050_XS.ino +++ b/arduino/Payload_BME280_MPU6050_XS.ino @@ -76,6 +76,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() { @@ -261,6 +263,6 @@ 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 } From 9c8b60fa5d27dbe68ff0ccc661fd6402f1d843bb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 3 Jan 2021 09:45:55 -0500 Subject: [PATCH 109/210] fixed APRS mode python read --- afsk/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 994b4652..ef34ecc8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -694,10 +694,11 @@ void get_tlm(void) { char * token; // char cmdbuffer[1000]; - FILE * file = popen(pythonStr, "r"); +// FILE * file = popen(pythonStr, "r"); + fputc('\n', file1); fgets(cmdbuffer, 1000, file); // printf("result: %s\n", cmdbuffer); - pclose(file); +// pclose(file); const char space[2] = " "; token = strtok(cmdbuffer, space); From d4ac2bb073fe7e1941447fec125d0d25c4b3645b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 3 Jan 2021 09:47:31 -0500 Subject: [PATCH 110/210] typo --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index ef34ecc8..64713fe1 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -696,7 +696,7 @@ void get_tlm(void) { // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); - fgets(cmdbuffer, 1000, file); + fgets(cmdbuffer, 1000, file1); // printf("result: %s\n", cmdbuffer); // pclose(file); From 278e84fcd9ba51b18ec5add173a5cc0249405a0f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 3 Jan 2021 10:28:20 -0500 Subject: [PATCH 111/210] change sleep(3.3) to 2.3 --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 64713fe1..dbac87ce 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1093,7 +1093,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(3.3); // No sleep at all! + sleep(2.3); // No sleep at all! // sleep(1.3); digitalWrite(txLed, txLedOff); From e7c1a4de3682393e06321a5e67191288aa94a863 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 3 Jan 2021 10:28:55 -0500 Subject: [PATCH 112/210] added back in cpulimit --- demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 89c96368..38aa9a74 100755 --- a/demo.sh +++ b/demo.sh @@ -16,7 +16,7 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then /home/pi/CubeSatSim/radioafsk afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then echo "Mode is continuous BPSK" -# sudo cpulimit -l 5 -P radioafsk & + sudo cpulimit -l 5 -P radioafsk & /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" From 863dddbbb55c3939889718bf3f22437baa853817 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 11:12:21 -0400 Subject: [PATCH 113/210] send frame twice over socket --- afsk/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index dbac87ce..cd4a19d8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1718,7 +1718,17 @@ void get_tlm_fox() { // printf("Not resending\n"); sleep(0.5); sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); - printf("Millis6: %d Result of socket send: %d \n\n", millis() - start, sock_ret); + printf("Millis7: %d Result of socket send: %d \n\n", millis() - start, sock_ret); + } + 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) { From fdd5fd0fd9823696193209b556c3c363d79b488d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 11:27:23 -0400 Subject: [PATCH 114/210] printout PythonConfigStr --- afsk/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index cd4a19d8..3f551058 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -343,6 +343,8 @@ int main(int argc, char * argv[]) { strcat(pythonStr, busStr); strcat(pythonConfigStr, pythonStr); strcat(pythonConfigStr, " c"); + + printf("pythonConfigStr: %s\n", pythonConfigStr); file1 = sopen(pythonConfigStr); // try new function fgets(cmdbuffer, 1000, file1); From b65770fc81c793952b145d2611c576afdfd929d3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 11:34:10 -0400 Subject: [PATCH 115/210] changed a printf to fprintf(stderr --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 3f551058..15a9a0c6 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -344,11 +344,11 @@ int main(int argc, char * argv[]) { strcat(pythonConfigStr, pythonStr); strcat(pythonConfigStr, " c"); - printf("pythonConfigStr: %s\n", pythonConfigStr); + fprintf(stderr, "pythonConfigStr: %s\n", pythonConfigStr); file1 = sopen(pythonConfigStr); // try new function fgets(cmdbuffer, 1000, file1); - printf("pythonStr result: %s\n", cmdbuffer); + fprintf(stderr, "pythonStr result: %s\n", cmdbuffer); /* sleep(5); fputc('\n', file1); From 79af4adb00d03642dd3c7fde539de14c4e101a43 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 12:36:41 -0400 Subject: [PATCH 116/210] moved config import to start --- python/voltcurrent.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index f73da809..13b260aa 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -6,6 +6,7 @@ import sys 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) @@ -14,18 +15,18 @@ if __name__ == "__main__": config = False if (len(sys.argv)) > 1: -# print("There are arguments!") -# if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): + print("There are arguments!") + if (('a' == sys.argv[1]) or ('afsk' in 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 + addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus -# print("buses: ", buses, " addr: ", addresses) + print("buses: ", buses, " addr: ", addresses) # config From b3951050fb6513d89c8b39803dc22590e92ca9fb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 14:46:03 -0400 Subject: [PATCH 117/210] added in try except --- python/voltcurrent.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 13b260aa..79ac4294 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -31,29 +31,29 @@ if __name__ == "__main__": # config for x in buses: -# try: + try: i2c_bus = I2C(x) # Device is /dev/i2c-x for y in addresses: - # print(x,y) - # try: + print(x,y) + try: # Create library object using Extended Bus I2C port -# print("bus: ", x, " addr: ", y) + 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") + print("ina219 test") -# print("Configuring") + 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 # optional : change voltage range to 16V ina219.bus_voltage_range = BusVoltageRange.RANGE_16V -# except: -# except: + except: + except: # No try checking yet i2c_one = I2C(buses[0]) From 167924c067667bef4673e28b1d1a0610c7051bed Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 14:48:37 -0400 Subject: [PATCH 118/210] indent typo --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 79ac4294..3be10e1f 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -34,7 +34,7 @@ if __name__ == "__main__": try: i2c_bus = I2C(x) # Device is /dev/i2c-x for y in addresses: - print(x,y) + print(x,y) try: # Create library object using Extended Bus I2C port print("bus: ", x, " addr: ", y) From 6a43dddb7bccf36d235b79058e4e277e8750bf3e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 14:49:46 -0400 Subject: [PATCH 119/210] more indent --- python/voltcurrent.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 3be10e1f..0831b657 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -37,7 +37,7 @@ if __name__ == "__main__": print(x,y) try: # Create library object using Extended Bus I2C port - print("bus: ", x, " addr: ", y) + print("bus: ", x, " addr: ", y) if x == 0 and y == 0x45: # print("Reading INA219 in MoPower Board") i2c_bus = I2C(1) @@ -53,7 +53,9 @@ if __name__ == "__main__": # optional : change voltage range to 16V ina219.bus_voltage_range = BusVoltageRange.RANGE_16V except: + print("Error 2") except: + print("Error 1") # No try checking yet i2c_one = I2C(buses[0]) From 854536bbce229f730fb6ae54576ae59c267a2f08 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 14:50:32 -0400 Subject: [PATCH 120/210] and more --- python/voltcurrent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 0831b657..be450497 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -44,9 +44,9 @@ if __name__ == "__main__": ina219 = INA219(i2c_bus, 0x4a) else: ina219 = INA219(i2c_bus, y) - print("ina219 test") + print("ina219 test") - print("Configuring") + 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 From b81c1d104dd1ebe40070b538713e5fe5ab52f6d0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 15:10:04 -0400 Subject: [PATCH 121/210] added , file=sys.stderr) --- python/voltcurrent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index be450497..4b4bbce6 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -15,7 +15,7 @@ if __name__ == "__main__": config = False 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])): buses[0] = int(sys.argv[1], base=10) if (len(sys.argv)) > 2: @@ -26,7 +26,7 @@ if __name__ == "__main__": addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus - print("buses: ", buses, " addr: ", addresses) + print("buses: ", buses, " addr: ", addresses, file=sys.stderr) # config @@ -53,9 +53,9 @@ if __name__ == "__main__": # optional : change voltage range to 16V ina219.bus_voltage_range = BusVoltageRange.RANGE_16V except: - print("Error 2") + print("Error 2", file=sys.stderr) except: - print("Error 1") + print("Error 1", file=sys.stderr) # No try checking yet i2c_one = I2C(buses[0]) From b38e528681ddcc19ae4b629c3eaf63075b502785 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 15:23:17 -0400 Subject: [PATCH 122/210] changed UART to 115200 --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 15a9a0c6..3389f529 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -383,7 +383,7 @@ int main(int argc, char * argv[]) { { 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) From 8f7cc9afe16120f653dfaa08894452165691cc22 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 15:25:58 -0400 Subject: [PATCH 123/210] more try --- python/voltcurrent.py | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 4b4bbce6..083c5bfb 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -53,9 +53,9 @@ if __name__ == "__main__": # optional : change voltage range to 16V ina219.bus_voltage_range = BusVoltageRange.RANGE_16V except: - print("Error 2", file=sys.stderr) + print("Error 2", file=sys.stderr, flush=True) except: - print("Error 1", file=sys.stderr) + print("Error 1", file=sys.stderr, flush=True) # No try checking yet i2c_one = I2C(buses[0]) @@ -66,25 +66,29 @@ if __name__ == "__main__": ina219_one = INA219(I2C(1), 0x4a) else: ina219_one = INA219(i2c_one, addresses[0]) - ina219_two = INA219(i2c_one, addresses[1]) - ina219_three = INA219(i2c_one, addresses[2]) - ina219_four= INA219(i2c_one, addresses[3]) - ina219_five= INA219(i2c_two, addresses[0]) - ina219_six = INA219(i2c_two, addresses[1]) - ina219_seven = INA219(i2c_two, addresses[2]) - ina219_eight = INA219(i2c_two, addresses[3]) - + try: + ina219_two = INA219(i2c_one, addresses[1]) + ina219_three = INA219(i2c_one, addresses[2]) + ina219_four= INA219(i2c_one, addresses[3]) + ina219_five= INA219(i2c_two, addresses[0]) + ina219_six = INA219(i2c_two, addresses[1]) + ina219_seven = INA219(i2c_two, addresses[2]) + ina219_eight = INA219(i2c_two, addresses[3]) + except: + print("Error 3", file=sys.stderr, flush=True) while (True): -# print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) - print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') - print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') - print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') - print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') - print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') - print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') - print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') - print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') - + try: +# print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') + print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') + print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') + print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') + except: + print("Error 4", file=sys.stderr, flush=True) print(" ") inp = input() # print(inp) From 41fb0eab3242d042eff9ac340f512d2766e26f75 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 18:16:40 -0400 Subject: [PATCH 124/210] added test for BPSK mode for 2nd socket send --- afsk/main.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 3389f529..17663030 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1722,15 +1722,19 @@ void get_tlm_fox() { 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); } - 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)) { + 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); + 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) { From 324ede0095f5c004fb65e903b83844f9ba7828c4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 18:47:38 -0400 Subject: [PATCH 125/210] removed MoPower support --- python/voltcurrent.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 083c5bfb..44be4bc6 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -61,12 +61,13 @@ if __name__ == "__main__": i2c_one = I2C(buses[0]) i2c_two = I2C(buses[1]) - if buses[0] == 0 and addresses[0] == 0x45: +# if buses[0] == 0 and addresses[0] == 0x45: # print("Reading INA219 in MoPower Board") - ina219_one = INA219(I2C(1), 0x4a) - else: +# ina219_one = INA219(I2C(1), 0x4a) +# else: + try: ina219_one = INA219(i2c_one, addresses[0]) - try: +# try: ina219_two = INA219(i2c_one, addresses[1]) ina219_three = INA219(i2c_one, addresses[2]) ina219_four= INA219(i2c_one, addresses[3]) From 882e04f61026cb1b7c0e426249d78565ce946903 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 18:56:09 -0400 Subject: [PATCH 126/210] commented out prints --- python/voltcurrent.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 44be4bc6..6da4d182 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -15,7 +15,7 @@ if __name__ == "__main__": config = False if (len(sys.argv)) > 1: - print("There are arguments!", file=sys.stderr) +# print("There are arguments!", file=sys.stderr) if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): buses[0] = int(sys.argv[1], base=10) if (len(sys.argv)) > 2: @@ -26,7 +26,7 @@ if __name__ == "__main__": addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus - print("buses: ", buses, " addr: ", addresses, file=sys.stderr) +# print("buses: ", buses, " addr: ", addresses, file=sys.stderr) # config @@ -34,17 +34,17 @@ if __name__ == "__main__": try: i2c_bus = I2C(x) # Device is /dev/i2c-x for y in addresses: - print(x,y) +# print(x,y) try: # Create library object using Extended Bus I2C port - print("bus: ", x, " addr: ", y) +# 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") +# print("ina219 test") print("Configuring") # optional : change configuration to use 32 samples averaging for both bus voltage and shunt voltage @@ -93,4 +93,3 @@ if __name__ == "__main__": print(" ") inp = input() # print(inp) - From ee30f44a94923408c6331fbf9edad343e6349b94 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 18:56:44 -0400 Subject: [PATCH 127/210] removed last print --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 6da4d182..08105f24 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -46,7 +46,7 @@ if __name__ == "__main__": ina219 = INA219(i2c_bus, y) # print("ina219 test") - print("Configuring") +# 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 From 63335e3e138560fc3ae00e4b8814118f91722940 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 19:08:15 -0400 Subject: [PATCH 128/210] added Python to error message --- python/voltcurrent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 08105f24..68b5da05 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -53,9 +53,9 @@ if __name__ == "__main__": # optional : change voltage range to 16V ina219.bus_voltage_range = BusVoltageRange.RANGE_16V except: - print("Error 2", file=sys.stderr, flush=True) + print("Python Error 2", file=sys.stderr, flush=True) except: - print("Error 1", file=sys.stderr, flush=True) + print("Python Error 1", file=sys.stderr, flush=True) # No try checking yet i2c_one = I2C(buses[0]) @@ -76,7 +76,7 @@ if __name__ == "__main__": ina219_seven = INA219(i2c_two, addresses[2]) ina219_eight = INA219(i2c_two, addresses[3]) except: - print("Error 3", file=sys.stderr, flush=True) + print("Python Error 3", file=sys.stderr, flush=True) while (True): try: # print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) @@ -89,7 +89,7 @@ if __name__ == "__main__": print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') except: - print("Error 4", file=sys.stderr, flush=True) + print("Python Error 4", file=sys.stderr, flush=True) print(" ") inp = input() # print(inp) From 7ef595e4bbb299115382d0dd8a5d0db64f133386 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 29 May 2021 19:20:20 -0400 Subject: [PATCH 129/210] double clearing buffer --- afsk/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 17663030..907a0b9d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1260,6 +1260,12 @@ void get_tlm_fox() { 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; From 421547dd9bf15d8b78c3aa0dd6c8eb4846d0eefa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 08:11:33 -0400 Subject: [PATCH 130/210] removed double clearing buffer --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 907a0b9d..57664283 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1260,12 +1260,13 @@ void get_tlm_fox() { 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; From 2f47c5fb5eccccf84c7e61c881936c04e5bb47e1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 08:59:46 -0400 Subject: [PATCH 131/210] Try 5% --- systemd/cubesatsim.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index d43b3cac..e704d5b8 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -11,7 +11,7 @@ StandardError=inherit Restart=always User=root CPUAccounting=true -CPUQuota=2.5% +CPUQuota=5% [Install] WantedBy=default.target From c7f6c7dda0fbd76e85deb909d23666b151d429ca Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 09:16:36 -0400 Subject: [PATCH 132/210] added -m to cpulimit to monitor forks --- demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 38aa9a74..7b6214ac 100755 --- a/demo.sh +++ b/demo.sh @@ -16,7 +16,7 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then /home/pi/CubeSatSim/radioafsk afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then echo "Mode is continuous BPSK" - sudo cpulimit -l 5 -P radioafsk & + sudo cpulimit -l 5 -m -P radioafsk & /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" From 8b8f2690470a2ffe3bf37bfbf3f5a15312008f57 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 09:27:57 -0400 Subject: [PATCH 133/210] added -b for background instead of & for cpulimit --- demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 7b6214ac..0566a9d5 100755 --- a/demo.sh +++ b/demo.sh @@ -16,7 +16,7 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then /home/pi/CubeSatSim/radioafsk afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then echo "Mode is continuous BPSK" - sudo cpulimit -l 5 -m -P radioafsk & + sudo cpulimit -l 5 -m -b -P radioafsk /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" From 62525ae66620ef6d9b09eb9dfa5129931223d631 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 09:35:31 -0400 Subject: [PATCH 134/210] cpulimit to 10 --- demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 0566a9d5..2052a893 100755 --- a/demo.sh +++ b/demo.sh @@ -16,7 +16,7 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then /home/pi/CubeSatSim/radioafsk afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then echo "Mode is continuous BPSK" - sudo cpulimit -l 5 -m -b -P radioafsk + sudo cpulimit -l 10 -m -b -P radioafsk /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" From 203dacb7471600f4df72c07da55506c0e6c02166 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 10:55:38 -0400 Subject: [PATCH 135/210] without -m --- demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 2052a893..7b645077 100755 --- a/demo.sh +++ b/demo.sh @@ -16,7 +16,7 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then /home/pi/CubeSatSim/radioafsk afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then echo "Mode is continuous BPSK" - sudo cpulimit -l 10 -m -b -P radioafsk + sudo cpulimit -l 10 -b -P radioafsk /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" From d88d0d2cfcf621925469ee71b59854bae35c1e77 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 12:56:10 -0400 Subject: [PATCH 136/210] changed to 2.5 for 6 frames/min --- demo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 7b645077..84b71b50 100755 --- a/demo.sh +++ b/demo.sh @@ -16,7 +16,7 @@ if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then /home/pi/CubeSatSim/radioafsk afsk elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then echo "Mode is continuous BPSK" - sudo cpulimit -l 10 -b -P radioafsk + sudo cpulimit -l 2.5 -b -P radioafsk /home/pi/CubeSatSim/radioafsk bpsk elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then echo "Mode is continuous SSTV" From 2cdb41f04fc6969cd16f456bf85e4ee85310c113 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 13:00:45 -0400 Subject: [PATCH 137/210] removed sleep(2.3) --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 57664283..097e183f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1095,7 +1095,7 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - sleep(2.3); // No sleep at all! +// sleep(2.3); // No sleep at all! // sleep(1.3); digitalWrite(txLed, txLedOff); From d836c622a8f4cfc66e5ef96ab10d251c1b2ca95e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 13:01:42 -0400 Subject: [PATCH 138/210] Only sleep(2.3) for FSK --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 097e183f..96f2c6b2 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1095,7 +1095,8 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ -// sleep(2.3); // No sleep at all! + if (mode == FSK) // don't sleep for BPSK + sleep(2.3); // No sleep at all! // sleep(1.3); digitalWrite(txLed, txLedOff); From df7e53c0facf0178590f2755ab09def01d1f0934 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 13:09:13 -0400 Subject: [PATCH 139/210] sleep 4.3 for BPSK --- afsk/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 96f2c6b2..fc135819 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1095,9 +1095,10 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - if (mode == FSK) // don't sleep for BPSK + if (mode == FSK) sleep(2.3); // No sleep at all! -// sleep(1.3); + else + sleep(4.3); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From b40eee5ca8fcdda74eaf035c8899ffc0f9c0f46e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 13:30:10 -0400 Subject: [PATCH 140/210] sleep 1.3 for BPSK --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index fc135819..44d84706 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1098,7 +1098,7 @@ void get_tlm_fox() { if (mode == FSK) sleep(2.3); // No sleep at all! else - sleep(4.3); + sleep(1.3); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From fcef731b5e8878903c0441ee87a48672d2612319 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 13:49:24 -0400 Subject: [PATCH 141/210] back to sleep(2.3) for BPSK and FSK --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 44d84706..85e9a01b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1095,10 +1095,10 @@ void get_tlm_fox() { while ((millis() - sampleTime) < (unsigned int)samplePeriod) sleep((unsigned int)sleepTime); */ - if (mode == FSK) +// if (mode == FSK) sleep(2.3); // No sleep at all! - else - sleep(1.3); +// else +// sleep(1.3); digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING From 7d2131773fb8f9b608fdbe152826abae36705216 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 14:46:39 -0400 Subject: [PATCH 142/210] added 0.0 printing if error --- python/voltcurrent.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 68b5da05..2ca0d8e1 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -79,17 +79,37 @@ if __name__ == "__main__": print("Python Error 3", file=sys.stderr, flush=True) while (True): try: -# print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) - print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') + except: + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + try: print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') + except: + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + try: print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') + except: + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + try: print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') + except: + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + try: 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)) + try: print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + except: + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + try: print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') + except: + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + try: print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') except: - print("Python Error 4", file=sys.stderr, flush=True) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) print(" ") inp = input() # print(inp) From 9608766ef5d709e3281063468ab989d24395a6d4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 14:54:16 -0400 Subject: [PATCH 143/210] fixed missing /n --- python/voltcurrent.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 2ca0d8e1..f1675b21 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -81,35 +81,35 @@ if __name__ == "__main__": try: print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: 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)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) + print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') print(" ") inp = input() # print(inp) From 792a2d2dc4ec4424f1c393d8a6f03b1081aea82b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 15:01:26 -0400 Subject: [PATCH 144/210] added try for the configuration --- python/voltcurrent.py | 52 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index f1675b21..33b9d614 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -58,7 +58,7 @@ if __name__ == "__main__": print("Python Error 1", file=sys.stderr, flush=True) # No try checking yet - i2c_one = I2C(buses[0]) + i2c_two = I2C(buses[1]) # if buses[0] == 0 and addresses[0] == 0x45: @@ -66,17 +66,47 @@ if __name__ == "__main__": # ina219_one = INA219(I2C(1), 0x4a) # else: try: - ina219_one = INA219(i2c_one, addresses[0]) -# try: - ina219_two = INA219(i2c_one, addresses[1]) - ina219_three = INA219(i2c_one, addresses[2]) - ina219_four= INA219(i2c_one, addresses[3]) - ina219_five= INA219(i2c_two, addresses[0]) - ina219_six = INA219(i2c_two, addresses[1]) - ina219_seven = INA219(i2c_two, addresses[2]) - ina219_eight = INA219(i2c_two, addresses[3]) + i2c_one = I2C(buses[0]) + try: + ina219_one = INA219(i2c_one, addresses[0]) + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_two = INA219(i2c_one, addresses[1]) + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_three = INA219(i2c_one, addresses[2]) + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_four= INA219(i2c_one, addresses[3]) + except: + print("Python Error 3", file=sys.stderr, flush=True) + except: + print("Python Error 5", file=sys.stderr, flush=True) + + try: + i2c_one = I2C(buses[1]) + try: + ina219_five= INA219(i2c_two, addresses[0]) + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_six = INA219(i2c_two, addresses[1]) + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_seven = INA219(i2c_two, addresses[2]) + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_eight = INA219(i2c_two, addresses[3]) + except: + print("Python Error 3", file=sys.stderr, flush=True) except: - print("Python Error 3", file=sys.stderr, flush=True) + print("Python Error 5", file=sys.stderr, flush=True) + while (True): try: print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') From 21638654f1937902671ce7ef5c4bbe647aeedfe6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 15:30:29 -0400 Subject: [PATCH 145/210] more changes --- python/voltcurrent.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 33b9d614..6fd591f2 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -57,9 +57,6 @@ if __name__ == "__main__": except: print("Python Error 1", file=sys.stderr, flush=True) # No try checking yet - - - i2c_two = I2C(buses[1]) # if buses[0] == 0 and addresses[0] == 0x45: # print("Reading INA219 in MoPower Board") @@ -68,9 +65,13 @@ if __name__ == "__main__": try: i2c_one = I2C(buses[0]) try: - ina219_one = INA219(i2c_one, addresses[0]) - except: - print("Python Error 3", file=sys.stderr, flush=True) + i2c_one = INA219(i2c_one, addresses[0]) + i2c_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + i2c_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + i2c_one.bus_voltage_range = BusVoltageRange.RANGE_16V + oneZero = 1 +# except: +# print("Python Error 3", file=sys.stderr, flush=True) try: ina219_two = INA219(i2c_one, addresses[1]) except: @@ -87,7 +88,7 @@ if __name__ == "__main__": print("Python Error 5", file=sys.stderr, flush=True) try: - i2c_one = I2C(buses[1]) + i2c_two = I2C(buses[1]) try: ina219_five= INA219(i2c_two, addresses[0]) except: @@ -108,9 +109,9 @@ if __name__ == "__main__": print("Python Error 5", file=sys.stderr, flush=True) while (True): - try: + if (zeroOne == 1): print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') - except: + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') From 03113feb852421ca4d3f97f362daff505f3e87ce Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 15:32:13 -0400 Subject: [PATCH 146/210] added except --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 6fd591f2..18c12b02 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -70,7 +70,7 @@ if __name__ == "__main__": i2c_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S i2c_one.bus_voltage_range = BusVoltageRange.RANGE_16V oneZero = 1 -# except: + except: # print("Python Error 3", file=sys.stderr, flush=True) try: ina219_two = INA219(i2c_one, addresses[1]) From d0bef1aa2a262ae9683e4b7a6d71d9062c4324f2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 15:34:10 -0400 Subject: [PATCH 147/210] Update voltcurrent.py --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 18c12b02..2eec3510 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -71,7 +71,7 @@ if __name__ == "__main__": i2c_one.bus_voltage_range = BusVoltageRange.RANGE_16V oneZero = 1 except: -# print("Python Error 3", file=sys.stderr, flush=True) + print("Python Error 3", file=sys.stderr, flush=True) try: ina219_two = INA219(i2c_one, addresses[1]) except: From 526439b81328d51b5c76dfef055e694fa02ca8b1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 15:46:14 -0400 Subject: [PATCH 148/210] more --- python/voltcurrent.py | 58 ++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 2eec3510..e8285f0b 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -30,32 +30,32 @@ if __name__ == "__main__": # config - for x in buses: - try: - i2c_bus = I2C(x) # Device is /dev/i2c-x - for y in addresses: +# for x in buses: +# try: +# i2c_bus = I2C(x) # Device is /dev/i2c-x +# for y in addresses: # print(x,y) - try: +# try: # Create library object using Extended Bus I2C port # print("bus: ", x, " addr: ", y) - if x == 0 and y == 0x45: +# 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) +# 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 - except: - print("Python Error 2", file=sys.stderr, flush=True) - except: - print("Python Error 1", file=sys.stderr, flush=True) +# 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: @@ -65,23 +65,35 @@ if __name__ == "__main__": try: i2c_one = I2C(buses[0]) try: - i2c_one = INA219(i2c_one, addresses[0]) - i2c_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - i2c_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - i2c_one.bus_voltage_range = BusVoltageRange.RANGE_16V - oneZero = 1 + ina219_one = INA219(i2c_one, addresses[0]) + ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V + one = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: ina219_two = INA219(i2c_one, addresses[1]) + ina219_two.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_two.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V + two = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: ina219_three = INA219(i2c_one, addresses[2]) + ina219_three.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_three.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V + three = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: ina219_four= INA219(i2c_one, addresses[3]) + ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V + four = 1 except: print("Python Error 3", file=sys.stderr, flush=True) except: @@ -109,7 +121,7 @@ if __name__ == "__main__": print("Python Error 5", file=sys.stderr, flush=True) while (True): - if (zeroOne == 1): + if (oneZero == 1): print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') From e808ae60beec445fb86a91597cd18d4c35c07d90 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 15:58:27 -0400 Subject: [PATCH 149/210] complete --- python/voltcurrent.py | 50 ++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index e8285f0b..2118e321 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -102,56 +102,72 @@ if __name__ == "__main__": try: i2c_two = I2C(buses[1]) try: - ina219_five= INA219(i2c_two, addresses[0]) + ina219_five = INA219(i2c_two, addresses[0]) + ina219_five.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_five.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V + five = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: ina219_six = INA219(i2c_two, addresses[1]) + ina219_six.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_six.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V + six = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: ina219_seven = INA219(i2c_two, addresses[2]) + ina219_seven.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_seven.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V + seven = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: ina219_eight = INA219(i2c_two, addresses[3]) + ina219_eight.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_eight.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V + eight = 1 except: print("Python Error 3", file=sys.stderr, flush=True) except: print("Python Error 5", file=sys.stderr, flush=True) while (True): - if (oneZero == 1): + if (one == 1): print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + if (two == 1): print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') - except: + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + if (three == 1): print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') - except: + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + if (four == 1): print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') - except: + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + if (five == 1): print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') - except: + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: - print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') - except: + if (six == 1): + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + if (seven == 1): print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') - except: + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + if (eight == 1): print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') - except: + else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') print(" ") inp = input() From 910097540160584824e979e51cf505c2f51b31c6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:00:18 -0400 Subject: [PATCH 150/210] print it2c_two --- python/voltcurrent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 2118e321..6b3476dd 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -101,6 +101,7 @@ if __name__ == "__main__": 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 From 71b14bfc16706ad47af3a07512981bdc0ec7b253 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:01:27 -0400 Subject: [PATCH 151/210] Update voltcurrent.py --- python/voltcurrent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 6b3476dd..1b3867cf 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -69,7 +69,7 @@ if __name__ == "__main__": ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V - one = 1 + oneF = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: @@ -138,7 +138,7 @@ if __name__ == "__main__": print("Python Error 5", file=sys.stderr, flush=True) while (True): - if (one == 1): + if (oneF == 1): print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') From f84b768d2fefb9b429026c7788f6e38172163aaa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:03:29 -0400 Subject: [PATCH 152/210] test for -1 --- python/voltcurrent.py | 146 +++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 1b3867cf..80202b6d 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -62,81 +62,83 @@ if __name__ == "__main__": # print("Reading INA219 in MoPower Board") # ina219_one = INA219(I2C(1), 0x4a) # else: - try: - i2c_one = I2C(buses[0]) + if (buses[0] != -1): try: - ina219_one = INA219(i2c_one, addresses[0]) - ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V - oneF = 1 + i2c_one = I2C(buses[0]) + try: + ina219_one = INA219(i2c_one, addresses[0]) + ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V + oneF = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_two = INA219(i2c_one, addresses[1]) + ina219_two.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_two.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V + two = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_three = INA219(i2c_one, addresses[2]) + ina219_three.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_three.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V + three = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_four= INA219(i2c_one, addresses[3]) + ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V + four = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) except: - print("Python Error 3", file=sys.stderr, flush=True) - try: - ina219_two = INA219(i2c_one, addresses[1]) - ina219_two.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_two.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V - two = 1 - except: - print("Python Error 3", file=sys.stderr, flush=True) - try: - ina219_three = INA219(i2c_one, addresses[2]) - ina219_three.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_three.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V - three = 1 - except: - print("Python Error 3", file=sys.stderr, flush=True) - try: - ina219_four= INA219(i2c_one, addresses[3]) - ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V - four = 1 - except: - print("Python Error 3", file=sys.stderr, flush=True) - except: - print("Python Error 5", file=sys.stderr, flush=True) - - 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 - ina219_five.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V - five = 1 - except: - print("Python Error 3", file=sys.stderr, flush=True) - try: - ina219_six = INA219(i2c_two, addresses[1]) - ina219_six.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_six.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V - six = 1 - except: - print("Python Error 3", file=sys.stderr, flush=True) - try: - ina219_seven = INA219(i2c_two, addresses[2]) - ina219_seven.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_seven.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V - seven = 1 - except: - print("Python Error 3", file=sys.stderr, flush=True) - try: - ina219_eight = INA219(i2c_two, addresses[3]) - ina219_eight.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_eight.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S - ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V - eight = 1 + 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 + ina219_five.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V + five = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_six = INA219(i2c_two, addresses[1]) + ina219_six.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_six.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V + six = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_seven = INA219(i2c_two, addresses[2]) + ina219_seven.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_seven.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V + seven = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) + try: + ina219_eight = INA219(i2c_two, addresses[3]) + ina219_eight.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_eight.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S + ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V + eight = 1 + except: + print("Python Error 3", file=sys.stderr, flush=True) except: - print("Python Error 3", file=sys.stderr, flush=True) - except: - print("Python Error 5", file=sys.stderr, flush=True) - + print("Python Error 5", file=sys.stderr, flush=True) + while (True): if (oneF == 1): print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') From 396b749fe1fc589aedec40baba89e058efbf9d45 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:04:33 -0400 Subject: [PATCH 153/210] Update voltcurrent.py --- python/voltcurrent.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 80202b6d..f0c691bd 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -24,6 +24,8 @@ if __name__ == "__main__": if sys.argv[3] == "c": config = True +print(buses[0]) +print(buses[1]) addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus # print("buses: ", buses, " addr: ", addresses, file=sys.stderr) From 7db971490c9a07613a4b926a6748650dd6b544da Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:06:51 -0400 Subject: [PATCH 154/210] Update voltcurrent.py --- python/voltcurrent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index f0c691bd..59c5d202 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -24,8 +24,8 @@ if __name__ == "__main__": if sys.argv[3] == "c": config = True -print(buses[0]) -print(buses[1]) + print(buses[0]) + print(buses[1]) addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus # print("buses: ", buses, " addr: ", addresses, file=sys.stderr) From 43447b7751c0f0ca96d076654345210217ae84e5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:08:22 -0400 Subject: [PATCH 155/210] Update voltcurrent.py --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 59c5d202..402b1765 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -16,7 +16,7 @@ if __name__ == "__main__": if (len(sys.argv)) > 1: # print("There are arguments!", file=sys.stderr) - if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): +# if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): buses[0] = int(sys.argv[1], base=10) if (len(sys.argv)) > 2: buses[1] = int(sys.argv[2], base=10) From 5142c44931eeb6898b6e074df91d0fc9c8b79119 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:09:55 -0400 Subject: [PATCH 156/210] Update voltcurrent.py --- python/voltcurrent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 402b1765..7e9f18fa 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -13,6 +13,7 @@ if __name__ == "__main__": buses = [1, 3] # default I2C buses config = False + one = two = three = four = five = six = seven = eight = 0 if (len(sys.argv)) > 1: # print("There are arguments!", file=sys.stderr) @@ -72,7 +73,7 @@ if __name__ == "__main__": ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V - oneF = 1 + one = 1 except: print("Python Error 3", file=sys.stderr, flush=True) try: From f236127414dfc61bf2cff7ab0f758b636773f066 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:10:39 -0400 Subject: [PATCH 157/210] Update voltcurrent.py --- python/voltcurrent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 7e9f18fa..7a38f6b1 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -25,8 +25,8 @@ if __name__ == "__main__": if sys.argv[3] == "c": config = True - print(buses[0]) - print(buses[1]) +# print(buses[0]) +# print(buses[1]) addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus # print("buses: ", buses, " addr: ", addresses, file=sys.stderr) @@ -143,7 +143,7 @@ if __name__ == "__main__": print("Python Error 5", file=sys.stderr, flush=True) while (True): - if (oneF == 1): + if (one == 1): print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') From 15985a26caf053d72a2195e6975b1640c77103e7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:19:04 -0400 Subject: [PATCH 158/210] no Error 3 print --- python/voltcurrent.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 7a38f6b1..468b655e 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -75,7 +75,8 @@ if __name__ == "__main__": ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V one = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) +# 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 @@ -83,7 +84,9 @@ if __name__ == "__main__": ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V two = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) +# 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 @@ -91,15 +94,18 @@ if __name__ == "__main__": ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V three = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) - try: +# 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 ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V four = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) + four = 0 +# print("Python Error 3", file=sys.stderr, flush=True) except: print("Python Error 5", file=sys.stderr, flush=True) From b3de8a2d37bffa96ca4f226997a81ad7e716d97f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:20:34 -0400 Subject: [PATCH 159/210] Update voltcurrent.py --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 468b655e..93330375 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -97,7 +97,7 @@ if __name__ == "__main__": # print("Python Error 3", file=sys.stderr, flush=True) three = 0 - try: + try: ina219_four= INA219(i2c_one, addresses[3]) ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S From ace40acd3d0687a6e2c254628d3c5a0c12e0685a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:43:15 -0400 Subject: [PATCH 160/210] removed last print --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 93330375..01ffc0c3 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -112,7 +112,7 @@ if __name__ == "__main__": if (buses[1] != -1): try: i2c_two = I2C(buses[1]) - print(i2c_two) +# print(i2c_two) try: ina219_five = INA219(i2c_two, addresses[0]) ina219_five.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S From c0963fd9511afdcfdcbecb929311d17380f7806d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:55:03 -0400 Subject: [PATCH 161/210] last of Error 3 --- python/voltcurrent.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 01ffc0c3..f5d25c40 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -120,7 +120,8 @@ if __name__ == "__main__": ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V five = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) +# 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 @@ -128,7 +129,8 @@ if __name__ == "__main__": ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V six = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) +# 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 @@ -136,7 +138,8 @@ if __name__ == "__main__": ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V seven = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) +# 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 @@ -144,7 +147,8 @@ if __name__ == "__main__": ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V eight = 1 except: - print("Python Error 3", file=sys.stderr, flush=True) +# print("Python Error 3", file=sys.stderr, flush=True) + eight = 0 except: print("Python Error 5", file=sys.stderr, flush=True) From b82ce4544233015fd9f8388fdc81ed7f14254f06 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 16:57:23 -0400 Subject: [PATCH 162/210] added printf for python results --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 85e9a01b..56358cda 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -699,7 +699,7 @@ void get_tlm(void) { // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); - // printf("result: %s\n", cmdbuffer); + printf("Pyton result: %s\n", cmdbuffer); // pclose(file); const char space[2] = " "; @@ -1201,7 +1201,7 @@ void get_tlm_fox() { // FILE * file = popen(pythonStr, "r"); fputc('\n', file1); fgets(cmdbuffer, 1000, file1); -// printf("Python read Result: %s\n", cmdbuffer); + fprintf(stderr, "Python read Result: %s\n", cmdbuffer); // pclose(file); /**/ const char space[2] = " "; From c9fd5e04461e9aa0c62aabdc5c5346d7c345c986 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 20:37:14 -0400 Subject: [PATCH 163/210] reverted to try except for printing instead of variable one, two, etc. --- python/voltcurrent.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index f5d25c40..38385374 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -153,37 +153,37 @@ if __name__ == "__main__": print("Python Error 5", file=sys.stderr, flush=True) while (True): - if (one == 1): + try: print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') else: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - if (two == 1): + try: print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') - else: + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - if (three == 1): + try: print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') - else: + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - if (four == 1): + try: print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') - else: + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - if (five == 1): + try: print("{:6.3f} ".format(ina219_five.bus_voltage), "{:6.3f} ".format(ina219_five.current) , end = '') - else: + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - if (six == 1): - print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') - else: + try: + print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - if (seven == 1): + try: print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') - else: + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - if (eight == 1): + try: print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') - else: + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') print(" ") inp = input() From 8612116e5f5e4b61225fe88a357b6f91c1decd90 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 20:40:43 -0400 Subject: [PATCH 164/210] else/except typo --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 38385374..d6fca650 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -155,7 +155,7 @@ if __name__ == "__main__": while (True): try: print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') - else: + except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') try: print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') From 4654fc583c82f3937ed7fad8eaf4e1ec9e61d68d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 30 May 2021 21:03:10 -0400 Subject: [PATCH 165/210] turned on max and min frames for a test similar to dev-faster --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 56358cda..a978435f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1330,7 +1330,8 @@ void get_tlm_fox() { } } } - if (mode == FSK) { // just moved +// if (mode == FSK) + { // just moved for (int count1 = 0; count1 < 8; count1++) { if (voltage[count1] < voltage_min[count1]) voltage_min[count1] = voltage[count1]; From 35c04331de84a9450e054f4ea16fd20b6cb51db3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 06:29:59 -0400 Subject: [PATCH 166/210] BPSK only send MAX MIN frames, just +Xv and +Yv so far --- afsk/main.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index a978435f..8bd7110c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1042,8 +1042,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)); @@ -1486,6 +1491,13 @@ 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_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, 30 + head_offset, PSUVoltage); @@ -1557,8 +1569,17 @@ 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 + rs_frame[j][i] = b_max[ctr3 % dataLen]; + update_rs(parities[j], b_max[ctr3 % dataLen]); + frm_type = 0x02; + { + } + // 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]; From 71b914cdb26bc0c376b0872b1452014cd157cae5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 06:53:23 -0400 Subject: [PATCH 167/210] added payload frame checking for MAX Min --- afsk/main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 8bd7110c..c0c73f89 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1574,8 +1574,21 @@ void get_tlm_fox() { rs_frame[j][i] = b[ctr3 % dataLen]; update_rs(parities[j], b[ctr3 % dataLen]); } else // BPSK - rs_frame[j][i] = b_max[ctr3 % dataLen]; - update_rs(parities[j], b_max[ctr3 % dataLen]); + if ((int)(ctr3/dataLen) == 4) + { + rs_frame[j][i] = b_max[ctr3 % dataLen]; + update_rs(parities[j], b_max[ctr3 % dataLen]); + } + else if ((int)(ctr3/dataLen) == 5) + { + 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]); + } frm_type = 0x02; { } From 1f7e2087760f917299813f8a482fd35dd66a0f37 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 07:01:38 -0400 Subject: [PATCH 168/210] always send MAX Min frame BPSK --- afsk/main.c | 62 ++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index c0c73f89..0c158bd8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1358,34 +1358,39 @@ void get_tlm_fox() { // printf("Other min %f max %f \n", other_min[count1], other_max[count1]); } - 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]; - } - } + 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 @@ -1589,7 +1594,6 @@ void get_tlm_fox() { rs_frame[j][i] = b[ctr3 % dataLen]; update_rs(parities[j], b[ctr3 % dataLen]); } - frm_type = 0x02; { } From c33ee9a02da2ed4e7b327fc11e827251ca982c3b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 07:10:11 -0400 Subject: [PATCH 169/210] fixed payload order --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 0c158bd8..e86d4f1a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1579,12 +1579,12 @@ void get_tlm_fox() { rs_frame[j][i] = b[ctr3 % dataLen]; update_rs(parities[j], b[ctr3 % dataLen]); } else // BPSK - if ((int)(ctr3/dataLen) == 4) + 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) == 5) + else if ((int)(ctr3/dataLen) == 4) { rs_frame[j][i] = b_min[ctr3 % dataLen]; update_rs(parities[j], b_min[ctr3 % dataLen]); From 50cff5a94efc3b74fe152f090bdd40ca3eee581a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 07:27:51 -0400 Subject: [PATCH 170/210] rest of battery voltages and currents --- afsk/main.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index e86d4f1a..3317981b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1440,7 +1440,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; @@ -1499,12 +1498,42 @@ void get_tlm_fox() { 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]] * 100)); + encodeB(b_max, 22 + head_offset, (int)(current_max[map[PLUS_Y]] * 100)); + encodeA(b_max, 24 + head_offset, (int)(current_max[map[PLUS_Z]] * 100)); + encodeB(b_max, 25 + head_offset, (int)(current_max[map[MINUS_X]] * 100)); + encodeA(b_max, 27 + head_offset, (int)(current_max[map[MINUS_Y]] * 100)); + encodeB(b_max, 28 + head_offset, (int)(current_max[map[MINUS_Z]] * 100)); + + 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); 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]] * 100)); + encodeB(b_min, 22 + head_offset, (int)(current_min[map[PLUS_Y]] * 100)); + encodeA(b_min, 24 + head_offset, (int)(current_min[map[PLUS_Z]] * 100)); + encodeB(b_min, 25 + head_offset, (int)(current_min[map[MINUS_X]] * 100)); + encodeA(b_min, 27 + head_offset, (int)(current_min[map[MINUS_Y]] * 100)); + encodeB(b_min, 28 + head_offset, (int)(current_min[map[MINUS_Z]] * 100)); + + 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); + encodeA(b, 30 + head_offset, PSUVoltage); // encodeB(b, 31 + head_offset,(spin * 10) + 2048); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); From dda78ebc6f96ff19fab3cfd363c908e5342309ca Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 07:29:47 -0400 Subject: [PATCH 171/210] missing { --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 3317981b..9f250394 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1533,7 +1533,7 @@ void get_tlm_fox() { 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); - + } encodeA(b, 30 + head_offset, PSUVoltage); // encodeB(b, 31 + head_offset,(spin * 10) + 2048); encodeB(b, 31 + head_offset, ((int)(other[SPIN] * 10)) + 2048); From c514885daed0a3875adbb40b95de87d2f6f11aba Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 07:39:38 -0400 Subject: [PATCH 172/210] fixed current conversions --- afsk/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 9f250394..cce098f1 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1503,12 +1503,12 @@ void get_tlm_fox() { 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]] * 100)); - encodeB(b_max, 22 + head_offset, (int)(current_max[map[PLUS_Y]] * 100)); - encodeA(b_max, 24 + head_offset, (int)(current_max[map[PLUS_Z]] * 100)); - encodeB(b_max, 25 + head_offset, (int)(current_max[map[MINUS_X]] * 100)); - encodeA(b_max, 27 + head_offset, (int)(current_max[map[MINUS_Y]] * 100)); - encodeB(b_max, 28 + head_offset, (int)(current_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)); @@ -1522,12 +1522,12 @@ void get_tlm_fox() { 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]] * 100)); - encodeB(b_min, 22 + head_offset, (int)(current_min[map[PLUS_Y]] * 100)); - encodeA(b_min, 24 + head_offset, (int)(current_min[map[PLUS_Z]] * 100)); - encodeB(b_min, 25 + head_offset, (int)(current_min[map[MINUS_X]] * 100)); - encodeA(b_min, 27 + head_offset, (int)(current_min[map[MINUS_Y]] * 100)); - encodeB(b_min, 28 + head_offset, (int)(current_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)); From 0813b39364c9e18a168b4fafde903a57881285b4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 07:51:11 -0400 Subject: [PATCH 173/210] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index cce098f1..9f065bc9 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1584,8 +1584,8 @@ void get_tlm_fox() { } if (mode == BPSK) { // WOD field experiments - encodeA(b, 63 + head_offset, 0xff); - encodeB(b, 74 + head_offset, 0xff); + encodeA(b, 64 + head_offset, 0xff); // was 63 + encodeB(b, 74 + head_offset, 0xa5; // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; From 6c3421e573ac2ba6d7ae9c4dbd0912b14593f0bf Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 07:52:16 -0400 Subject: [PATCH 174/210] missing ) typo --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 9f065bc9..ec4ae7fd 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1585,7 +1585,7 @@ void get_tlm_fox() { if (mode == BPSK) { // WOD field experiments encodeA(b, 64 + head_offset, 0xff); // was 63 - encodeB(b, 74 + head_offset, 0xa5; // was ff + encodeB(b, 74 + head_offset, 0xa5); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; From ccc5955c2fb372599916fdabfe64237fd17bf63c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 08:03:47 -0400 Subject: [PATCH 175/210] wow test --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ec4ae7fd..6f20083b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1348,7 +1348,7 @@ void get_tlm_fox() { if (current[count1] > current_max[count1]) current_max[count1] = current[count1]; - // printf("Vmin %f Vmax %f Imin %f Imax %f \n", voltage_min[count1], voltage_max[count1], current_min[count1], current_max[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]) @@ -1584,7 +1584,7 @@ void get_tlm_fox() { } if (mode == BPSK) { // WOD field experiments - encodeA(b, 64 + head_offset, 0xff); // was 63 + encodeA(b, 64 + head_offset, 0x7f); // was ff -> 1fe was 63 encodeB(b, 74 + head_offset, 0xa5); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; From c33b24b1cece5168630ea59bcce591f5c2347344 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 08:15:21 -0400 Subject: [PATCH 176/210] switching max and min --- afsk/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 6f20083b..9e2131f7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1583,8 +1583,9 @@ void get_tlm_fox() { printf("TX Antenna Deployed!\n"); } - if (mode == BPSK) { // WOD field experiments - encodeA(b, 64 + head_offset, 0x7f); // was ff -> 1fe was 63 + if (mode == BPSK) { // wod field experiments + encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 + encodeA(b, 65 + head_offset, 0xff); encodeB(b, 74 + head_offset, 0xa5); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; @@ -1608,12 +1609,12 @@ void get_tlm_fox() { rs_frame[j][i] = b[ctr3 % dataLen]; update_rs(parities[j], b[ctr3 % dataLen]); } else // BPSK - if ((int)(ctr3/dataLen) == 3) + if ((int)(ctr3/dataLen) == 4) // was 3 { rs_frame[j][i] = b_max[ctr3 % dataLen]; update_rs(parities[j], b_max[ctr3 % dataLen]); } - else if ((int)(ctr3/dataLen) == 4) + else if ((int)(ctr3/dataLen) == 3) // was 4 { rs_frame[j][i] = b_min[ctr3 % dataLen]; update_rs(parities[j], b_min[ctr3 % dataLen]); From 6c37aadf01b8d4dda2e96c91eba1f707f3aa3b74 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 08:29:58 -0400 Subject: [PATCH 177/210] added rest of sensors --- afsk/main.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 9e2131f7..3fb52c98 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1515,6 +1515,16 @@ void get_tlm_fox() { 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, 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_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)); @@ -1533,6 +1543,17 @@ void get_tlm_fox() { 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, 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, 30 + head_offset, PSUVoltage); // encodeB(b, 31 + head_offset,(spin * 10) + 2048); @@ -1585,7 +1606,7 @@ void get_tlm_fox() { if (mode == BPSK) { // wod field experiments encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 - encodeA(b, 65 + head_offset, 0xff); + encodeA(b, 63 + head_offset, 0xff); // ,65 ff -> fefe encodeB(b, 74 + head_offset, 0xa5); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; From 4fc4ff76a91bd4d025cb5fc344b9bda24f805db6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 08:38:49 -0400 Subject: [PATCH 178/210] put MAX and MIN back --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 3fb52c98..5ee8104b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1606,7 +1606,7 @@ void get_tlm_fox() { if (mode == BPSK) { // wod field experiments encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 - encodeA(b, 63 + head_offset, 0xff); // ,65 ff -> fefe + encodeA(b, 63 + head_offset, 0x1e); // ,65 ff -> fefe, ff -> e1, encodeB(b, 74 + head_offset, 0xa5); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; @@ -1630,12 +1630,12 @@ void get_tlm_fox() { rs_frame[j][i] = b[ctr3 % dataLen]; update_rs(parities[j], b[ctr3 % dataLen]); } else // BPSK - if ((int)(ctr3/dataLen) == 4) // was 3 + 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) == 3) // was 4 + else if ((int)(ctr3/dataLen) == 4) { rs_frame[j][i] = b_min[ctr3 % dataLen]; update_rs(parities[j], b_min[ctr3 % dataLen]); From 7488627d62b702791c8f62b07982d564d4b7a81a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 08:58:59 -0400 Subject: [PATCH 179/210] more word --- afsk/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 5ee8104b..a97b75fd 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,9 +1605,10 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 - encodeA(b, 63 + head_offset, 0x1e); // ,65 ff -> fefe, ff -> e1, - encodeB(b, 74 + head_offset, 0xa5); // was ff +// encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 +// encodeA(b, 63 + head_offset, 0x1e); // 1e -> 224,65 ff -> fefe, ff -> e1, + encodeA(b, 65 + head_offset, 0x80); // 0x80 is 1000 0000 at 65 + encodeB(b, 74 + head_offset, 0x5a); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; From 4fc216bc81f796e0b2f4a8a487d542cad05ff839 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 09:06:03 -0400 Subject: [PATCH 180/210] more wod --- afsk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index a97b75fd..1b3c8c4f 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,10 +1605,10 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments -// encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 + encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0x1e); // 1e -> 224,65 ff -> fefe, ff -> e1, - encodeA(b, 65 + head_offset, 0x80); // 0x80 is 1000 0000 at 65 - encodeB(b, 74 + head_offset, 0x5a); // was ff + encodeA(b, 65 + head_offset, 0xff); // 0x80 is 1000 0000 at 65 + encodeB(b, 74 + head_offset, 0xa5); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; From 0c6083f0d613a279c1aa17209da9e60f78c4a41b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 09:14:18 -0400 Subject: [PATCH 181/210] more word --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 1b3c8c4f..8f01ada4 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1607,8 +1607,8 @@ void get_tlm_fox() { if (mode == BPSK) { // wod field experiments encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0x1e); // 1e -> 224,65 ff -> fefe, ff -> e1, - encodeA(b, 65 + head_offset, 0xff); // 0x80 is 1000 0000 at 65 - encodeB(b, 74 + head_offset, 0xa5); // was ff + encodeA(b, 63 + head_offset, 0xff); // 0x80 is 1000 0000 at 65 + encodeB(b, 74 + head_offset, 0xfff); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)]; From 343592d81ccd46fa7ffe1a42feca5107592a2b88 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 09:24:16 -0400 Subject: [PATCH 182/210] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 8f01ada4..86bd6485 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,9 +1605,9 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - encodeA(b, 64 + head_offset, 0x7f); // was 7f -> fe, ff -> 1fe was 63 + encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0x1e); // 1e -> 224,65 ff -> fefe, ff -> e1, - encodeA(b, 63 + head_offset, 0xff); // 0x80 is 1000 0000 at 65 + encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 encodeB(b, 74 + head_offset, 0xfff); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; From 3f009f49aa104a23d4ea74ee172b76d94683c127 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 09:30:45 -0400 Subject: [PATCH 183/210] more word --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index 86bd6485..edbe9397 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1608,6 +1608,7 @@ void get_tlm_fox() { encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0x1e); // 1e -> 224,65 ff -> fefe, ff -> e1, encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 + encodeA(b, 65 + head_offset, 0xfff); encodeB(b, 74 + head_offset, 0xfff); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; From e56efcf66295e3e490a9287143ae22afe6546e49 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 09:37:43 -0400 Subject: [PATCH 184/210] wow test --- afsk/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index edbe9397..9cbabf62 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,10 +1605,13 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 -// encodeA(b, 63 + head_offset, 0x1e); // 1e -> 224,65 ff -> fefe, ff -> e1, - encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 - encodeA(b, 65 + head_offset, 0xfff); + long val = 31234; + encodeA(b, 63 + head_offset, 0xff & val); + encodeA(b, 64 + head_offset, (0xff00 & val) >> 8); + encodeA(b, 65 + head_offset, (0xff0000 & val) >> 16); +// encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 +// encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 +// encodeA(b, 65 + head_offset, 0xfff); encodeB(b, 74 + head_offset, 0xfff); // was ff } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; From ed73add48d0a93d0b394b993fa2e86c483d9bd8e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 10:32:48 -0400 Subject: [PATCH 185/210] changed to unsigned int --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 9cbabf62..496ff7bb 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,7 +1605,7 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - long val = 31234; + unsigned long val = 31234; encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, (0xff00 & val) >> 8); encodeA(b, 65 + head_offset, (0xff0000 & val) >> 16); From 6d0e3db664048195de79236eb7cc0f81968c469b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 10:40:14 -0400 Subject: [PATCH 186/210] WOD printf --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 496ff7bb..d32f32f3 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,7 +1605,8 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 31234; + unsigned long val = 0xffffff; + printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, (0xff00 & val) >> 8); encodeA(b, 65 + head_offset, (0xff0000 & val) >> 16); From b93996587c0c142d1854fd3cc9e925887c5863a2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 10:46:58 -0400 Subject: [PATCH 187/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index d32f32f3..fd640934 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,7 +1605,7 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 0xffffff; + unsigned long val = 0xffff00; printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, (0xff00 & val) >> 8); From cbbca89a3f14385dc17e6a9804cddb1c3a3799a2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 10:49:36 -0400 Subject: [PATCH 188/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index fd640934..ca28ad94 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,7 +1605,7 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 0xffff00; + unsigned long val = 0x7ffff70; printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, (0xff00 & val) >> 8); From 5773a859757025fe489af05ee021b9482567755e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 10:53:08 -0400 Subject: [PATCH 189/210] Update main.c --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ca28ad94..cc647f99 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,11 +1605,11 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 0x7ffff70; + unsigned long val = 0x7ffff; printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); - encodeA(b, 63 + head_offset, 0xff & val); - encodeA(b, 64 + head_offset, (0xff00 & val) >> 8); - encodeA(b, 65 + head_offset, (0xff0000 & val) >> 16); +// encodeA(b, 63 + head_offset, 0xff & val); + encodeA(b, 64 + head_offset, 0xff & val); + encodeA(b, 65 + head_offset, val >> 8); // encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 // encodeA(b, 65 + head_offset, 0xfff); From 0c9c57b37a5fcf723ac8d580568cc044b282c42a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 10:55:18 -0400 Subject: [PATCH 190/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index cc647f99..87e03f04 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,7 +1605,7 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 0x7ffff; + unsigned long val = 0x17fffe; printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); // encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, 0xff & val); From 3dab69630241ac192993af615215c38e1a63f33e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 10:57:41 -0400 Subject: [PATCH 191/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 87e03f04..f960c723 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,7 +1605,7 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 0x17fffe; + unsigned long val = 0x7fff; printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); // encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, 0xff & val); From b8a65f40380a6149aa3bf9c164b2e253def1290f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 11:00:49 -0400 Subject: [PATCH 192/210] Update main.c --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index f960c723..83546b97 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1610,7 +1610,8 @@ void get_tlm_fox() { // encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, 0xff & val); encodeA(b, 65 + head_offset, val >> 8); -// encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 + encodeA(b, 66 + head_offset, 1); + // encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 // encodeA(b, 65 + head_offset, 0xfff); encodeB(b, 74 + head_offset, 0xfff); // was ff From b59c8ec0b9ef66a6488e97170025fac34cf09bae Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 11:04:11 -0400 Subject: [PATCH 193/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 83546b97..d8f74205 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1610,7 +1610,7 @@ void get_tlm_fox() { // encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, 0xff & val); encodeA(b, 65 + head_offset, val >> 8); - encodeA(b, 66 + head_offset, 1); + encodeA(b, 63 + head_offset, 0xff); // encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 // encodeA(b, 65 + head_offset, 0xfff); From fcd4457cd6ce2e55f5959e6799c318d5de20241f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 11:08:22 -0400 Subject: [PATCH 194/210] Update main.c --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index d8f74205..27d08b6b 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1605,12 +1605,12 @@ void get_tlm_fox() { } if (mode == BPSK) { // wod field experiments - unsigned long val = 0x7fff; + unsigned long val = 0xffff; printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); // encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, 0xff & val); encodeA(b, 65 + head_offset, val >> 8); - encodeA(b, 63 + head_offset, 0xff); + encodeA(b, 63 + head_offset, 0x01); // encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 // encodeA(b, 65 + head_offset, 0xfff); From 06600cfea5de0a339d7770abbfd1d5a957114c8b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 11:11:24 -0400 Subject: [PATCH 195/210] Update main.c --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 27d08b6b..dc2aa32c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1610,7 +1610,7 @@ void get_tlm_fox() { // encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, 0xff & val); encodeA(b, 65 + head_offset, val >> 8); - encodeA(b, 63 + head_offset, 0x01); + encodeA(b, 63 + head_offset, 0x80); // encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 // encodeA(b, 65 + head_offset, 0xfff); From 4c3a0cc27c431f339d2c3932adbc64b34bcc3684 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 11:14:44 -0400 Subject: [PATCH 196/210] Update main.c --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index dc2aa32c..667f0e86 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1610,7 +1610,8 @@ void get_tlm_fox() { // encodeA(b, 63 + head_offset, 0xff & val); encodeA(b, 64 + head_offset, 0xff & val); encodeA(b, 65 + head_offset, val >> 8); - encodeA(b, 63 + head_offset, 0x80); + encodeA(b, 63 + head_offset, 0x00); + encodeA(b, 62 + head_offset, 0x01); // encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 // encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 // encodeA(b, 65 + head_offset, 0xfff); From 357e73c440cc35005986296230cb561d550f16a8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 12:39:19 -0400 Subject: [PATCH 197/210] added time.sleep(0.001) after each config --- python/voltcurrent.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index d6fca650..9994ec80 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -71,8 +71,11 @@ if __name__ == "__main__": 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.001) one = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -80,8 +83,11 @@ if __name__ == "__main__": 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.001) two = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -90,8 +96,11 @@ if __name__ == "__main__": 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.001) three = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -100,8 +109,11 @@ if __name__ == "__main__": 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.001) four = 1 except: four = 0 @@ -116,8 +128,11 @@ if __name__ == "__main__": 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.001) five = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -125,8 +140,11 @@ if __name__ == "__main__": 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.001) six = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -134,8 +152,11 @@ if __name__ == "__main__": 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.001) seven = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -143,8 +164,11 @@ if __name__ == "__main__": 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.001) eight = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) From 9e890c1082e427bfc14ad2a2b0625a48f9214aa9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 12:42:13 -0400 Subject: [PATCH 198/210] increased sleep between configs --- python/voltcurrent.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 9994ec80..d8b1a492 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -75,7 +75,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) one = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -87,7 +87,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) two = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -100,7 +100,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) three = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -113,7 +113,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) four = 1 except: four = 0 @@ -132,7 +132,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) five = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -144,7 +144,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) six = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -156,7 +156,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) seven = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) @@ -168,7 +168,7 @@ if __name__ == "__main__": 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.001) + time.sleep(0.01) eight = 1 except: # print("Python Error 3", file=sys.stderr, flush=True) From c5d551b582a73d08d2a0ca915f7a1fb8bcc1db89 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 12:56:53 -0400 Subject: [PATCH 199/210] added delay between prints of 0.01 --- python/voltcurrent.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index d8b1a492..a509ed6b 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -178,37 +178,45 @@ if __name__ == "__main__": while (True): try: + time.sleep(0.01) print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '') except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + try: + time.sleep(0.01) print("{:6.3f} ".format(ina219_two.bus_voltage), "{:6.3f} ".format(ina219_two.current) , end = '') except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + try: + time.sleep(0.01) print("{:6.3f} ".format(ina219_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + try: + time.sleep(0.01) print("{:6.3f} ".format(ina219_four.bus_voltage), "{:6.3f} ".format(ina219_four.current) , end = '') except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + 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), end = '') - try: + try: + time.sleep(0.01) print("{:6.3f} ".format(ina219_six.bus_voltage), "{:6.3f} ".format(ina219_six.current) , end = '') except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: + try: + time.sleep(0.01) print("{:6.3f} ".format(ina219_seven.bus_voltage), "{:6.3f} ".format(ina219_seven.current) , end = '') except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - try: - print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current) , end = '') + try: + time.sleep(0.01) + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current)) except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') - print(" ") + print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) +# print(" ") inp = input() # print(inp) From d543c1dc150ca06505970b1711bcac7c7876dd4b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 15:01:21 -0400 Subject: [PATCH 200/210] added last few sensors max min --- afsk/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 667f0e86..db3f6b24 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1525,6 +1525,12 @@ void get_tlm_fox() { 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); + encodeB(b_max, 31 + head_offset, ((int)(other_max[SPIN] * 10)) + 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)); + 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); + 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)); @@ -1554,6 +1560,12 @@ void get_tlm_fox() { 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); + encodeB(b_m, 31 + head_offset, ((int)(other_m[SPIN] * 10)) + 2048); + encodeB(b_m, 37 + head_offset, (int)(other_m[RSSI] + 0.5) + 2048); + encodeA(b_m, 39 + head_offset, (int)(other_m[IHU_TEMP] * 10 + 0.5)); + encodeA(b_m, 48 + head_offset, (int)(sensor_m[XS2]) + 2048); + encodeB(b_m, 49 + head_offset, (int)(sensor_m[XS3] * 100 + 0.5) + 2048); + } encodeA(b, 30 + head_offset, PSUVoltage); // encodeB(b, 31 + head_offset,(spin * 10) + 2048); From 8ebf3b830b51e28e72c9b8b17d586c0e12be5c42 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 15:03:17 -0400 Subject: [PATCH 201/210] rest of sensors max min --- afsk/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index db3f6b24..7e0c27c3 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1348,7 +1348,7 @@ void get_tlm_fox() { 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]); +// 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]) @@ -1560,11 +1560,11 @@ void get_tlm_fox() { 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); - encodeB(b_m, 31 + head_offset, ((int)(other_m[SPIN] * 10)) + 2048); - encodeB(b_m, 37 + head_offset, (int)(other_m[RSSI] + 0.5) + 2048); - encodeA(b_m, 39 + head_offset, (int)(other_m[IHU_TEMP] * 10 + 0.5)); - encodeA(b_m, 48 + head_offset, (int)(sensor_m[XS2]) + 2048); - encodeB(b_m, 49 + head_offset, (int)(sensor_m[XS3] * 100 + 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)); + 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); } encodeA(b, 30 + head_offset, PSUVoltage); From 445330ea5b09e63f30f96c5e9001feebbaaab4fe Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 15:11:31 -0400 Subject: [PATCH 202/210] added humidity --- afsk/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 7e0c27c3..15c07f98 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1530,6 +1530,8 @@ void get_tlm_fox() { encodeA(b_max, 39 + head_offset, (int)(other_max[IHU_TEMP] * 10 + 0.5)); 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] + 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)); @@ -1565,7 +1567,8 @@ void get_tlm_fox() { encodeA(b_min, 39 + head_offset, (int)(other_min[IHU_TEMP] * 10 + 0.5)); 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] + 0.5)); } encodeA(b, 30 + head_offset, PSUVoltage); // encodeB(b, 31 + head_offset,(spin * 10) + 2048); From c93b7006e0125264cd208cf89c869b68f92629a4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 17:21:37 -0400 Subject: [PATCH 203/210] added error recovery during print --- python/voltcurrent.py | 138 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 128 insertions(+), 10 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index a509ed6b..3f52052d 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -177,46 +177,164 @@ if __name__ == "__main__": 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: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + 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) + 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: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + 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) + 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_three.bus_voltage), "{:6.3f} ".format(ina219_three.current) , end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + 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) + 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: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + 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) + 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), end = '') + + 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) + 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: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + 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) + 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: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + + 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) + 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)) + print("{:6.3f} ".format(ina219_eight.bus_voltage), "{:6.3f} ".format(ina219_eight.current), end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0)) -# print(" ") + + 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) + 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!") + inp = input() # print(inp) From 2383f6d0aea3c1f27c8846b81de0e36d04007561 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 31 May 2021 17:36:14 -0400 Subject: [PATCH 204/210] added print in recovery --- python/voltcurrent.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 3f52052d..c5d0fce6 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -191,6 +191,7 @@ if __name__ == "__main__": 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: @@ -211,6 +212,7 @@ if __name__ == "__main__": 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: @@ -231,6 +233,7 @@ if __name__ == "__main__": 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: @@ -250,6 +253,7 @@ if __name__ == "__main__": 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: @@ -268,6 +272,7 @@ if __name__ == "__main__": 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: @@ -287,6 +292,7 @@ if __name__ == "__main__": 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: @@ -306,8 +312,9 @@ if __name__ == "__main__": 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 = '') @@ -325,8 +332,9 @@ if __name__ == "__main__": 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 = '') From bb29bdab7f579b34bdf1ce24e6cba88ab1a23352 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 1 Jun 2021 07:38:09 -0400 Subject: [PATCH 205/210] added flush(stderr) --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index 15c07f98..aa11a01c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -573,6 +573,7 @@ int main(int argc, char * argv[]) { loopTime = millis(); while (loop-- != 0) { + fflush(stderr); // frames_sent++; printf("++++ Loop time: %d +++++\n", millis() - loopTime); From 1d275ef56cf1ea9685494801a38218b46ce5fd65 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 1 Jun 2021 07:45:04 -0400 Subject: [PATCH 206/210] added fflush(stdout) --- afsk/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/afsk/main.c b/afsk/main.c index aa11a01c..b319b6b8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -573,6 +573,7 @@ int main(int argc, char * argv[]) { loopTime = millis(); while (loop-- != 0) { + fflush(stdout); fflush(stderr); // frames_sent++; From 0d15eb274b6e26e2d2a57036a010c2a28d98db37 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 1 Jun 2021 13:48:23 -0400 Subject: [PATCH 207/210] removed bogus max min when no payload present --- afsk/main.c | 69 +++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index b319b6b8..cb5546e2 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1517,24 +1517,27 @@ void get_tlm_fox() { 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, 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); - - encodeB(b_max, 31 + head_offset, ((int)(other_max[SPIN] * 10)) + 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)); - 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] + 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] + 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)); @@ -1552,25 +1555,29 @@ void get_tlm_fox() { 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, 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); + 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)); - 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] + 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] + 0.5)); + } } encodeA(b, 30 + head_offset, PSUVoltage); // encodeB(b, 31 + head_offset,(spin * 10) + 2048); @@ -2176,7 +2183,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 From 869e2da2daee4f54448379e6866507e8e8a4851d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 1 Jun 2021 14:03:54 -0400 Subject: [PATCH 208/210] added zero values if no max or min --- afsk/main.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index cb5546e2..bd4cec5a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1537,7 +1537,24 @@ void get_tlm_fox() { 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] + 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)); @@ -1578,6 +1595,23 @@ void get_tlm_fox() { encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] + 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); From 606243e601c5f9e87d176acc1d7b8484db267f26 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 1 Jun 2021 14:07:57 -0400 Subject: [PATCH 209/210] simulated mode if i2c bus 3 not present --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index bd4cec5a..079a7a0a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -439,7 +439,8 @@ int main(int argc, char * argv[]) { 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_bus1 == OFF) && (i2c_bus3 == OFF)) { + if (i2c_bus3 == OFF) { sim_mode = TRUE; From 417360ad838a83d8bb6ba859b79f51d43dfc09e6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 1 Jun 2021 16:05:59 -0400 Subject: [PATCH 210/210] removed some printfs --- afsk/main.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 079a7a0a..18c83de8 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -606,7 +606,7 @@ int main(int argc, char * argv[]) { // 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)) { @@ -742,7 +742,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 } @@ -931,7 +931,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) { @@ -949,7 +949,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 } @@ -1118,8 +1118,6 @@ void get_tlm_fox() { } else printf("first time - no sleep\n"); - - float voltage[9], current[9], sensor[17], other[3]; char sensor_payload[500]; memset(voltage, 0, sizeof(voltage)); @@ -1130,9 +1128,9 @@ void get_tlm_fox() { 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 +// #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 @@ -1665,17 +1663,12 @@ void get_tlm_fox() { if (mode == BPSK) { // wod field experiments unsigned long val = 0xffff; - printf("WOD: %x %x %x \n", 0xff & val, (0xff00 & val) >> 8, (0xff0000 & val) >> 16); -// encodeA(b, 63 + head_offset, 0xff & val); 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); - // encodeA(b, 64 + head_offset, 0xfff); // was 7f -> fe, ff -> 1fe was 63 -// encodeA(b, 63 + head_offset, 0xfff); // 0x80 is 1000 0000 at 65 -// encodeA(b, 65 + head_offset, 0xfff); - encodeB(b, 74 + head_offset, 0xfff); // was ff - } + encodeB(b, 74 + head_offset, 0xfff); + } short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)]; short int data8[headerLen + rsFrames * (rsFrameLen + parityLen)];