Compare commits

...

6 Commits

@ -23,7 +23,11 @@ try:
start = time.perf_counter()
try:
while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2):
# while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2):
while ((time.perf_counter() - start) < 2) and (mode < 2):
if session.waiting(2.0):
session.read()
# print(gps.MODE_SET)
# print(session.valid)
if (session.valid):

@ -763,6 +763,48 @@ int main(int argc, char * argv[]) {
}
}
if (gps_status == TRUE) {
fprintf(stderr, "Checking Pi gps\n");
cmdbuffer[0] = '\0';
gps_read = sopen("python3 /home/pi/CubeSatSim/gps_client.py"); // python sensor polling function
if (gps_read != NULL) {
fgets(cmdbuffer, 1000, gps_read);
const char gpsTestStr[] = "2 32.3 -54 333\n";
strcpy(cmdbuffer, gpsTestStr);
fprintf(stderr, "gps read: %s\n", cmdbuffer);
if ((cmdbuffer[0] == '2') || (cmdbuffer[0] == '3'))
{
printf("Valid gps data!\n");
int count1;
char * token;
const char space[2] = " ";
token = strtok(cmdbuffer, space);
// printf("token: %s\n", token);
for (count1 = GPS; count1 < (GPS + 3); count1++) {
if (token != NULL) {
sensor[count1] = (float) atof(token);
strcpy(sensor_string[count1], token);
// #ifdef DEBUG_LOGGING
printf("sensor: %f ", sensor[count1]); // print sensor data
printf("Sensor String %d is %s\n",count1, sensor_string[count1]);
// #endif
token = strtok(NULL, space);
}
}
printf("\n");
} else {
fprintf(stderr, "No Pi gps available\n");
}
fclose(gps_read);
} else
fprintf(stderr, "Error checking gps");
}
printf("\n");
// if (sensor[GPS1] != 0) {

@ -39,16 +39,17 @@
#define PRES 3
#define ALT 4
#define HUMI 5
#define GYRO_X 7 // MPU6050 is posisition 6
#define GYRO_X 7 // MPU6050 label is posisition 6
#define GYRO_Y 8
#define GYRO_Z 9
#define ACCEL_X 10
#define ACCEL_Y 11
#define ACCEL_Z 12
#define GPS1 14 // GPS is position 13
#define GPS2 15
#define GPS3 16
#define DTEMP 18 // TMP is position 17
#define GPS 13 // GPS label
#define GPS1 14 // latitude
#define GPS2 15 // longitude
#define GPS3 16 // altitude
#define DTEMP 18 // TMP label is position 17
#define XS1 20 // NEW user defined token will be position 19
#define XS2 21
#define XS3 22

Loading…
Cancel
Save

Powered by TurnKey Linux.