From 2308e5b6f00289c4046ea6b0d9155006c2d6f3e0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 5 Sep 2020 15:21:37 -0400 Subject: [PATCH 01/34] removed Parities and voltage and current logging --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f3822f6e..e928b86c 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -584,7 +584,7 @@ for (int j = 0; j < frameCnt; j++) { voltage[count1] = atof(token); #ifdef DEBUG_LOGGING - printf("voltage: %f ", voltage[count1]); +// printf("voltage: %f ", voltage[count1]); #endif token = strtok(NULL, space); if (token != NULL) @@ -593,7 +593,7 @@ for (int j = 0; j < frameCnt; j++) if ((current[count1] < 0) && (current[count1] > -0.5)) current[count1] *= (-1.0); #ifdef DEBUG_LOGGING - printf("current: %f\n", current[count1]); +// printf("current: %f\n", current[count1]); #endif token = strtok(NULL, space); } @@ -1164,13 +1164,13 @@ if (payload == ON) #ifdef DEBUG_LOGGING // printf("\nAt end of data8 write, %d ctr1 values written\n\n", ctr1); - +/* printf("Parities "); -// for (int m = 0; m < PARITY_LEN; m++) { for (int m = 0; m < parityLen; m++) { printf("%d ", parities[0][m]); } printf("\n"); +*/ #endif int ctr2 = 0; From 37168ce57993e4ff9fcf27dc02da254eb930f62a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 5 Sep 2020 15:23:51 -0400 Subject: [PATCH 02/34] removed rest of voltage and current logging --- afsk/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index e928b86c..25ab7857 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -575,6 +575,7 @@ for (int j = 0; j < frameCnt; j++) token = strtok(cmdbuffer, space); float voltage[9], current[9]; + memset(voltage, 0, sizeof(voltage)); memset(current, 0, sizeof(current)); @@ -909,7 +910,7 @@ if (firstTime != ON) { voltage[count1] = atof(token); #ifdef DEBUG_LOGGING - printf("voltage: %f ", voltage[count1]); +// printf("voltage: %f ", voltage[count1]); #endif token = strtok(NULL, space); if (token != NULL) @@ -918,7 +919,7 @@ if (firstTime != ON) if ((current[count1] < 0) && (current[count1] > -0.5)) current[count1] *= (-1.0); #ifdef DEBUG_LOGGING - printf("current: %f\n", current[count1]); +// printf("current: %f\n", current[count1]); #endif token = strtok(NULL, space); } From dad41bf31d5bfae62e336fd6f30506c6aca3a141 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 5 Sep 2020 15:42:24 -0400 Subject: [PATCH 03/34] cleanup --- afsk/main.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 25ab7857..f5758fb5 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1129,16 +1129,12 @@ if (payload == ON) int ctr1 = 0; int ctr3 = 0; -// for (i = 0; i < RS_FRAME_LEN; i++) for (i = 0; i < rsFrameLen; i++) { -// for (int j = 0; j < RS_FRAMES ; j++) for (int j = 0; j < rsFrames ; j++) { -// if (!((i == (RS_FRAME_LEN - 1)) && (j == 2))) // skip last one for BPSK if (!((i == (rsFrameLen - 1)) && (j == 2))) // skip last one for BPSK { -// if (ctr1 < HEADER_LEN) if (ctr1 < headerLen) { rs_frame[j][i] = h[ctr1]; @@ -1149,9 +1145,7 @@ if (payload == ON) } else { -// rs_frame[j][i] = b[ctr3 % DATA_LEN]; rs_frame[j][i] = b[ctr3 % dataLen]; -// update_rs(parities[j], b[ctr3 % DATA_LEN]); update_rs(parities[j], b[ctr3 % dataLen]); // printf("%d rs_frame[%d][%d] = %x %d \n", // ctr1, j, i, b[ctr3 % DATA_LEN], ctr3 % DATA_LEN); @@ -1177,8 +1171,6 @@ if (payload == ON) int ctr2 = 0; memset(data10,0,sizeof(data10)); - -// for (i = 0; i < DATA_LEN * PAYLOADS + HEADER_LEN; i++) // 476 for BPSK for (i = 0; i < dataLen * payloads + headerLen; i++) // 476 for BPSK { data10[ctr2] = (Encode_8b10b[rd][((int)data8[ctr2])] & 0x3ff); @@ -1189,10 +1181,8 @@ if (payload == ON) rd = nrd; // ^ nrd; ctr2++; } -// for (i = 0; i < PARITY_LEN; i++) for (i = 0; i < parityLen; i++) { -// for (int j = 0; j < RS_FRAMES; j++) for (int j = 0; j < rsFrames; j++) { data10[ctr2++] = (Encode_8b10b[rd][((int)parities[j][i])] & 0x3ff); @@ -1215,14 +1205,11 @@ if (payload == ON) // printf("\nAt start of buffer loop, syncBits %d samples %d ctr %d\n", syncBits, samples, ctr); #endif -// for (i = 1; i <= SYNC_BITS * SAMPLES; i++) for (i = 1; i <= syncBits * samples; i++) { write_wave(ctr, buffer); // printf("%d ",ctr); -// if ( (i % SAMPLES) == 0) { if ( (i % samples) == 0) { -// int bit = SYNC_BITS - i/SAMPLES + 1; int bit = syncBits - i/samples + 1; val = sync; data = val & 1 << (bit - 1); @@ -1251,14 +1238,10 @@ if (payload == ON) // printf("\n\nValue of ctr after header: %d Buffer Len: %d\n\n", ctr, buffSize); #endif for (i = 1; -// i <= (10 * (HEADER_LEN + DATA_LEN * PAYLOADS + RS_FRAMES * PARITY_LEN) * SAMPLES); i++) // 572 i <= (10 * (headerLen + dataLen * payloads + rsFrames * parityLen) * samples); i++) // 572 { write_wave(ctr, buffer); -// if ( (i % SAMPLES) == 0) { if ( (i % samples) == 0) { -// int symbol = (int)((i - 1)/ (SAMPLES * 10)); -// int bit = 10 - (i - symbol * SAMPLES * 10) / SAMPLES + 1; int symbol = (int)((i - 1)/ (samples * 10)); int bit = 10 - (i - symbol * samples * 10) / samples + 1; val = data10[symbol]; @@ -1342,15 +1325,14 @@ if (payload == ON) // digitalWrite (0, LOW); printf("Sending %d buffer bytes over socket after %d ms!\n", ctr, millis()-start); start = millis(); -// int sock_ret = send(sock, buffer, buffSize, 0); int sock_ret = send(sock, buffer, ctr * 2 + 2, 0); printf("Millis5: %d Result of socket send: %d \n", millis() - start, sock_ret); if (sock_ret < (ctr * 2 + 2)) { - printf("Resending\n"); + 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("Millis10: %d Result of socket send: %d \n", millis() - start, sock_ret); } if (sock_ret == -1) { From 294e708268f79d1ac85936e95d4176dc98a5a77e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 16:15:24 -0400 Subject: [PATCH 04/34] added try test to make sure i2c bus is enabled --- python/voltcurrent.py | 53 +++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 51d4444e..70a19fe7 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -27,37 +27,40 @@ if __name__ == "__main__": addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus # print("buses: ", buses, " addr: ", addresses) for x in buses: - i2c_bus = I2C(x) # Device is /dev/i2c-x - for y in addresses: + 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("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("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 = '') +# 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), end = '') # pass print(" ") From 327b21fee85aa7baa6875244d7a861c494fdc25b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 16:18:51 -0400 Subject: [PATCH 05/34] added four 0 readings for current and voltage for missing bus --- python/voltcurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/voltcurrent.py b/python/voltcurrent.py index 70a19fe7..f34e9e52 100644 --- a/python/voltcurrent.py +++ b/python/voltcurrent.py @@ -61,6 +61,6 @@ if __name__ == "__main__": except: print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') except: - print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '') + 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(" ") From 2e64a1df966f8083f67d40ea9c930bb3e1f19445 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:27:13 -0400 Subject: [PATCH 06/34] added test to bus 11 or 3 to make sure it has pullup resistors --- afsk/telem.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 42ef098a..880a854c 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -71,9 +71,44 @@ int main(int argc, char *argv[]) { printf("vB5 Present\n"); // Don't print normal board detection if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present - printf("/dev/i2c-11 is present\n\n"); + printf("/dev/i2c-11 is present\n\n"); + + char result[128]; + char command[50] = "timeout 10 i2cdetect -y "; + strcat (command, "11"); +// printf("Command: %s \n", command); + FILE *i2cdetect = popen(command, "r"); + + while (fgets(result, 128, i2cdetect) != NULL) { + ; +// printf("result: %s", result); + } + int error = pclose(i2cdetect)/256; +// printf("%s error: %d \n", &command, error); + if (error != 0) + { + printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); +// return (data); + } strcpy(busStr,"1 11"); } else { + char result[128]; + char command[50] = "timeout 10 i2cdetect -y "; + strcat (command, "3"); +// printf("Command: %s \n", command); + FILE *i2cdetect = popen(command, "r"); + + while (fgets(result, 128, i2cdetect) != NULL) { + ; +// printf("result: %s", result); + } + int error = pclose(i2cdetect)/256; +// printf("%s error: %d \n", &command, error); + if (error != 0) + { + printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "3"); +// return (data); + } strcpy(busStr,"1 3"); } } From 70e25e0d02cd48409f1e84beb74160629d71af6d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:29:19 -0400 Subject: [PATCH 07/34] put -1 for bad i2c bus --- afsk/telem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 880a854c..914e7e55 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -107,9 +107,10 @@ int main(int argc, char *argv[]) { if (error != 0) { printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "3"); -// return (data); + strcpy(busStr,"1 -1"); } - strcpy(busStr,"1 3"); + else + strcpy(busStr,"1 3"); } } else From a25d4daf9b508151a923e68e79ada549bf4d6ff5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:38:48 -0400 Subject: [PATCH 08/34] added bus tests 0 --- afsk/telem.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 914e7e55..29e7e2b3 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -47,8 +47,33 @@ int main(int argc, char *argv[]) { map[BAT] = BUS; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - strcpy(busStr,"1 0"); - } + if (access("/dev/i2c-0", W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present + printf("/dev/i2c-0 is present\n\n"); + char result[128]; + char command[50] = "timeout 10 i2cdetect -y "; + strcat (command, "0"); +// printf("Command: %s \n", command); + FILE *i2cdetect = popen(command, "r"); + + while (fgets(result, 128, i2cdetect) != NULL) { + ; +// printf("result: %s", result); + } + int error = pclose(i2cdetect)/256; +// printf("%s error: %d \n", &command, error); + if (error != 0) + { + printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "0"); + strcpy(busStr,"1 -1"); + } + else + strcpy(busStr,"1 0"); + } else + { + printf("ERROR: %s bus has a problem \n Check software to see if enabled \n", "0"); + strcpy(busStr,"1 -1"); + } + } else { pinMode (3, INPUT); @@ -88,9 +113,10 @@ int main(int argc, char *argv[]) { if (error != 0) { printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); -// return (data); + strcpy(busStr,"1 -1"); } - strcpy(busStr,"1 11"); + else + strcpy(busStr,"1 11"); } else { char result[128]; char command[50] = "timeout 10 i2cdetect -y "; @@ -120,9 +146,34 @@ int main(int argc, char *argv[]) { map[BAT] = BUS; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - strcpy(busStr,"1 0"); - } + + if (access("/dev/i2c-0", W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present + printf("/dev/i2c-0 is present\n\n"); + char result[128]; + char command[50] = "timeout 10 i2cdetect -y "; + strcat (command, "0"); +// printf("Command: %s \n", command); + FILE *i2cdetect = popen(command, "r"); + + while (fgets(result, 128, i2cdetect) != NULL) { + ; +// printf("result: %s", result); + } + int error = pclose(i2cdetect)/256; +// printf("%s error: %d \n", &command, error); + if (error != 0) + { + printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "0"); + strcpy(busStr,"1 -1"); + } + else + strcpy(busStr,"1 0"); + } else + { + printf("ERROR: %s bus has a problem \n Check software to see if enabled \n", "0"); + strcpy(busStr,"1 -1"); } + } } // Reading I2C voltage and current sensors From 41d274bc52be03ff7b5505226c4a30ebfeaed578 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:39:31 -0400 Subject: [PATCH 09/34] typo --- afsk/telem.c | 1 - 1 file changed, 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 29e7e2b3..855b83d1 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -173,7 +173,6 @@ int main(int argc, char *argv[]) { printf("ERROR: %s bus has a problem \n Check software to see if enabled \n", "0"); strcpy(busStr,"1 -1"); } - } } // Reading I2C voltage and current sensors From bb3924055e0222f511999ed007f6a82ec42f6511 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:41:33 -0400 Subject: [PATCH 10/34] typo --- afsk/telem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/afsk/telem.c b/afsk/telem.c index 855b83d1..97d6294c 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -173,6 +173,8 @@ int main(int argc, char *argv[]) { printf("ERROR: %s bus has a problem \n Check software to see if enabled \n", "0"); strcpy(busStr,"1 -1"); } + } + } } // Reading I2C voltage and current sensors From 4c0a2118db98b0c82fbb8f63a8941b1f6dd2e78f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:54:02 -0400 Subject: [PATCH 11/34] added test_i2c_bus function --- afsk/telem.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 97d6294c..f4836c3a 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -23,6 +23,7 @@ #define OFF -1 #define ON 1 +int test_i2c_bus(char *bus); const char pythonCmd[] = "python3 /home/pi/CubeSatSim/python/voltcurrent.py "; char pythonStr[100], pythonConfigStr[100], busStr[10]; int map[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; @@ -95,6 +96,8 @@ int main(int argc, char *argv[]) { { printf("vB5 Present\n"); // Don't print normal board detection + print("Result: %d \n",test_i2c_bus(3)); + if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present printf("/dev/i2c-11 is present\n\n"); @@ -173,8 +176,8 @@ int main(int argc, char *argv[]) { printf("ERROR: %s bus has a problem \n Check software to see if enabled \n", "0"); strcpy(busStr,"1 -1"); } - } } + } } // Reading I2C voltage and current sensors @@ -240,3 +243,36 @@ int main(int argc, char *argv[]) { return 0; } + +int test_i2c_bus(char *bus) +{ + int result = 1; + char *busString = "/dev/i2c-3"; + + if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present +// printf("bus is present\n\n"); + char result[128]; + char command[50] = "timeout 10 i2cdetect -y "; + strcat (command, itoa(bus)); +// printf("Command: %s \n", command); + FILE *i2cdetect = popen(command, "r"); + + while (fgets(result, 128, i2cdetect) != NULL) { + ; +// printf("result: %s", result); + } + int error = pclose(i2cdetect)/256; +// printf("%s error: %d \n", &command, error); + if (error != 0) + { + printf("ERROR: %d bus has a problem \n Check I2C wiring and pullup resistors \n", bus); + result = -1; + } + } else + { + printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); + result = -1 + } + } + return(result); +} From a2f01d7c61631be9db4bcc22ea6e814a6b558265 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:54:52 -0400 Subject: [PATCH 12/34] typo --- afsk/telem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index f4836c3a..28027200 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -271,8 +271,8 @@ int test_i2c_bus(char *bus) } else { printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); - result = -1 + result = -1; } - } + } return(result); } From 6259ff62f02804ebea8416dc85165e95131a84de Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:56:48 -0400 Subject: [PATCH 13/34] typo --- afsk/telem.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 28027200..c11c5135 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -249,7 +249,7 @@ int test_i2c_bus(char *bus) int result = 1; char *busString = "/dev/i2c-3"; - if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present + if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present // printf("bus is present\n\n"); char result[128]; char command[50] = "timeout 10 i2cdetect -y "; @@ -268,11 +268,10 @@ int test_i2c_bus(char *bus) printf("ERROR: %d bus has a problem \n Check I2C wiring and pullup resistors \n", bus); result = -1; } - } else - { + } else + { printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); result = -1; - } - } - return(result); + } + return(result); } From 235231c744ae9b6c77c2df35730bd00a105d1ea6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:58:01 -0400 Subject: [PATCH 14/34] typo --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index c11c5135..1aee70ec 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -244,7 +244,7 @@ int main(int argc, char *argv[]) { return 0; } -int test_i2c_bus(char *bus) +int test_i2c_bus(int bus) { int result = 1; char *busString = "/dev/i2c-3"; From 9dbf7927dbb26bdca720cb07f8cb1bca3e32a032 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:58:29 -0400 Subject: [PATCH 15/34] Update telem.c --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 1aee70ec..494d89b0 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -23,7 +23,7 @@ #define OFF -1 #define ON 1 -int test_i2c_bus(char *bus); +int test_i2c_bus(int bus); const char pythonCmd[] = "python3 /home/pi/CubeSatSim/python/voltcurrent.py "; char pythonStr[100], pythonConfigStr[100], busStr[10]; int map[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; From 0435bd54ccf1dd658c1a7312e851d79d469f50c9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 17:59:44 -0400 Subject: [PATCH 16/34] Update telem.c --- afsk/telem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 494d89b0..5c73acff 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -246,7 +246,7 @@ int main(int argc, char *argv[]) { int test_i2c_bus(int bus) { - int result = 1; + int output = 1; char *busString = "/dev/i2c-3"; if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present @@ -266,12 +266,12 @@ int test_i2c_bus(int bus) if (error != 0) { printf("ERROR: %d bus has a problem \n Check I2C wiring and pullup resistors \n", bus); - result = -1; + output = -1; } } else { printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); - result = -1; + output = -1; } - return(result); + return(output); } From 1c2aa10540c79dced9d368d80f5303ffefb579b2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:01:22 -0400 Subject: [PATCH 17/34] Update telem.c --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 5c73acff..42b1a81c 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) { { printf("vB5 Present\n"); // Don't print normal board detection - print("Result: %d \n",test_i2c_bus(3)); + printf("Result: %d \n",test_i2c_bus(3)); if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present printf("/dev/i2c-11 is present\n\n"); From c6bc354f65557fb4dd0b536531facd7cd93eb6dd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:04:10 -0400 Subject: [PATCH 18/34] Update telem.c --- afsk/telem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 42b1a81c..3d930be5 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -248,12 +248,15 @@ int test_i2c_bus(int bus) { int output = 1; char *busString = "/dev/i2c-3"; + char *busS[5]; if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present // printf("bus is present\n\n"); char result[128]; char command[50] = "timeout 10 i2cdetect -y "; - strcat (command, itoa(bus)); + sprintf(busS, "%d", bus); + printf("Bus String: %s \n", busS); + strcat (command, busS); // printf("Command: %s \n", command); FILE *i2cdetect = popen(command, "r"); From 83bbc1ec2416924141c116f9b1b930cacf018505 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:08:30 -0400 Subject: [PATCH 19/34] added bus string determination --- afsk/telem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 3d930be5..8ce6ea42 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -247,15 +247,18 @@ int main(int argc, char *argv[]) { int test_i2c_bus(int bus) { int output = 1; - char *busString = "/dev/i2c-3"; + char *busDev = "/dev/i2c-"; + char *busString[25]; char *busS[5]; + sprintf(busS, "%d", bus); + strcat (busString, busDev); + strcat (busString, busS); + printf("Bus Dev String: %s \n", busString); if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present // printf("bus is present\n\n"); char result[128]; char command[50] = "timeout 10 i2cdetect -y "; - sprintf(busS, "%d", bus); - printf("Bus String: %s \n", busS); strcat (command, busS); // printf("Command: %s \n", command); FILE *i2cdetect = popen(command, "r"); From 5d588a171571ff8b6c86082b5995c6bbb5bef8ab Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:10:35 -0400 Subject: [PATCH 20/34] fixed string cat --- afsk/telem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 8ce6ea42..b5d40516 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -258,7 +258,9 @@ int test_i2c_bus(int bus) if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present // printf("bus is present\n\n"); char result[128]; - char command[50] = "timeout 10 i2cdetect -y "; + char command_start = "timeout 10 i2cdetect -y "; + char command[50]; + strcpy (command, command_start); strcat (command, busS); // printf("Command: %s \n", command); FILE *i2cdetect = popen(command, "r"); From 7a72f6edbc82f7367c077c15966c220762983570 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:14:25 -0400 Subject: [PATCH 21/34] Update telem.c --- afsk/telem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index b5d40516..66e7a342 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -247,9 +247,9 @@ int main(int argc, char *argv[]) { int test_i2c_bus(int bus) { int output = 1; - char *busDev = "/dev/i2c-"; - char *busString[25]; - char *busS[5]; + char busDev[] = "/dev/i2c-"; + char busString[25]; + char busS[5]; sprintf(busS, "%d", bus); strcat (busString, busDev); strcat (busString, busS); From 0ba842108b3f1174fed054788280ece53a1b2e8e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:16:35 -0400 Subject: [PATCH 22/34] Update telem.c --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 66e7a342..5d26f694 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) { int test_i2c_bus(int bus) { int output = 1; - char busDev[] = "/dev/i2c-"; + constant char busDev[] = "/dev/i2c-"; char busString[25]; char busS[5]; sprintf(busS, "%d", bus); From 654de9f30af51a2c81d8bc46977198cdbc4aedf4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:17:08 -0400 Subject: [PATCH 23/34] Update telem.c --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 5d26f694..16eb0973 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) { int test_i2c_bus(int bus) { int output = 1; - constant char busDev[] = "/dev/i2c-"; + const char busDev[] = "/dev/i2c-"; char busString[25]; char busS[5]; sprintf(busS, "%d", bus); From ffa70811ce981e3ff8a150bffbbf5b0ac7407a82 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:18:00 -0400 Subject: [PATCH 24/34] Update telem.c --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 16eb0973..5e29cd2f 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -258,7 +258,7 @@ int test_i2c_bus(int bus) if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present // printf("bus is present\n\n"); char result[128]; - char command_start = "timeout 10 i2cdetect -y "; + const char command_start[] = "timeout 10 i2cdetect -y "; char command[50]; strcpy (command, command_start); strcat (command, busS); From 16c705173c72478379197c653958e5878786f740 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 11 Sep 2020 18:19:25 -0400 Subject: [PATCH 25/34] Update telem.c --- afsk/telem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 5e29cd2f..45bfac9b 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -251,8 +251,8 @@ int test_i2c_bus(int bus) char busString[25]; char busS[5]; sprintf(busS, "%d", bus); - strcat (busString, busDev); - strcat (busString, busS); + strcat (busString, &busDev); + strcat (busString, &busS); printf("Bus Dev String: %s \n", busString); if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present From 3cba4929b01e261e5eaa3d0e79aef8e159e57c93 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 10:53:27 -0400 Subject: [PATCH 26/34] fixing string errors --- afsk/telem.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 45bfac9b..fe687d07 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -247,15 +247,14 @@ int main(int argc, char *argv[]) { int test_i2c_bus(int bus) { int output = 1; - const char busDev[] = "/dev/i2c-"; + char busDev[20] = "/dev/i2c-"; char busString[25]; - char busS[5]; - sprintf(busS, "%d", bus); - strcat (busString, &busDev); - strcat (busString, &busS); - printf("Bus Dev String: %s \n", busString); + char *busS; + snprintf(busS, 5, "%d", bus); + strcat (busDev, busS); + printf("Bus Dev String: %s \n", busDev); - if (access(busString, W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present + if (access(busDev, W_OK | R_OK) >= 0) { // Test if I2C Bus is present // printf("bus is present\n\n"); char result[128]; const char command_start[] = "timeout 10 i2cdetect -y "; From d84d1de3d1c44e7197dc226daa1f0767af31b7bc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 10:55:13 -0400 Subject: [PATCH 27/34] Update telem.c --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index fe687d07..aa49cd1d 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -249,7 +249,7 @@ int test_i2c_bus(int bus) int output = 1; char busDev[20] = "/dev/i2c-"; char busString[25]; - char *busS; + char busS[5]; snprintf(busS, 5, "%d", bus); strcat (busDev, busS); printf("Bus Dev String: %s \n", busDev); From 8795900a03efcdadf9a81e28b2d2473b2aae80e2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 11:12:49 -0400 Subject: [PATCH 28/34] added test for bus 3 and 11 --- afsk/telem.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index aa49cd1d..21912a9e 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -95,12 +95,15 @@ int main(int argc, char *argv[]) { if (digitalRead(26) != HIGH) { printf("vB5 Present\n"); // Don't print normal board detection - - printf("Result: %d \n",test_i2c_bus(3)); + if (test_i2c_bus(0) != OFF) + strcpy(busStr,"1 "); + else + strcpy(busStr,"-1 "); +// printf("Result: %d \n",test_i2c_bus(3)); if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present printf("/dev/i2c-11 is present\n\n"); - +/* char result[128]; char command[50] = "timeout 10 i2cdetect -y "; strcat (command, "11"); @@ -114,14 +117,18 @@ int main(int argc, char *argv[]) { int error = pclose(i2cdetect)/256; // printf("%s error: %d \n", &command, error); if (error != 0) +*/ + if (test_i2c_bus(11) != OFF) { - printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); - strcpy(busStr,"1 -1"); +// printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); + strcat(busStr,"-1"); } else - strcpy(busStr,"1 11"); + strcat(busStr,"11"); + printf("Bus String: %s \n", busStr); + } else { - char result[128]; +/* char result[128]; char command[50] = "timeout 10 i2cdetect -y "; strcat (command, "3"); // printf("Command: %s \n", command); @@ -140,7 +147,16 @@ int main(int argc, char *argv[]) { } else strcpy(busStr,"1 3"); - } + */ + if (test_i2c_bus(3) != OFF) + { +// printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); + strcat(busStr,"-1"); + } + else + strcat(busStr,"3"); + printf("Bus String: %s \n", busStr); + } } else { @@ -248,7 +264,6 @@ int test_i2c_bus(int bus) { int output = 1; char busDev[20] = "/dev/i2c-"; - char busString[25]; char busS[5]; snprintf(busS, 5, "%d", bus); strcat (busDev, busS); From 5d6275af102a2d649714b2aad75026839fedcb16 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 11:20:46 -0400 Subject: [PATCH 29/34] use snprintf --- afsk/telem.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/afsk/telem.c b/afsk/telem.c index 21912a9e..d4a2d0aa 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -95,6 +95,11 @@ int main(int argc, char *argv[]) { if (digitalRead(26) != HIGH) { printf("vB5 Present\n"); // Don't print normal board detection + + snprintf(busStr, 10, "%d %d", test_i2c_bus(0), test_i2c_bus(3)); + + printf("New Bus String: %s \n", busStr); +/* if (test_i2c_bus(0) != OFF) strcpy(busStr,"1 "); else @@ -117,7 +122,7 @@ int main(int argc, char *argv[]) { int error = pclose(i2cdetect)/256; // printf("%s error: %d \n", &command, error); if (error != 0) -*/ +* if (test_i2c_bus(11) != OFF) { // printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); @@ -125,7 +130,7 @@ int main(int argc, char *argv[]) { } else strcat(busStr,"11"); - printf("Bus String: %s \n", busStr); +* printf("Bus String: %s \n", busStr); } else { /* char result[128]; @@ -157,7 +162,8 @@ int main(int argc, char *argv[]) { strcat(busStr,"3"); printf("Bus String: %s \n", busStr); } - } +*/ + } else { printf("VB3 Present\n"); @@ -262,7 +268,7 @@ int main(int argc, char *argv[]) { int test_i2c_bus(int bus) { - int output = 1; + int output = bus; // return bus number if OK, otherwise return -1 char busDev[20] = "/dev/i2c-"; char busS[5]; snprintf(busS, 5, "%d", bus); @@ -295,5 +301,5 @@ int test_i2c_bus(int bus) printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); output = -1; } - return(output); + return(output); // return bus number or -1 if there is a problem with the bus } From 2b4f9b19f385acc2baba8ab8d2e4734786647176 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 11:21:42 -0400 Subject: [PATCH 30/34] Update telem.c --- afsk/telem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index d4a2d0aa..3ea65147 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) { } else strcpy(busStr,"1 3"); - */ + * if (test_i2c_bus(3) != OFF) { // printf("ERROR: %s bus has a problem \n Check I2C wiring and pullup resistors \n", "11"); From 9d786f3db86148422853ee43e69f1d00b04d50c4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 11:25:13 -0400 Subject: [PATCH 31/34] added rest --- afsk/telem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 3ea65147..81b3f344 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -85,7 +85,12 @@ int main(int argc, char *argv[]) { printf("vB4 Present\n"); map[BAT] = BUS; map[BUS] = BAT; - strcpy(busStr,"1 0"); + + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); + + printf("New Bus String: %s \n", busStr); + + // strcpy(busStr,"1 0"); } else { @@ -172,6 +177,10 @@ int main(int argc, char *argv[]) { map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); + + printf("New Bus String: %s \n", busStr); +/* if (access("/dev/i2c-0", W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present printf("/dev/i2c-0 is present\n\n"); char result[128]; @@ -198,6 +207,7 @@ int main(int argc, char *argv[]) { printf("ERROR: %s bus has a problem \n Check software to see if enabled \n", "0"); strcpy(busStr,"1 -1"); } +*/ } } } From f4e1b433db8e736c5dab5fe11a68ddf7d4574fc0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 16:31:48 -0400 Subject: [PATCH 32/34] Added test_i2c_bus, sets bus to -1 if not present --- afsk/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f5758fb5..9f689d2a 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -119,6 +119,7 @@ int sampleTime = 0, frames_sent = 0; int cw_id = ON; int vB4 = FALSE, vB5 = FALSE, ax5043 = FALSE, transmit = FALSE, onLed, onLedOn, onLedOff, txLed, txLedOn, txLedOff, payload = OFF; float batteryThreshold = 3.0, batteryVoltage; +int test_i2c_bus(int bus); const char pythonCmd[] = "python3 /home/pi/CubeSatSim/python/voltcurrent.py "; char pythonStr[100], pythonConfigStr[100], busStr[10]; @@ -302,15 +303,15 @@ if (vB4) { map[BAT] = BUS; map[BUS] = BAT; - strcpy(busStr,"1 0"); + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); } else if (vB5) { if (access("/dev/i2c-11", W_OK | R_OK) >= 0) { // Test if I2C Bus 11 is present printf("/dev/i2c-11 is present\n\n"); - strcpy(busStr,"1 11"); + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(11)); } else { - strcpy(busStr,"1 3"); + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(3)); } } else @@ -319,7 +320,7 @@ else map[BAT] = BUS; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; - strcpy(busStr,"1 0"); + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); batteryThreshold = 8.0; } @@ -1586,3 +1587,40 @@ int twosToInt(int val,int len) { // Convert twos compliment to integer return(val); } +int test_i2c_bus(int bus) +{ + int output = bus; // return bus number if OK, otherwise return -1 + char busDev[20] = "/dev/i2c-"; + char busS[5]; + snprintf(busS, 5, "%d", bus); + strcat (busDev, busS); + printf("I2C Bus Tested: %s \n", busDev); + + if (access(busDev, W_OK | R_OK) >= 0) { // Test if I2C Bus is present +// printf("bus is present\n\n"); + char result[128]; + const char command_start[] = "timeout 10 i2cdetect -y "; + char command[50]; + strcpy (command, command_start); + strcat (command, busS); +// printf("Command: %s \n", command); + FILE *i2cdetect = popen(command, "r"); + + while (fgets(result, 128, i2cdetect) != NULL) { + ; +// printf("result: %s", result); + } + int error = pclose(i2cdetect)/256; +// printf("%s error: %d \n", &command, error); + if (error != 0) + { + printf("ERROR: %d bus has a problem \n Check I2C wiring and pullup resistors \n", bus); + output = -1; + } + } else + { + printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); + output = -1; + } + return(output); // return bus number or -1 if there is a problem with the bus +} From 313c439cdea556d2fece9253c01cc6ec915bdc91 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 16:36:18 -0400 Subject: [PATCH 33/34] fixed error text --- afsk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 9f689d2a..aa35bc7d 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -1614,12 +1614,12 @@ int test_i2c_bus(int bus) // printf("%s error: %d \n", &command, error); if (error != 0) { - printf("ERROR: %d bus has a problem \n Check I2C wiring and pullup resistors \n", bus); + printf("ERROR: %sd bus has a problem \n Check I2C wiring and pullup resistors \n", busDev); output = -1; } } else { - printf("ERROR: %d bus has a problem \n Check software to see if enabled \n", bus); + printf("ERROR: %s bus has a problem \n Check software to see if I2C enabled \n", busDev); output = -1; } return(output); // return bus number or -1 if there is a problem with the bus From 3531a337188ce958587f3e5f03da3056265b0282 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 12 Sep 2020 17:16:02 -0400 Subject: [PATCH 34/34] added bus test for vB3 --- afsk/telem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/afsk/telem.c b/afsk/telem.c index 81b3f344..231f68a3 100644 --- a/afsk/telem.c +++ b/afsk/telem.c @@ -48,6 +48,10 @@ int main(int argc, char *argv[]) { map[BAT] = BUS; map[PLUS_Z] = BAT; map[MINUS_Z] = PLUS_Z; + + snprintf(busStr, 10, "%d %d", test_i2c_bus(1), test_i2c_bus(0)); + printf("New Bus String: %s \n", busStr); +/* if (access("/dev/i2c-0", W_OK | R_OK) >= 0) { // Test if I2C Bus 0 is present printf("/dev/i2c-0 is present\n\n"); char result[128]; @@ -74,7 +78,8 @@ int main(int argc, char *argv[]) { printf("ERROR: %s bus has a problem \n Check software to see if enabled \n", "0"); strcpy(busStr,"1 -1"); } - } +*/ + } else { pinMode (3, INPUT);