Update main.c fix {}

old-payload
Alan Johnston 2 months ago committed by GitHub
parent 6a4de820e9
commit c412eb194b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

124
main.c

@ -2273,91 +2273,53 @@ float toAprsFormat(float input) {
int get_payload_serial(int debug_camera) { int get_payload_serial(int debug_camera) {
#ifdef OLD_STEM_PAYLOAD #ifdef OLD_STEM_PAYLOAD
if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600 if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600
// if (payload == ON) { // -55 STEMBoardFailure = 0;
if (TRUE) { // -55 char c;
STEMBoardFailure = 0; unsigned int waitTime;
int i, end, trys = 0;
buffer2[0] = 0;
char c; buffer2[1] = 0;
unsigned int waitTime; while (((buffer2[0] != 'O') || (buffer2[1] != 'K')) && (trys++ < 10)) {
int i, end, trys = 0; i = 0;
buffer2[0] = 0; serialPutchar(uart_fd, '?');
buffer2[1] = 0; sleep(0.05); // added delay after ?
while (((buffer2[0] != 'O') || (buffer2[1] != 'K')) && (trys++ < 10)) { printf("%d Querying payload with ?\n", trys);
i = 0; waitTime = millis() + 500;
serialPutchar(uart_fd, '?'); end = FALSE;
sleep(0.05); // added delay after ? // int retry = FALSE;
printf("%d Querying payload with ?\n", trys); while ((millis() < waitTime) && !end) {
waitTime = millis() + 500; int chars = (char)serialDataAvail(uart_fd);
end = FALSE; while ((chars > 0) && !end) {
// int retry = FALSE; // printf("Chars: %d\ ", chars);
while ((millis() < waitTime) && !end) { chars--;
int chars = (char) serialDataAvail(uart_fd); c = (char)serialGetchar(uart_fd);
while ((chars > 0) && !end) { // printf ("%c", c);
// printf("Chars: %d\ ", chars); // fflush(stdout);
chars--; if (c != '\n') {
c = (char) serialGetchar(uart_fd); buffer2[i++] = c;
// printf ("%c", c); } else {
// fflush(stdout); end = TRUE;
if (c != '\n') {
buffer2[i++] = c;
} else {
end = TRUE;
}
}
}
buffer2[i++] = ' ';
// buffer2[i++] = '\n';
buffer2[i] = '\0';
printf(" Response from STEM Payload board: %s\n", buffer2);
sleep(0.1); // added sleep between loops
//// } // removed this!
/*
if ((buffer2[0] == 'O') && (buffer2[1] == 'K')) // only process if valid payload response
{
int count1;
char * token;
const char space[2] = " ";
token = strtok(sensor_payload, space);
for (count1 = 0; count1 < 17; count1++) {
if (token != NULL) {
sensor[count1] = (float) atof(token);
#ifdef DEBUG_LOGGING
// printf("sensor: %f ", sensor[count1]);
#endif
token = strtok(NULL, space);
}
}
printf("\n");
} }
else
payload = OFF; // turn off since STEM Payload is not responding
} }
}
if ((buffer2[0] == 'O') && (buffer2[1] == 'K')) {
for (int count1 = 0; count1 < 17; count1++) {
if (sensor[count1] < sensor_min[count1])
sensor_min[count1] = sensor[count1];
if (sensor[count1] > sensor_max[count1])
sensor_max[count1] = sensor[count1];
// printf("Smin %f Smax %f \n", sensor_min[count1], sensor_max[count1]);
}
}
*/
} else
printf("Can't open serial to payload");
if (payload == ON) { buffer2[i++] = ' ';
// printf("\nSTEM Payload is present!\n"); // buffer2[i++] = '\n';
// sleep(2); // delay to give payload time to get ready buffer2[i] = '\0';
return(TRUE); printf(" Response from STEM Payload board: %s\n", buffer2);
sleep(0.1); // added sleep between loops
} }
} else
printf("Can't open serial to payload");
if ((buffer2[0] == 'O') && (buffer2[1] == 'K')) // {
// printf("\nSTEM Payload is present!\n");
// sleep(2); // delay to give payload time to get ready
return (TRUE);
}
#endif #endif
#ifdef OLD_STEM_PAYLOAD2 #ifdef OLD_STEM_PAYLOAD2

Loading…
Cancel
Save

Powered by TurnKey Linux.