--
You received this message because you are subscribed to the Google Groups "Signal K" group.
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
A parser for the GPSd JSON output wouldn’t be too hard to build. jamesp/node-mea module outputs a custom JSON format, I have a small utility that translates it to Signal K (although it still needs a lot of work). It could easily be adapted to translate GPSd JSON to Signal K. Although it’s written in node, it would not be that hard to make it work like a cli util that one can pipe after GPSd.
Teppo:I'm using a separate "module" (more like, a single file) that does some basic translation. GPS is simple, so I merely check what kind of message node-nmea has parsed (i.e., nav-info, track-info) and then taking out the necessary information, transforming it as necessary. At the moment this proces is still very incomplete (for instance, dates are not parsed properly) - I wanted to get my Provider-Server-Consumer logic up and running before perfecting.That said, come to think about it, I don't think that's the best way to go. In my opinion, it would be best to build a 'standard' parser for NMEA 0183 to Signal K (directly) without relying on any other translations (like GPSd JSON or node-nmea's output) - as they could change at any time and they just decrease performance (I mean, Parsing to JSON, and then translating to different JSON.. that already sounds slow). As the NMEA0182 protocol is huge and badly documented, the parser should be build in modular fashion.A parser could work like this:
- NMEA 0183 sentence is fed into the parser - either programmatically or via StdIn (e.g. getnmeafromgps --raw /dev/ttyUSB010101 | signalk-nmea0183 | signalk-utp-server).
- For each line of incoming NMEA data, the parser checks if there is a plugin available that can handle that particular line of NMEA data.
- If there is not, the line is discarded (throwing an error would not be useful, as there is a lot of data coming in and the parser would still work perfectly for other lines)
- The plugin is called to handle that particular line of data
- The plugin parses the data into sub-object of a full signalK object (e.g. "navigation": {} or even "location": {} if the line is coming from a GPS that doesn't give COG and SOG).
- The parser receives the sub-object and puts it in the right place in the SignalK object. If the data is already present (e.g., GPS data from two different sources) the data with the latest timestamp is used - in favour of the other data.
- The parser outputs a full Signal K object including all lines that could be parsed. Unparsed lines are simply ignored.
When the logic that checks the plugins and folds their results back into a signal k object is build, adding parsers for whatever line of NMEA data we can find could become a true community effort.I haven't really explored the source of node-nmea yet, so I have no idea how modular that is and if we could simply fork it to get started. If not, and if everyone agrees that we need a direct NMEA0183 to Signal K parser, I'm willing to start work on this and get the ball rolling. Teppo, what do you think?
I’d write it in Node (javascript), preferably. Node.js makes it extremely easy build the parser in such a way that it can work stand alone (as a CLI utility), executed from another process (regardless of the language) and (added bones) in the browser..
Something else I was thinking of, but I’m not sure if it adds value or makes anything any easier. Would it be an idea to write a little utility (NPM module for parsers written in Node) that parser plugins can require in order to automatically be up-to-date with the specification of Signal K? I’m thinking of something like this:- Plugins asks the K utility for the Schema of the K sub-object “environmental”.- An object defining all properties and their types, defaults etc is returned (not dissimilar to what most ORM/ODB libraries do - e.g. http://mongoosejs.com/docs/guide.html).
That way, we ensure (to a point) that a parser plugin’s output is always up to date with the spec, regardless of wether the author updates it regularly. Of course, this would only work for incremental (backwards compatible) spec updates, bigger, feature-breaking updates would require some work by the dev.
NMEA 0183 sentence is fed into the parser - either programmatically or via StdIn (e.g. getnmeafromgps --raw /dev/ttyUSB010101 | signalk-nmea0183 | signalk-utp-server).
- For each line of incoming NMEA data, the parser checks if there is a plugin available that can handle that particular line of NMEA data.
- If there is not, the line is discarded (throwing an error would not be useful, as there is a lot of data coming in and the parser would still work perfectly for other lines)
- The plugin is called to handle that particular line of data
- The plugin parses the data into sub-object of a full signalK object (e.g. "navigation": {} or even "location": {} if the line is coming from a GPS that doesn't give COG and SOG).
- The parser receives the sub-object and puts it in the right place in the SignalK object. If the data is already present (e.g., GPS data from two different sources) the data with the latest timestamp is used - in favour of the other data.
- The parser outputs a full Signal K object including all lines that could be parsed. Unparsed lines are simply ignored.
When the logic that checks the plugins and folds their results back into a signal k object is build, adding parsers for whatever line of NMEA data we can find could become a true community effort.I haven't really explored the source of node-nmea yet, so I have no idea how modular that is and if we could simply fork it to get started. If not, and if everyone agrees that we need a direct NMEA0183 to Signal K parser, I'm willing to start work on this and get the ball rolling. Teppo, what do you think?
My next todo item there would have been to make the plugins dynamic, eg. require all the files in a directory, assume they all export ID, put those into parsers like so:parsers[plugin.ID]=pluginand you have a lookup table for the parsers.