From bf7eac5fac7dd81108756d47c70626dcf0e677d5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 17 May 2025 23:23:32 +0000 Subject: [PATCH] parse nmea from socket --- pkgs/maps/main.fnl | 6 +++++- pkgs/maps/nmea.fnl | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl index 9a32538..389c20e 100644 --- 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 index 065e912..fe999c5 100644 --- 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 }