Merge pull request #290 from alanbjohnston/beta-v1.3.1.1-sim

Beta v1.3.1.1 sim
beta-v1.3.1.1
Alan Johnston 2 years ago committed by GitHub
commit 8c4880c699
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
firstTime = 1;
if (!sim_mode)
// if (!sim_mode) // always read sensors, even in sim mode
{
strcpy(pythonStr, pythonCmd);
strcat(pythonStr, busStr);
@ -604,6 +604,41 @@ int main(int argc, char * argv[]) {
fflush(stdout);
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
double time = ((long int)millis() - time_start) / 1000.0;
@ -671,6 +706,9 @@ int main(int argc, char * argv[]) {
// end of simulated telemetry
}
else {
// code moved
/*
int count1;
char * token;
fputc('\n', file1);
@ -697,10 +735,16 @@ int main(int argc, char * argv[]) {
token = strtok(NULL, space);
}
}
}
if (voltage[map[BAT]] == 0.0)
batteryVoltage = 4.5;
else
batteryVoltage = voltage[map[BAT]];
batteryCurrent = current[map[BAT]];
*/
}
// batteryVoltage = voltage[map[BAT]];
// batteryCurrent = current[map[BAT]];
if (batteryVoltage < 3.7) {
SafeMode = 1;
@ -877,7 +921,11 @@ int main(int argc, char * argv[]) {
FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w");
if (fp != NULL) {
printf("Writing telem_string.txt\n");
if (batteryVoltage != 4.5)
fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent);
else
fprintf(fp, "\n"); // don't show voltage and current if it isn't a sensor value
fclose(fp);
} else
printf("Error writing to telem_string.txt\n");

Loading…
Cancel
Save

Powered by TurnKey Linux.