nmea(3tcl)
๐ฐ๏ธ NAME ๐ฐ๏ธ
nmea โ bestie, this is the manual for the nmea package (section 3tcl, she's a Tcl girlie ๐
) and her one job is processing NMEA data. That's the whole name. Short, sweet, iconic. โจ
๐ SYNOPSIS ๐
Okay so before literally anything else you gotta have Tcl on deck, and then you pull in the package. The version is optional, hence the lil ?1.1.0? situation:
package require Tcl 8.5 9
package require nmea ?1.1.0?
::nmea::input sentence
::nmea::open_port port ?speed?
::nmea::close_port
::nmea::configure_port settings
::nmea::open_file file ?rate?
::nmea::close_file
::nmea::do_line
::nmea::rate
::nmea::log ?file?
::nmea::checksum data
::nmea::write sentence data
::nmea::event setence ?command?
and yes it literally says setence in there. not me being the one to fix it ๐ we report, we don't rewrite. no cap.
๐ธ DESCRIPTION ๐ธ
So here's the vibe: this package gives you a standard interface for writing software that receives NMEA standard input data. Which means you can read data from COM ports, from files, or just feed it in programmatically like the main character you are. ๐
It also handles checksumming and logging of incoming data, because nobody wants to do that by hand, fr fr.
Once parsing happens, the input gets dispatched to user defined handler commands for processing. Wanna define one of those handlers? Go look at the event command, bestie, she's the one in charge. ๐ซถ
Important note: there are no GPS specific functions in this package. She's just the plumbing, not the satellite. ๐ฐ๏ธ
And an NMEA sentence is literally just: a sentence type, followed by a list of data. That's the whole structure. Periodt.
โจ COMMANDS โจ
๐ฆ The lineup
::nmea::input sentenceโ takes that sentence and processes + dispatches it. Here's the tea: if the sentence has no commas in it, it's treated as a plain Tcl list. Otherwise it has to be standard comma delimited NMEA data, with an optional checksum and an optional leading$. Both of these work:
nmea::input {$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39}
nmea::input [list GPGSA A 3 04 05 09 12 "" "" 24 "" "" "" 2.5 1.3 2.1]
::nmea::open_port port ?speed?โ opens the COM port you named and reads NMEA sentences whenever they show up. Port speed defaults to 4800bps, or you can passspeedand do your own thing. โจ::nmea::close_portโ closes the COM port connection, but only if one is actually open. No drama.::nmea::configure_port settingsโ changes the current port settings.settingstakes the exact same format asfconfigure -mode, so go read that if you need the details.::nmea::open_file file ?rate?โ opensfileand reads NMEA sentences, one per line, at the rate you give in?rate?measured in milliseconds. The file format is chill โ it may omit the leading$and/or the checksum. And ifrateis<= 0(which is the default, btw) then lines only get processed when something callsdo_line. ๐ค::nmea::close_fileโ closes the open file if one exists. bye bestie ๐::nmea::do_lineโ if there's a file currently open, this reads and processes a single line from it. Returns the number of lines read. ๐::nmea::rateโ sets the rate at which lines get processed from the open file, in milliseconds. The rate stays consistent across files, so there doesn't need to be a file currently open for you to use this command. Set it to0to disable automatic line processing entirely. ๐::nmea::log ?file?โ starts or stops input logging. If you give it a file name, then all NMEA data received on the open port gets logged to?file?in append mode. Iffileis an empty string, any logging gets stopped. And if you pass no file at all, it returns a boolean telling you whether logging is currently enabled. ๐ซง
big caveat, don't skip this one: data written to the port bywrite, data read from files, or input made usinginputis NOT logged. only the port data. okay? okay. ๐
::nmea::checksum dataโ returns the checksum of the data you handed it. math girl summer ๐งฎ::nmea::write sentence dataโ if there's a port currently open, this writes the givensentenceanddataout to the port in proper NMEA checksummed format. โ๏ธ::nmea::event setence ?command?โ registers a handler proc for a given NMEA sentence. Rules: there can be at most one handler per sentence, and any existing handler gets replaced. If you don't pass acommand, it returns the name of the current handler for that sentence, or an empty string if none exists. ๐
So besides the actual incoming sentences, there are 2 builtin types: EOF and DEFAULT.
- The
DEFAULThandler fires when there's no specific handler for that sentence. - The
EOFhandler fires when End Of File is reached on the open file or port.
Now the signature tea: the handler procedures โ with the exception of the builtin types โ must take exactly one argument, which is a list of the data values. The DEFAULT handler should have two arguments: the sentence type and the data values. The EOF handler takes no arguments. ๐
Here's the whole squad in action:
nmea::event gpgsa parse_sat_detail
nmea::event default handle_unknown
proc parse_sat_detail {data} {
puts [lindex $data 1]
}
proc handle_unknown {name data} {
puts "unknown data type $name"
}
๐ BUGS, IDEAS, FEEDBACK ๐
Real talk, bestie: this document, and the package it describes, will undoubtedly contain bugs and other problems. Not being shady, that's just how it is. ๐ญ
Please report them in the category nmea of the Tcllib Trackers: http://core.tcl.tk/tcllib/reportlist
Got ideas for enhancements? For the package and/or the documentation? Also bring those there. We want them. ๐ซถ
If you're proposing code changes, please provide unified diffs โ i.e. the output of diff -u. That's the format, no substitutions.
And one more: attachments are strongly preferred over inlined patches. To attach something, go to the Edit form of the ticket right after you create it, then use the left-most button in the secondary navigation bar. boom. done. โจ
๐ KEYWORDS ๐
gps, nmea
๐ CATEGORY ๐
Networking
๐ COPYRIGHT ๐
Copyright (c) 2006-2009, Aaron Faupell <afaupell@users.sourceforge.net>
okay that's the whole page, you made it, so proud of you ๐ฅน๐ this beauty ships out of tcllib, version 1.1.0, and she answers to the name nmea(3tcl). go read your GPS data. slay. ๐ โจ
๐ฆ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 ยท Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 ยท Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 ยท Tcl
- Copyright (c) 2006-2009, Aaron Faupell <afaupell@users\&.sourceforge\&.net>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms