added get_tlm_fox

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

@ -60,8 +60,8 @@ ax25_conf_t hax25;
static void init_rf();
int twosToInt(int val, int len);
//int get_tlm(int tlm[][5]);
int get_tlm(char *str);
int get_tlm_fox(char *str);
void config_x25();
void trans_x25();
int upper_digit(int number);
@ -186,9 +186,6 @@ int main(int argc, char *argv[]) {
//setSpiSpeed(SPI_SPEED);
//initializeSpi();
// int tlm[7][5];
// memset(tlm, 0, sizeof tlm);
tempSensor = config_sensor("/dev/i2c-3", 0x48, 0);
sensor[PLUS_X] = config_sensor("/dev/i2c-1", 0x40, 400);
@ -229,7 +226,7 @@ int main(int argc, char *argv[]) {
#ifdef DEBUG_LOGGING
fprintf(stderr,"INFO: Preparing X.25 packet\n");
#endif
printf("Tlm: %s \n", str);
printf("%s \n", str);
/*
digitalWrite (0, LOW);
@ -389,6 +386,51 @@ int get_tlm(char *str) {
return 0;
}
int get_tlm_fox(char *str) {
int tlm[7][5];
memset(tlm, 0, sizeof tlm);
// Reading I2C voltage and current sensors
int count;
for (count = 0; count < 8; count++)
{
reading[count] = read_sensor_data(sensor[count]);
#ifdef DEBUG_LOGGING
printf("Read sensor[%d] % 4.2fV % 6.1fmA % 6.1fmW \n",
count, reading[count].voltage, reading[count].current, reading[count].power);
#endif
}
tlm[1][A] = (int)(reading[BUS].voltage /15.0 + 0.5) % 100; // Current of 5V supply to Pi
tlm[1][B] = (int) (99.5 - reading[PLUS_X].current/10.0) % 100; // +X current [4]
tlm[1][C] = (int) (99.5 - reading[MINUS_X].current/10.0) % 100; // X- current [10]
tlm[1][D] = (int) (99.5 - reading[PLUS_Y].current/10.0) % 100; // +Y current [7]
tlm[2][A] = (int) (99.5 - reading[MINUS_Y].current/10.0) % 100; // -Y current [10]
tlm[2][B] = (int) (99.5 - reading[PLUS_Z].current/10.0) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel
tlm[2][C] = (int) (99.5 - reading[MINUS_Z].current/10.0) % 100; // -Z current (was timestamp)
tlm[2][D] = (int)(50.5 + reading[BAT].current/10.0) % 100; // NiMH Battery current
tlm[3][A] = abs((int)((reading[BAT].voltage * 10.0) - 65.5) % 100);
tlm[3][B] = (int)(reading[BUS].voltage * 10.0) % 100; // 5V supply to Pi
if (tempSensor.fd != OFF) {
int tempValue = wiringPiI2CReadReg16(tempSensor.fd, 0);
uint8_t upper = (uint8_t) (tempValue >> 8);
uint8_t lower = (uint8_t) (tempValue & 0xff);
float temp = (float)lower + ((float)upper / 0x100);
#ifdef DEBUG_LOGGING
printf("Temp Sensor Read: %6.1f\n", temp);
#endif
tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5) % 100;
}
return 0;
}
int twosToInt(int val,int len) { // Convert twos compliment to integer
// from https://www.raspberrypi.org/forums/viewtopic.php?t=55815

Loading…
Cancel
Save

Powered by TurnKey Linux.