From b4b5f02e82d6ea3a05ca52c85bd96a521468aa40 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 29 Oct 2018 08:33:05 -0400 Subject: [PATCH 1/2] Update main.c --- afsk/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index ef5e11f0..8ef900c1 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -202,17 +202,17 @@ int get_tlm(int tlm[][5]) { } // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); - tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5); // Current of 5V supply to Pi - tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10); // +X current [4] - tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10); // +Y current [7] - tlm[1][C] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10); // +Z current [10] (actually -X current, AO-7 didn't have a Z solar panel?) + tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi + tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // +X current [4] + tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // +Y current [7] + tlm[1][C] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] (actually -X current, AO-7 didn't have a Z solar panel?) tlm[2][B] = 99; tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; - tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0); // NiMH Battery current + tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0) % 100; // NiMH Battery current - tlm[3][A] = (int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5); - tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0); // 5V supply to Pi + tlm[3][A] = (int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100; + tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi int tempValue = wiringPiI2CReadReg16(tempSensor, 0); // printf("Read: %x\n", tempValue); @@ -220,7 +220,7 @@ int get_tlm(int tlm[][5]) { uint8_t lower = (uint8_t) (tempValue & 0xff); float temp = (float)lower + ((float)upper / 0x100); - tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5); + tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5) % 100; tlm[6][B] = 0 ; tlm[6][D] = 49 + rand() % 3; From b86d82f8e775e06d09f6dbfb90741cedfce5effd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 29 Oct 2018 08:43:54 -0400 Subject: [PATCH 2/2] Added modulo 100 to fix out of bounds telemetry --- cw/cw_main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cw/cw_main.c b/cw/cw_main.c index 8bb3bb0f..69b9c2af 100644 --- a/cw/cw_main.c +++ b/cw/cw_main.c @@ -454,17 +454,17 @@ int get_tlm(int tlm[][5]) { } // printf("1B: ina219[%d]: %s val: %f \n", SENSOR_40 + CURRENT, ina219[SENSOR_40 + CURRENT], strtof(ina219[SENSOR_40 + CURRENT], NULL)); - tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5); // Current of 5V supply to Pi - tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10); // +X current [4] - tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10); // +Y current [7] - tlm[1][C] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10); // +Z current [10] (actually -X current, AO-7 didn't have a Z solar panel?) + tlm[1][A] = (int)(strtof(ina219[SENSOR_4A + CURRENT], NULL) / 15 + 0.5) % 100; // Current of 5V supply to Pi + tlm[1][B] = (int) (99.5 - strtof(ina219[SENSOR_40 + CURRENT], NULL)/10) % 100; // +X current [4] + tlm[1][D] = (int) (99.5 - strtof(ina219[SENSOR_41 + CURRENT], NULL)/10) % 100; // +Y current [7] + tlm[1][C] = (int) (99.5 - strtof(ina219[SENSOR_44 + CURRENT], NULL)/10) % 100; // +Z current [10] (actually -X current, AO-7 didn't have a Z solar panel?) tlm[2][B] = 99; tlm[2][C] = (int)((time(NULL) - timestamp) / 15) % 100; - tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0); // NiMH Battery current + tlm[2][D] = (int)(50.5 + strtof(ina219[SENSOR_45 + CURRENT], NULL)/10.0) % 100; // NiMH Battery current - tlm[3][A] = (int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5); - tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0); // 5V supply to Pi + tlm[3][A] = (int)((strtof(ina219[SENSOR_45 + VOLTAGE], NULL) * 10) - 65.5) % 100; + tlm[3][B] = (int)(strtof(ina219[SENSOR_4A + VOLTAGE], NULL) * 10.0) % 100; // 5V supply to Pi int tempValue = wiringPiI2CReadReg16(tempSensor, 0); // printf("Read: %x\n", tempValue); @@ -472,7 +472,7 @@ int get_tlm(int tlm[][5]) { uint8_t lower = (uint8_t) (tempValue & 0xff); float temp = (float)lower + ((float)upper / 0x100); - tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5); + tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5) % 100; tlm[6][B] = 0 ; tlm[6][D] = 49 + rand() % 3;