From 37db2a567ddbe71131bc7e4755dadcd1fcac69fc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Oct 2018 14:53:41 -0400 Subject: [PATCH] Update cw_main.c --- cw/cw_main.c | 54 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/cw/cw_main.c b/cw/cw_main.c index 664c4aa1..74aa9ae1 100644 --- a/cw/cw_main.c +++ b/cw/cw_main.c @@ -42,6 +42,10 @@ #define TIME 8 #define UCTEMP 30 #define UPTIME_SEC 8 +#define A 1 +#define B 2 +#define C 3 +#define D 4 long int timestamp = 0; extern uint8_t axradio_rxbuffer[]; @@ -464,33 +468,37 @@ int get_tlm(int tlm[][5]) { if (timestamp == 0) timestamp = time; - int tlm_2c = (int)((time - timestamp) / 15) % 100; - printf("Relative time: %ld seconds 2C: %d 2C: %d%d\n", time - timestamp,tlm_2c, upper_digit(tlm_2c), lower_digit(tlm_2c)); +// int tlm_2c = (int)((time - timestamp) / 15) % 100; + tlm[2][C] = (int)((time - timestamp) / 15) % 100; + +// printf("Relative time: %ld seconds 2C: %d 2C: %d%d\n", time - timestamp,tlm_2c, upper_digit(tlm_2c), lower_digit(tlm_2c)); float vbat; vbat = strtof(mopower[VBATT], NULL); printf(" vbat: %f \n", vbat); - int tlm_3a = (int)((vbat * 10) - 65.5); - int tlm_6b = 0, tlm_2b = 99; - printf("TLM 3A = %d \n", tlm_3a); +// int tlm_3a = (int)((vbat * 10) - 65.5); + tlm[3][A] = (int)((vbat * 10) - 65.5); +// int tlm_6b = 0, tlm_2b = 99; + tlm[6][B] = 0, tlm_2b = 99; +// printf("TLM 3A = %d \n", tlm_3a); // Read current from I2C bus // printf("\n\nI2C result: %d\n", i2cDevice); // printf("Read: %d\n", wiringPiI2CRead(i2cDevice)) ; - int result = wiringPiI2CWriteReg16(xPlusSensor, 0x05, 4096); - printf("Write result: %d\n", result); +// int result = wiringPiI2CWriteReg16(xPlusSensor, 0x05, 4096); +// printf("Write result: %d\n", result); int currentValue = wiringPiI2CReadReg16(xPlusSensor, 0x04); - printf("Current: %d\n\n\n", currentValue); +// printf("Current: %d\n\n\n", currentValue); - int tlm_1b = (int) (98.5 - currentValue/400); - printf("TLM 1B = %d \n\n", tlm_1b); - int tlm_1a = 0, tlm_1c = 98, tlm_1d = 98, tlm_2a = 98; +// int tlm_1b = (int) (98.5 - currentValue/400); + tlm[1][B] = (int) (98.5 - currentValue/400); +// printf("TLM 1B = %d \n\n", tlm_1b); +// int tlm_1a = 0, tlm_1c = 98, tlm_1d = 98, tlm_2a = 98; // Reading 5V voltage and current - file = popen("sudo python /home/pi/CubeSatSim/python/readcurrent.py 2>&1", "r"); fgets(cmdbuffer, 1000, file); pclose(file); @@ -507,12 +515,14 @@ int get_tlm(int tlm[][5]) { i++; } - int tlm_3b = (int)(strtof(battery[0], NULL) * 10.0); - int tlm_2d = (int)(50.0 + strtof(battery[1], NULL)/40.0); - printf(" 2D: %d 3B: %d\n", tlm_2d, tlm_3b); +// int tlm_3b = (int)(strtof(battery[0], NULL) * 10.0); +// int tlm_2d = (int)(50.0 + strtof(battery[1], NULL)/40.0); + tlm[3][B] = (int)(strtof(battery[0], NULL) * 10.0); + tlm[2][D] = (int)(50.0 + strtof(battery[1], NULL)/40.0); +// printf(" 2D: %d 3B: %d\n", tlm_2d, tlm_3b); int tempValue = wiringPiI2CReadReg16(tempSensor, 0); - printf("Read: %x\n", tempValue); +// printf("Read: %x\n", tempValue); uint8_t upper = (uint8_t) (tempValue >> 8); uint8_t lower = (uint8_t) (tempValue & 0xff); @@ -520,11 +530,13 @@ int get_tlm(int tlm[][5]) { float temp = (float)lower + ((float)upper / 0x100); printf("upper: %x lower: %x temp: %f\n", upper, lower, temp); - int tlm_4a = (int)((95.8 - temp)/1.48 + 0.5); - printf(" 4A: %d \n", tlm_4a); - - int tlm_6d = 49 + rand() % 3; +// int tlm_4a = (int)((95.8 - temp)/1.48 + 0.5); + tlm[4][A] = (int)((95.8 - temp)/1.48 + 0.5); +// printf(" 4A: %d \n", tlm_4a); +// int tlm_6d = 49 + rand() % 3; + tlm[6][D] = 49 + rand() % 3; +/* char tlm_str[1000]; printf("%d %d %d %d %d %d %d %d %d %d %d %d %d \n", tlm_1a, tlm_1b, tlm_1c, tlm_1d, tlm_2a, tlm_2b, tlm_2c, tlm_2d, tlm_3a, tlm_3b, tlm_4a, tlm_6b, tlm_6d); @@ -554,6 +566,6 @@ int get_tlm(int tlm[][5]) { upper_digit(tlm_6d), lower_digit(tlm_6d)); printf("%s\n",tlm_str); - +*/ return 0; }