Skip to content

Commit

Permalink
Include utctime in message
Browse files Browse the repository at this point in the history
  • Loading branch information
sindrehan committed Oct 11, 2024
1 parent 0b56a34 commit 8f0cbf2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/nmea_publisher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import socket
import time
import blueye.protocol as bp
Expand All @@ -14,7 +15,12 @@ def nmea_sentence(lat: float, lon: float, valid: bool) -> str:
lat_hemisphere = "N" if lat >= 0 else "S"
lon_hemisphere = "E" if lon >= 0 else "W"
is_valid = "A" if valid else "V"
return f"GPGLL,{lat_deg:02d}{lat_min:07.4f},{lat_hemisphere},{lon_deg:03d}{lon_min:07.4f},{lon_hemisphere},{is_valid}"

# Get current UTC time with fractional seconds
now = datetime.datetime.now(datetime.timezone.utc)
utc_time = now.strftime("%H%M%S") + f".{now.microsecond // 10000:02d}"

return f"GPGLL,{lat_deg:02d}{lat_min:07.4f},{lat_hemisphere},{lon_deg:03d}{lon_min:07.4f},{lon_hemisphere},{utc_time},{is_valid}"


def callback_position_estimate(
Expand Down

0 comments on commit 8f0cbf2

Please sign in to comment.