From 853b2bcec98c2640fb7094fc402dc03b374a2ed0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 19 Aug 2020 16:00:14 -0400 Subject: [PATCH] start converting to voltcurrent.py --- afsk/main.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index d5a17302..e74d19b7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -481,6 +481,11 @@ else tempSensor = config_sensor("/dev/i2c-3", 0x48, 0); } + FILE* file = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11 c", "r"); + char cmdbuffer[1000]; + fgets(cmdbuffer, 1000, file); + pclose(file); + // try connecting to Arduino payload using UART if (!ax5043) // don't test if AX5043 is present @@ -1045,7 +1050,31 @@ if (firstTime != ON) sampleTime = millis(); } else printf("first time - no sleep\n"); + +int count; + char *token; +// char cmdbuffer[1000]; + while (1) { + file = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11", "r"); + fgets(cmdbuffer, 1000, file); +// printf("result: %s\n", cmdbuffer); + pclose(file); + + const char space[2] = " "; + token = strtok(cmdbuffer, space); + for (count = 0; count < 8; count++) + { + printf("voltage: %s ", token); + token = strtok(NULL, space); + printf("current: %s\n", token); + token = strtok(NULL, space); + } + + printf("\n"); + } + + int count; for (count = 0; count < 8; count++) {