1nmea(n) NMEA protocol implementation nmea(n)
2
3
4
5______________________________________________________________________________
6
8 nmea - Process NMEA data
9
11 package require Tcl 8.4
12
13 package require nmea ?1.0.0?
14
15 ::nmea::input sentence
16
17 ::nmea::open_port port ?speed?
18
19 ::nmea::close_port
20
21 ::nmea::configure_port settings
22
23 ::nmea::open_file file ?rate?
24
25 ::nmea::close_file
26
27 ::nmea::do_line
28
29 ::nmea::rate
30
31 ::nmea::log ?file?
32
33 ::nmea::checksum data
34
35 ::nmea::write sentence data
36
37 ::nmea::event setence ?command?
38
39______________________________________________________________________________
40
42 This package provides a standard interface for writing software which
43 recieves NMEA standard input data. It allows for reading data from COM
44 ports, files, or programmatic input. It also supports the checksumming
45 and logging of incoming data. After parsing, input is dispatched to
46 user defined handler commands for processing. To define a handler, see
47 the event command. There are no GPS specific functions in this package.
48 NMEA data consists of a sentence type, followed by a list of data.
49
51 ::nmea::input sentence
52 Processes and dispatches the supplied sentence. If sentence con‐
53 tains no commas it is treated as a Tcl list, otherwise it must
54 be standard comma delimited NMEA data, with an optional checksum
55 and leading $.
56
57
58 nmea::input {$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39}
59 nmea::input [list GPGSA A 3 04 05 09 12 "" "" 24 "" "" "" 2.5 1.3 2.1]
60
61
62 ::nmea::open_port port ?speed?
63 Open the specified COM port and read NMEA sentences when avail‐
64 able. Port speed is set to 4800bps by default or to speed.
65
66 ::nmea::close_port
67 Close the com port connection if one is open.
68
69 ::nmea::configure_port settings
70 Changes the current port settings. settings has the same format
71 as fconfigure -mode.
72
73 ::nmea::open_file file ?rate?
74 Open file file and read NMEA sentences, one per line, at the
75 rate specified by ?rate? in milliseconds. The file format may
76 omit the leading $ and/or the checksum. If rate is <= 0 (the
77 default) then lines will only be processed when a call to
78 do_line is made.
79
80 ::nmea::close_file
81 Close the open file if one exists.
82
83 ::nmea::do_line
84 If there is a currently open file, this command will read and
85 process a single line from it. Returns the number of lines
86 read.
87
88 ::nmea::rate
89 Sets the rate at which lines are processed from the open file,
90 in milliseconds. The rate remains consistant across files, there
91 does not need to be a file currently open to use this command.
92 Set to 0 to disable automatic line processing.
93
94 ::nmea::log ?file?
95 Starts or stops input logging. If a file name is specified then
96 all NMEA data recieved on the open port will be logged to the
97 ?file? in append mode. If file is an empty string then any log‐
98 ging will be stopped. If no file is specified then returns a
99 boolean value indicating if logging is currently enabled. Data
100 written to the port by write, data read from files, or input
101 made using input, is not logged.
102
103 ::nmea::checksum data
104 Returns the checksum of the supplied data.
105
106 ::nmea::write sentence data
107 If there is a currently open port, this command will write the
108 specified sentence and data to the port in proper NMEA check‐
109 summed format.
110
111 ::nmea::event setence ?command?
112 Registers a handler proc for a given NMEA sentence. There may be
113 at most one handler per sentence, any existing handler is
114 replaced. If no command is specified, returns the name of the
115 current handler for the given setence or an empty string if none
116 exists. In addition to the incoming sentences there are 2
117 builtin types, EOF and DEFAULT. The handler for the DEFAULT
118 setence is invoked if there is not a specific handler for that
119 sentence. The EOF handler is invoked when End Of File is reached
120 on the open file or port.
121
122 The handler procedures, with the exception of the builtin
123 types,must take exactly one argument, which is a list of the
124 data values. The DEFAULT handler should have two arguments, the
125 sentence type and the data values. The EOF handler has no argu‐
126 ments.
127
128
129 nmea::event gpgsa parse_sat_detail
130 nmea::event default handle_unknown
131
132 proc parse_sat_detail {data} {
133 puts [lindex $data 1]
134 }
135
136 proc handle_unknown {name data} {
137 puts "unknown data type $name"
138 }
139
140
142 This document, and the package it describes, will undoubtedly contain
143 bugs and other problems. Please report such in the category nmea of
144 the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please
145 also report any ideas for enhancements you may have for either package
146 and/or documentation.
147
148 When proposing code changes, please provide unified diffs, i.e the out‐
149 put of diff -u.
150
151 Note further that attachments are strongly preferred over inlined
152 patches. Attachments can be made by going to the Edit form of the
153 ticket immediately after its creation, and then using the left-most
154 button in the secondary navigation bar.
155
157 gps, nmea
158
160 Networking
161
163 Copyright (c) 2006-2009, Aaron Faupell <afaupell@users.sourceforge.net>
164
165
166
167
168tcllib 1.0.0 nmea(n)