question

jwfrary avatar image
jwfrary asked

NGT-1 Pi and Venus

I have a Pi 2 and a NGT-1 from actisense.

While used to largeish be. Bus installations, I only have a BMV and a 500 watt pheonix inverter on my personal boat, along with a few temp sensors, so thinking rather than a full blown GX device a Pi with veus and signal k would suffice.


Anyway the question is, can I use an NGT-1 ISO in via the pi 2 UART port (via an rs232 Hat) with Venus OS?

I know the hardware works, it's currently running open plotter on a pi 4, but the power consumption is pretty high, so I'm thinking of migrating it all to a pi2 and use Venus os as the yacht server mainly to pass the victron data over to the N2k.


Thanks

Raspberry PiNMEA 2000 - N2K
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

andrew-mason avatar image andrew-mason commented ·
I have an NGT1 with a USB connector plugged into a Raspberry Pi 4 running Venus Large with SignalK. I cannot get it to work because SignalK reports a "permission denied" error opening the USB port. This seems a glitch which should be solvable. Have you got your system working? Thanks.
0 Likes 0 ·
6 Answers
bathnm avatar image
bathnm answered ·

It might be that VenusOS thinks it is a device it should be concerned about and therefore has it open meaning that SignalK cant use it.

A search of the web for information about serial-starter and VenusOS will give you some pointers as to how to get serial-starter to ignore the device and allow SignalK to access it.

I might in a few weeks time when on my boat be able to try plugging one into my VenusOS install and see what happens. Will be able to give you more information then.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

jwfrary avatar image jwfrary commented ·
I'll have a look at that, thanks, might wait for 2.90 to be released before I start customising!
0 Likes 0 ·
mvader (Victron Energy) avatar image
mvader (Victron Energy) answered ·

Afaik NGT-1 is not a common usb-can device , and will not show up as socketcan and will thus not work.


You’ll be saving yourself a lot of time by going for a can-hat for the pi. Or soms other something that ends up being socketcan

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ commented ·

Ps; in v2.90~12 we fixed a permission denied for usb devices & node-red.


Could be that something similar is needed for signalk: I don’t know which user we run signalk under, also don’t know its permissions. But that, as well as testing a fix, is something one of you can hopefully do.


Here is the recent fix for node-red.


https://github.com/victronenergy/meta-victronenergy/commit/f1c18713a44a9e1d849caca059575d6360aa3b3c


And, regardless of this permission issue, still there will be issues with having Venus OS read from the NGT-1 directly, since NGT-1 is not socketcan under linux.

On the opposiite: in signalk the NGT-1 should work.

0 Likes 0 ·
andrew-mason avatar image andrew-mason mvader (Victron Energy) ♦♦ commented ·

Thanks @mvader (Victron Energy) and @Bathnm for the good ideas.

I am not expecting Venus OS to read data from the NGT-1, but instead to leave the port available for use by Signal-K. As the comments above suggest, this could be a permissions issue to do with the Signal-K "user", or could it be that Venus-OS has opened the NGT-1 USB port? (If the latter, I will dig into "serial-starter".)

Perhaps I am unusual in adding devices to the Raspberry Pi that are intended for SignalK, and not Venus-OS?

A standalone Raspberry Pi Signal-K installation (i.e. not within Venus-OS) works fine; there is good Signal-K support for the NGT1 because it was one of the first NMEA2000-to-USB/Serial adapters. Note that my NGT-1 is a USB model; @Jwfrary 's unit seems to be a serial port model. I assume that will not make a difference.

I will do some experimenting when next aboard, and report back.

Thanks, again, for the prompt responses and support.

0 Likes 0 ·
andrew-mason avatar image
andrew-mason answered ·

I have made a start on this. Looking at the VenusOS file start-signalk.sh, VenusOS appears to start SignalK as the current user:

exec /usr/lib/node_modules/signalk-server/bin/signalk-server -c /data/conf/signalk

This suggests the error is not a privilege issue?

The start-signalk.sh script also defines a "before opening serial port" command used by SignalK:

export PRESERIALCOMMAND="/opt/victronenergy/serial-starter/stop-tty.sh"

PRESERIALCOMMAND is used in SignalK's "serialport.js" where it "is invoked once per each configured serial port", passing the port name as an argument:

if (process.env.PRESERIALCOMMAND) {
child_process.execSync(
`${process.env.PRESERIALCOMMAND} ${shellescape(this.options.device)}`
)
}

VenusOS documents "stop-tty.sh" as "stopping the driver", and (presumably) closing the port.

Can anyone see anything wrong with this? Note that the Actisense NGT-1 port is "/dev/serial/by-id/usb-0403_NGT-1-A_1A4FA-if00-port0"; is this a valid argument to "stop-tty.sh"?

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

andrew-mason avatar image
andrew-mason answered ·

Knowing that SignalK attempts to close the port made me look further. I see now that in the file:

meta-victronenergy-master\meta-third-party\recipes-extended\signalk-server\signalk-server_1.40.0.bb

the SignalK start-up is defined as follows:

DAEMONTOOLS_SCRIPT = "${bindir}/prepare-signalk.sh && exec setuidgid signalk ${bindir}/start-signalk.sh"

As you suggested, @mvader (Victron Energy) , this will likely cause the same problems as a similar exec did for NodeRed. Changing this will hopefully fix the problem. Based on the commit at

https://github.com/victronenergy/meta-victronenergy/commit/f1c18713a44a9e1d849caca059575d6360aa3b3c

the change should be, I suggest, although I have no experience as a Linux programmer :-)

- DAEMONTOOLS_SCRIPT = "${bindir}/prepare-signalk.sh && exec setuidgid signalk ${bindir}/start-signalk.sh"
+ DAEMONTOOLS_SCRIPT = "${bindir}/prepare-signalk.sh && exec setpriv --init-groups --reuid signalk --regid signalk ${bindir}/start-signalk.sh"

Does this look right?

Andrew

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dirk-Jan Faber (Victron Energy) avatar image Dirk-Jan Faber (Victron Energy) ♦ commented ·

That is correct. The patch for this change has already made it on the todo list and is likely to be applied for the next update. It is not too obvious, but the patch changes the last line in the file /service/signalk-server/run.

0 Likes 0 ·
andrew-mason avatar image
andrew-mason answered ·

Thanks, @mvader (Victron Energy) and @Bathnm for the good ideas.

I am not expecting the NGT-1 to provide NMEA-2000 data to VenusOS, but instead for VenusOS to leave the NGT-1 USB port available for Signal-K to then use. A standard Signal-K Raspberry Pi install (i.e. not using Signal-K within VenusOS) works fine with the NGT-1. There is good Actisense NGT-1 support in Signal-K because the NGT-1 was one of the first NMEA-2000-to-USB/Serial devices to be available.

To summarise the comments above, either :
(1) the Signal-K "user" under VenusOS may not have the correct permissions which will require (small) code changes to fix, or
(2) VenusOS is opening the NGT-1's USB port which, can be fixed using "serial-starter".
I will dig into this further when next on-board. (I am assuming that if VenusOS is opening the NGT-1 port, then the best fix is for me to discover an NGT-1 device ID and then add an appropriate line to /etc/udev/rules.d/serial-starter.rules )

@mvader (Victron Energy) I am not quite sure what you mean by "On the opposiite: in signalk the NGT-1 should work.", but just to be clear, the NGT-1 does work under a standard Signal-K install, but does not work with Signal-K as part of VenusOS.

Thanks, again, for all the help and suggestions.

PS: I note that my NGT-1 is the USB model, whereas @Jwfrary 's seems to be a serial model. I assume that a "serial-starter.rules" change will work for USB ports, but won't work for generic serial ports?

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

jwfrary avatar image jwfrary commented ·
Yes, Mine is a serial model, hooked up to a serial HAT on the Pi. (All bits left over from other projects)


from my point of view as long as it can talk to signal k that's great, and in some ways of course that separation from Victron side might be a good thing!


When i have more time ill give this a crack!

0 Likes 0 ·
andrew-mason avatar image
andrew-mason answered ·

Success!

I have now tested this on my Raspberry Pi 4 running Venus OS Large v2.90~12. Specifically, in the two files:

/service/signalk-server/run
/opt/victronenergy/service/signalk-server/run

I replaced the last line, which read:

/usr/bin/prepare-signalk.sh && exec setuidgid signalk /usr/bin/start-signalk.sh

with

/usr/bin/prepare-signalk.sh && exec setpriv --init-groups --reuid signalk --regid signalk /usr/bin/start-signalk.sh

I then added my NGT1 in SignalK as a Data Connection, re-booted, and it seemed to work. Specifically, SignalK showed my NGT1 as being connected to the NGT1 port instead of showing the "permission denied" error message I received before.

I do not have anything connected to my NGT-1, so I have not yet confirmed that it is actually receiving NMEA 2000 data, but at least the obvious error has been resolved.I will test this further when next aboard the boat.

It would be great if this change could be considered for the next 2.90~XX release.

Thanks, @mvader (Victron Energy), for pointing me at the commit I could copy from: https://github.com/victronenergy/meta-victronenergy/commit/f1c18713a44a9e1d849caca059575d6360aa3b3c

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

bathnm avatar image bathnm commented ·

@Andrew Mason Glad you got it working. There was a post earlier today on one of your previous comments informing you that the patch is already in the todo list for merging into one of the upcoming beta releases.

0 Likes 0 ·

Related Resources

Additional resources still need to be added for this topic

Raspberry Pi running Victron’s Venus firmware - Blog Post

Venus OS Large image: Signal K and Node-RED - Install

raspberrypi install venus image


Additional resources still need to be added for this topic