analyzer

canboat edited this page Apr 4, 2012 · 6 revisions

Analyzer is a command line program that takes as its input raw ASCII messages and converts these to either a readable ASCII format or JSON format.

Analyzer is the most complicated program in the CANboat project. It contains a large number of NMEA 2000 PGNs with guessed data formats and data lengths. The guesses mean that you should REALLY not use this blindly without checking that the guesses that the program makes are correct. Still, most PGNs have been found to work with a variety of devices and their decoding seems to be in order. If you find anything wrong with them, please fork and fix, then send a pull request to the maintainers.

Analyzer reads data in three formats:

  1. Plain format.

    This consists of lines containing fields separated by commas. The fields are: timestamp, priority, pgn, source, destination, number of data bytes followed by up to 8 data bytes. PGNs that span multiple CAN messages are are represented by one line per CAN message.

  2. Fast format.

    This is the same as plain format but with a PGN that spans multiple CAN messages condensed to one line. The number of data bytes will be higher than 8 for such messages.

  3. Airmar format.

    This is the format produced by Airmar's WeatherCaster software.

For instance if we use analyzer on the following data:

2011-11-24-22:42:04.388,2,127251,36,255,8,7d,0b,7d,02,00,ff,ff,ff
2011-11-24-22:42:04.390,2,127250,36,255,8,00,5a,7c,00,00,00,00,fd
2011-11-24-22:42:04.437,2,130306,36,255,8,b1,5c,00,ee,f0,fa,ff,ff

we get:

$ analyzer < small.log
N2K packet analyzer $Rev: 233 $ from $Date: 2011-11-27 22:21:08 +0100 (zo, 27 nov 2011) $
(C) 2009-2011 Keversoft B.V., Harlingen, The Netherlands
http://yachtelectronics.blogspot.com

New PGN 127251 for device 36 (heap 5452 bytes)
2011-11-24-22:42:04.388 2  36 255 127251 Rate of Turn:  SID = 125; Rate = 0.0934 deg/s
New PGN 127250 for device 36 (heap 5467 bytes)
2011-11-24-22:42:04.390 2  36 255 127250 Vessel Heading:  SID = 0; Heading = 182.4 deg; Deviation = 0.0 deg; Variation = 0.0 deg; Reference = Magnetic
New PGN 130306 for device 36 (heap 5480 bytes)
2011-11-24-22:42:04.437 2  36 255 130306 Wind Data:  SID = 177; Wind Speed = 0.92 m/s; Wind Angle = 353.4 deg; Reference = Apparent

The default output is readable for humans, but not very good for computers to parse and process further. If you want to use the analyzer in your software you're better of using the -json option which will produce lines like this:

{"timestamp":"2011-11-24-22:42:04.388","prio":"2","src":"36","dst":"255","pgn":"127251","description":"Rate of Turn","fields":{"SID":"125","Rate":"0.0934"}}
{"timestamp":"2011-11-24-22:42:04.390","prio":"2","src":"36","dst":"255","pgn":"127250","description":"Vessel Heading","fields":{"SID":"0","Heading":"182.4","Deviation":"0.0","Variation":"0.0","Reference":"Magnetic"}}
{"timestamp":"2011-11-24-22:42:04.437","prio":"2","src":"36","dst":"255","pgn":"130306","description":"Wind Data","fields":{"SID":"177","Wind Speed":"0.92","Wind Angle":"353.4","Reference":"Apparent"}}

The analyzer's second mode of producing the database that is kept within it can be accessed with the -explain and -explain-xml arguments. Further arguments are used when you are analyzing a particular PGN or a particular device.

Argument Purpose
-raw Show the raw bytes of the message data following the parsed data.
-debug Shows internal values of the parser; check the source.
-geo {dd,dm,dms} Choose which format is used to print geographical locations.
-json Format the output as JSON computer readable data.
-src <src> Ignore input coming from other sources than the specified one.
<pgn> Ignore PGNs other than this one.
-clocksrc <src> Set the computer's clock with data from this source.
-explain Produce the human readable list of PGNs that the parser understands.
-explain-xml Produce the computer readable list, in XML format, of PGNs that the parser understands.

The -clocksrc argument is only supported on POSIX platforms.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.