Update main.c read sensors in sim mode

beta-v1.3.1.1-sim
Alan Johnston 2 years ago committed by GitHub
parent 8030080c19
commit 5252970097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -545,7 +545,7 @@ int main(int argc, char * argv[]) {
get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored
firstTime = 1; firstTime = 1;
if (!sim_mode) // if (!sim_mode) // always read sensors, even in sim mode
{ {
strcpy(pythonStr, pythonCmd); strcpy(pythonStr, pythonCmd);
strcat(pythonStr, busStr); strcat(pythonStr, busStr);
@ -604,6 +604,41 @@ int main(int argc, char * argv[]) {
fflush(stdout); fflush(stdout);
loopTime = millis(); loopTime = millis();
{
int count1;
char * token;
fputc('\n', file1);
fgets(cmdbuffer, 1000, file1);
fprintf(stderr, "Python read Result: %s\n", cmdbuffer);
const char space[2] = " ";
token = strtok(cmdbuffer, space);
for (count1 = 0; count1 < 8; count1++) {
if (token != NULL) {
voltage[count1] = (float) atof(token);
#ifdef DEBUG_LOGGING
// printf("voltage: %f ", voltage[count1]);
#endif
token = strtok(NULL, space);
if (token != NULL) {
current[count1] = (float) atof(token);
if ((current[count1] < 0) && (current[count1] > -0.5))
current[count1] *= (-1.0f);
#ifdef DEBUG_LOGGING
// printf("current: %f\n", current[count1]);
#endif
token = strtok(NULL, space);
}
}
if (voltage[map[BAT]] == 0.0)
batteryVoltage = 4.5;
else
batteryVoltage = voltage[map[BAT]];
batteryCurrent = current[map[BAT]];
}
if (sim_mode) { // simulated telemetry if (sim_mode) { // simulated telemetry
double time = ((long int)millis() - time_start) / 1000.0; double time = ((long int)millis() - time_start) / 1000.0;
@ -671,6 +706,9 @@ int main(int argc, char * argv[]) {
// end of simulated telemetry // end of simulated telemetry
} }
else { else {
// code moved
/*
int count1; int count1;
char * token; char * token;
fputc('\n', file1); fputc('\n', file1);
@ -697,10 +735,16 @@ int main(int argc, char * argv[]) {
token = strtok(NULL, space); token = strtok(NULL, space);
} }
} }
} if (voltage[map[BAT]] == 0.0)
batteryVoltage = 4.5;
else
batteryVoltage = voltage[map[BAT]]; batteryVoltage = voltage[map[BAT]];
batteryCurrent = current[map[BAT]]; batteryCurrent = current[map[BAT]];
*/
}
// batteryVoltage = voltage[map[BAT]];
// batteryCurrent = current[map[BAT]];
if (batteryVoltage < 3.7) { if (batteryVoltage < 3.7) {
SafeMode = 1; SafeMode = 1;

Loading…
Cancel
Save

Powered by TurnKey Linux.