Skip to content

Commit

Permalink
#60 fix timestamp type error
Browse files Browse the repository at this point in the history
  • Loading branch information
DarylDohner committed Jul 6, 2023
1 parent 4196e55 commit ccf9e6f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions EosPayload/drivers/GPS_driver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
import queue
import traceback

import adafruit_gps
import serial
import Adafruit_BBIO.UART as UART
Expand Down Expand Up @@ -87,13 +89,17 @@ def device_read(self, logger: logging.Logger) -> None:
data_datetime_string = "{:02}:{:02}:{:02} {}/{}/{}".format(time_hr, time_min, time_sec, time_day,
time_month, time_year)
data_datetime = datetime.datetime.strptime(data_datetime_string, GPSDriver.data_time_format)
date_time = str(data_datetime.timestamp())
except Exception:
date_time = str(datetime.datetime.now())
date_time = data_datetime.timestamp()
logger.info(f"Parsed timestamp from GPS: {data_datetime.isoformat()} ({date_time})")
except Exception as e:
data_datetime = datetime.datetime.now()
date_time = data_datetime.timestamp()
logger.warning("Error parsing timestamp from GPS, using current system time instead:"
f" {e}\n{traceback.format_exc()}")

logger.info(date_time)
logger.info(f"Timestamp: {data_datetime.isoformat()} ({date_time})")

position_bytes = Position.encode_position(float(date_time), float(gps_lat),
position_bytes = Position.encode_position(date_time, float(gps_lat),
float(gps_lon), float(gps_alt),
float(gps_speed), int(gps_sat),
self.current_flight_state)
Expand Down

0 comments on commit ccf9e6f

Please sign in to comment.