maps: read from gnss unix socket

This commit is contained in:
Daniel 2025-05-16 21:15:38 +00:00
parent ae9c4b0b3c
commit 4835b24e03

View File

@ -1,9 +1,12 @@
; (local { : view } (require :fennel)) ; (local { : view } (require :fennel))
(local { : fdopen } (require :posix.stdio))
(local { (local {
: Gtk : Gtk
: OsmGpsMap : OsmGpsMap
: Gdk : Gdk
: Gio
: GLib
} }
(require :lgi)) (require :lgi))
@ -60,6 +63,25 @@ label.readout {
(: :add (readout "00:00")) (: :add (readout "00:00"))
(: :add (readout "25 km/h")))) (: :add (readout "25 km/h"))))
(local gnss-socket
(let [addr (Gio.UnixSocketAddress {
:path "/var/run/gnss-share.sock"
})]
(: (Gio.SocketClient) :connect addr nil)))
(fn read-gnss [socket]
(each [l #(socket:read "l")]
(print "gnss" l))
true)
(let [sock (gnss-socket:get_socket)
fd (sock:get_fd)
events [ GLib.IOCondition.IN GLib.IOCondition.HUP]
channel (GLib.IOChannel.unix_new fd)
handle (fdopen fd :r)]
(GLib.io_add_watch channel 0 events #(read-gnss handle)))
(window:add (window:add
(doto (Gtk.Overlay {}) (doto (Gtk.Overlay {})
(: :add (osm-widget)) (: :add (osm-widget))