Compare commits

...

46 Commits

Author SHA1 Message Date
Alan Johnston 221ef17d30
Update main.c don't check get_payload_status if gps is on
3 days ago
Alan Johnston 4bafce21c7
Update main.c fix and
3 days ago
Alan Johnston 9ffb8aa715
Update main.c fix gps read print
3 days ago
Alan Johnston b9aa2b5811
Update gps_client.py no prints
3 days ago
Alan Johnston 5d68765a53
Update gps_client.py
3 days ago
Alan Johnston 61608a9fcb
Update gps_client.py remove extra prints
3 days ago
Alan Johnston 97ff121ce3
Update gps_client.py no exit
3 days ago
Alan Johnston e588a79cad
Update main.c
3 days ago
Alan Johnston 9fcaef192d
Update main.c check gps before payload
3 days ago
Alan Johnston f7cd661fc8
Update main.c display gps read
3 days ago
Alan Johnston 7a1bfce748
Update main.c add error checking gps
3 days ago
Alan Johnston 75325d38b2
Update main.c gps on/off
3 days ago
Alan Johnston 2fc1a58afe
Update main.h fix off
3 days ago
Alan Johnston eedf0944bc
Update main.c missing (
3 days ago
Alan Johnston cc2f6670b6
Update main.h gps_status
3 days ago
Alan Johnston 3df3728426
Update main.c add gps check
3 days ago
Alan Johnston 4d79943e55
Update main.h add gps_mode
3 days ago
Alan Johnston afd8cb3bf5
Update gps_client.py typo
3 days ago
Alan Johnston f965097f55
Update gps_client.py make fail -1 0 0 0
3 days ago
Alan Johnston 0ffa6c7512
Update gps_client.py extra print
3 days ago
Alan Johnston 37a607ba86
Update gps_client.py fix except
3 days ago
Alan Johnston 9e13222bd1
Update gps_client.py add return
3 days ago
Alan Johnston f43a9f19d7
Update gps_client.py missing "
3 days ago
Alan Johnston 307c7c6038
Update gps_client.py cleanup
3 days ago
Alan Johnston ce2ae0ea61
Update gps_client.py fix except
3 days ago
Alan Johnston 7140fab3f5
Update gps_client.py add except
3 days ago
Alan Johnston 4454747453
Update gps_client.py return -1 if no socket
3 days ago
Alan Johnston cb80a03df3
Update gps_client.py stop if mode 3
3 days ago
Alan Johnston ed570b8dc4
Update gps_client.py fix ()
3 days ago
Alan Johnston 53d8ecaa23
Update gps_client.py fix if
3 days ago
Alan Johnston 8cc8f6f079
Update gps_client.py check for finite
3 days ago
Alan Johnston 5797a0734a
Update gps_client.py add if session valid
3 days ago
Alan Johnston 921737ff6e
Update gps_client.py 2 seconds
3 days ago
Alan Johnston 78996ea015
Update gps_client.py add mode
3 days ago
Alan Johnston dd0b73c2cb
Update gps_client.py fix prints
3 days ago
Alan Johnston ac26577771
Update gps_client.py fix print
3 days ago
Alan Johnston 7d46d0f74d
Update gps_client.py fix prints
3 days ago
Alan Johnston a64604e76e
Update gps_client.py add alt
3 days ago
Alan Johnston e4fa0f7082
Update gps_client.py
3 days ago
Alan Johnston 75762f120a
Update gps_client.py counter
3 days ago
Alan Johnston 08454a385d
Update gps_client.py typo
3 days ago
Alan Johnston 6d764c1c52
Update gps_client.py add 1 second timeout
3 days ago
Alan Johnston 12494ebb9f
Update gps_client.py print values
3 days ago
Alan Johnston 8bb167acd1
Update gps_client.py fix mode print
4 days ago
Alan Johnston b6930b424b
Update gps_client.py just print mode lat lon
4 days ago
Alan Johnston 0d500ede48
Create gps_client.py
4 days ago

@ -0,0 +1,68 @@
#! /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,18 +330,46 @@ 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)) {
@ -649,9 +677,17 @@ int main(int argc, char * argv[]) {
payload = get_payload_serial(FALSE); // not debug
printf("get_payload_status: %d \n", payload);
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");
}
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,6 +235,7 @@ 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.