February 03, 2022

Read and write NMEA files, Openplotter, Signal K

This post is written for those who runs Signal K(SK), or applications that indirect are using SK, and want to write log files that could be read for later use.

Other applications could be Openplotter which includes SK or OpenCPN for example interfacing a NMEA 2000 network via SK.

There are sample files within the SK installation which can be used, for testing purposes, before you have created your own log files from your boat trips. Check here at "Input file/data".

Intro
The easiest way to read/write your trip data is to use, the two SK plugins, "signalk-data-logger" writing data to a log file and the "signalk-log-player" reading from the same log files.

The plugin "signalk-data-logger" will do the job recording and will write any data that is processed within the server, so called SK deltas.

The point storing it as SK data is that even if there is no "mapping" to a NMEA sentence the data is recorded and stored.

If you really want to store the data formated as NMEA 0183 or NMEa 2000 data I will show a way.

Write data
Install the "writer", "signalk-data-logger", via the "Appstore" and configure it via "Server => Plugin config => Signal K delta logger". Enable "Yes", and klick on "Submit" and the recording will start direct.

Please read the help supplied.

To stop the logging go back to the configuration => Enable "No", klick on "Submit" and restart the SK server.

Read data
Install the "reader", "signalk-log-player", via the "Appstore" and read the help supplied.

Please note that the "reader" can just read files that aren't compressed ! So decompress the files that you got from the "writer" with "gzip -d" For example 

gzip -d sk-delta-log.2022-01-25T18:04:51.865Z.log.gz

Configure the "reader" via "Server => Plugin config => Signal K Delta Log Player". 
Enable "Yes", and if you are using the default directory, from the "writer", change to path "/home/pi/sk-delta-logs". Klick on "Submit" and the reading will start direct.

Please note that if your boat is "moving" very slow or quick on the chart, compared to the actual recording, change the "Update rate (Hz)" in the configuration.

To stop the "reader" go back to the configuration => Enable "No", klick on "Submit" and restart the SK server.

To compress the files again use "gzip

NMEA 0183
If you really want NMEA 0183(N1) as output use the command 

nc localhost 10110 > N1.txt

This will work since every N1 message by default is available, TCP port 10110, at the server and in this case piped to the "N1.txt" file.

This file can then be used as an input for a "File Stream" connection.

Please note that if You just have NMEA 2000(N2), or created some own data, as input to SK you must use the "@signalk/signalk-to-nmea0183" plugin to map the SK path to N1 data.

If you want to pick just some selected N1 sentences, use the command above together with "grep". For example 

nc localhost 10110 | grep -E 'DBT|RMC' > N1.txt

NMEA2000
If you have an Actisense NG-T1 use

actisense-serialjs /dev/ttyUSB0 | analyzerjs > N2.txt


The file "N2.txt" can then be used as an input for a "File Stream" connection.

It could be that the commands aren't in your "path" so do a find "sudo find / -name "actisense-serialjs" and add the path with, for example 

export PATH="/usr/lib/node_modules/signalk-server/node_modules/.bin/:$PATH"


4 comments:

  1. As a newbie to SignalK this is an excellent article - exactly what I was looking for. Going to give this a go later today. Thank you so much.

    ReplyDelete
  2. Have You tried to "read" a file as described? I tried like your description but my Signal K server hangs and I have to re install it. Do you also have to add a "connection" with file as input or is this plugin all needed? I try to read files exported from Yachtdevices YDV-3 which should be in Signal-K format and look like this
    2023-06-27-09:25:07.532,6,60928,188,255,8,87,26,ab,59,00,96,96,c0
    2023-06-27-09:25:09.034,6,60928,187,255,8,dc,24,ab,59,00,96,96,c0
    2023-06-27-09:25:09.034,6,60928,105,255,8,0f,84,6c,e7,20,be,a0,c0
    2023-06-27-09:25:09.065,4,129039,43,255,27,12,78,41,d7,0f,ff,ff,ff,7f,ff,ff,ff,7f,fc,ff,ff,ff,ff,00,00,22,ff,ff,00,70,fe,ff
    2023-06-27-09:25:09.303,4,129038,43,255,28,01,66,82,d5,0f,e0,d5,b7,0a,da,c8,21,23,25,db,7a,cf,06,5d,01,01,b7,7a,00,00,c0,f8,ff

    I also tried in open skipper XML-format like this:

    18EEFFBC8726AB59009696C0
    18EEFFBBDC24AB59009696C0
    18EEFF690F846CE720BEA0C0

    Am I completely wrong?

    Any suggestions how to do?

    Reidar Stolt
    Sweden

    ReplyDelete
    Replies
    1. Hi ! Did you use the mentioned, "signalk-data-logger", to write the data to a log file ?

      Delete

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !