Added modulo 100 to fix out of bounds telemetry

pull/1/head
alanbjohnston 7 years ago committed by GitHub
parent b4b5f02e82
commit b86d82f8e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;

Loading…
Cancel
Save

Powered by TurnKey Linux.