Compare commits

..

No commits in common. '221ef17d309487c8483182f56e1bc6f6bab8116c' and '39ebc247c921b6c1109e63802e5e69d77c98df12' have entirely different histories.

@ -1,68 +0,0 @@
#! /usr/bin/env python3
"""
example Python gpsd client
run this way: python3 example1.py.txt
"""
# from https://gpsd.gitlab.io/gpsd/gpsd-client-example-code.html
# this client is for the CubeSatSim Lite which does not have a Pico microcontroller
import gps # the gpsd interface module
import time
try:
mode = -1
lat = 0
lon = 0
alt = 0
session = gps.gps(mode=gps.WATCH_ENABLE)
start = time.perf_counter()
try:
while (session.read() == 0) and ((time.perf_counter() - start) < 2) and (mode < 2):
# print(gps.MODE_SET)
# print(session.valid)
if (session.valid):
# not useful, probably not a TPV message
# continue
# print('Mode: %s(%d) Time: ' %
# (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode],
# session.fix.mode), end="")
# print time, if we have it
# print("%d " % session.fix.mode, end="")
if (session.fix.mode > mode):
mode = session.fix.mode
# if gps.TIME_SET & session.valid:
# print(session.fix.time, end="")
# else:
# print('n/a', end="")
if gps.isfinite(session.fix.latitude):
lat = session.fix.latitude
if gps.isfinite(session.fix.longitude):
lon = session.fix.longitude
if gps.isfinite(session.fix.altitude):
alt = session.fix.altitude
# print("%.6f %.6f %.6f" % (session.fix.latitude, session.fix.longitude, session.fix.altitude))
# else:
# print(" 0 0 0")
except KeyboardInterrupt:
# got a ^C. Say bye, bye
print('')
# Got ^C, or fell out of the loop. Cleanup, and leave.
session.close()
print("%d %.6f %.6f %.1f" % (mode, lat, lon, alt))
# exit(0)
except:
print("-1 0 0 0")
exit(0)

@ -330,46 +330,18 @@ int main(int argc, char * argv[]) {
//file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1", "r");
pclose(file5);
cmdbuffer[0] = '\0';
gps_status = OFF;
FILE *gps_read = sopen("python3 /home/pi/CubeSatSim/gps_client.py"); // python sensor polling function
if (gps_read != NULL) {
fgets(cmdbuffer, 1000, gps_read);
fprintf(stderr, "gps read: %s\n", cmdbuffer);
if ((cmdbuffer[0] == '-') && (cmdbuffer[1] == '1'))
{
gps_status = OFF;
fprintf(stderr, "Pi GPS off\n");
} else {
gps_status = ON;
fprintf(stderr, "Pi GPS on\n");
}
fclose(gps_read);
} else
fprintf(stderr, "Error checking gps");
payload = OFF;
fprintf(stderr,"Opening serial\n");
if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600
fprintf(stderr,"Serial opened to Pico\n");
// payload = ON;
payload = get_payload_serial(FALSE);
fprintf(stderr,"Get_payload_status: %d \n", payload); // not debug
} else {
fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno));
}
if (gps_status == OFF)
{
fprintf(stderr,"Opening serial\n");
if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600
fprintf(stderr,"Serial opened to Pico\n");
// payload = ON;
payload = get_payload_serial(FALSE);
fprintf(stderr,"Get_payload_status: %d \n", payload); // not debug
} else {
fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno));
}
}
else
{
payload = FALSE;
printf("get_payload_status not run since gps_status is ON\n");
}
sensor_setup();
if ((i2c_bus3 == OFF) || (sim_mode == TRUE)) {
@ -677,17 +649,9 @@ int main(int argc, char * argv[]) {
if (gps_status == OFF)
{
payload = get_payload_serial(FALSE); // not debug
printf("get_payload_status: %d \n", payload);
}
else
{
payload = FALSE;
printf("get_payload_status not run since gps_status is ON\n");
}
payload = get_payload_serial(FALSE); // not debug
printf("get_payload_status: %d \n", payload);
if (payload == FALSE) {
payload = pi_sensors(buffer2);
printf("pi_sensors status: %d \n", payload);

@ -66,7 +66,7 @@
#define IHU_TEMP 2
#define SPIN 1
#define OFF -1
#define OFF - 1
#define ON 1
#define CHECK 0
#define DISABLED 0
@ -235,7 +235,6 @@ int fail_rnd_mode = FALSE;
int battery_saver_mode = FALSE;
long int loopTime;
long int failTime = 0;
int gps_status = OFF;
int error_count = 0;
int groundCommandCount = 0;

Loading…
Cancel
Save

Powered by TurnKey Linux.