commit bf7eac5fac7dd81108756d47c70626dcf0e677d5
parent 59c7b53022804fba3c912859e6efecee9d72724c
Author: Daniel <dan@telent.net>
Date: Sat, 17 May 2025 23:23:32 +0000
parse nmea from socket
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl
@@ -1,5 +1,6 @@
; (local { : view } (require :fennel))
(local { : fdopen } (require :posix.stdio))
+(local nmea (require :nmea))
(local {
: Gtk
@@ -71,7 +72,10 @@ label.readout {
(fn read-gnss [socket]
(each [l #(socket:read "l")]
- (print "gnss" l))
+ ; (print "gnss" l)
+ (if (not (= l ""))
+ (print (view (nmea.parse l)))))
+
true)
(let [sock (gnss-socket:get_socket)
diff --git a/pkgs/maps/nmea.fnl b/pkgs/maps/nmea.fnl
@@ -3,9 +3,8 @@
;; 3-5 are the message type
;; fields are comma-delimited
-;; we assume that we can parse the message based only on type
-;; (i.e. that the same type should always be parsed the same way no
-;; matter who the talker)
+;; we can parse the message based only on type (i.e. the same type is
+;; always parsed the same way no matter who the talker)
;; outline: split message into lines, extract values between
;; $ and * as talker, type, fields
@@ -177,3 +176,5 @@
:speed-kmh 2.9
:mode :A
})
+
+{ :parse parse-line }