Skybolt - I am dipping my feet in the plugin wa...
I am dipping my feet in the plugin waters. Coming from Microsoft things are quite different in the linux world. Anyway, I have followed the documentation and and have a shell created and registered and although it does nothing right now it is running. My question is how do you get any sort of debug log going and where is it located?
43 Replies
I am running from a terminal and start SK like this: DEBUG=signalk-maretron-vmm6 signalk-server
Use app.debug(), and turn on the debug setting in the plugin options
Also I have app.debug statements in the index.js code. but nothing is in hte terminal.
Those will show in the “Server Log” in the admin console
And show in the system log file. (That location depends on what Linux distribution/version) you are using.
Yeah, nothing showing up anywhere it seems. I have this at the top - const debug = require('debug')('app');
and then app.debug("xxx"); but nothing.
No. Use app.debug
You don’t need that require
I am running on r-pi bookworm
I tried that before I put that there. but let me try again.
When you say admin log, thats the server log under server?
Yes
And sounds like you are running the server by hand?
I have tried it different ways. Only from the terminal because the log gets dumped there. A little easier at this point.
I disabled the services to run SK.
Then your debug logs will show in the terminal
Make sure you turn on debug in the Plugin Options
You don’t need the DEBUG in your command line
Right, that's what I thought and why I am running from the terminal at this point. Still nothing there. But at least I now know it is supposed to show up there. Thanks.

Sounds like your debug statement is not getting executed
Yeah looks that way.
That's why I had to ask these q's.
I can take a look at you code if you want...
Let me get it a bit further along and I definetly will take you up on that.
Thanks again Scott! BTW, I am over in the Kent Narrows. Small world.
Oh cool. I am on the Magothy
Nice area we live in huh? 😀
indeed!
Love it here on the bay.
Have a great day, I'll be back.
you too!
Question on eventing on a specific PGN? I am using subscribe/subscriptionmanager in start from the documentation. But is there anyway of subscribing to an actual path so that when that path's value changes I catch it? Right now it it is hit or miss it seems.
That’s exactly what subscriptionmanager does
What’s your subscription look like?
I probably need to narrow it down to only the bank and switch I am looking at.
Ok need to switch from this chrome book.
Ok trying again. This is the first part of the start:
let localSubscription = {
context: 'vessels.self',
subscribe: [{
path:
electrical.switches.bank.*,
period: 1000
}]}Looks good
This is the subscription manager:
app.subscriptionmanager.subscribe( localSubscription, unsubscribes, (subscriptionError) => { app.error('Error:' + subscriptionError) }, (delta) => {
delta.updates.forEach((update) => {
if (update.values) {
update.values.forEach((value) => {
const path = value.path;
const key =
if (path.endsWith('state')) { //app.debug(
//electrical.switches.bank.14.12.state let switchPGN = path.split('.'); let instance = Number(switchPGN[3]); let switchNum = Number(switchPGN[4]); let sval = value.value; if (instance == 14 && switchNum==1 ) app.debug(
${path}.${update.$source};if (path.endsWith('state')) { //app.debug(
Switch Path: ${path});//electrical.switches.bank.14.12.state let switchPGN = path.split('.'); let instance = Number(switchPGN[3]); let switchNum = Number(switchPGN[4]); let sval = value.value; if (instance == 14 && switchNum==1 ) app.debug(
Switch Value: ${instance}.${switchNum} = ${sval});
}
`
that app.debug doesn't pick up allof th eswitch changes.I could see you missing switches if they are happened more than once a second
You can set that period to 1ms in that case
I am trying to write a plugin that will work with the Maretron VMM switch series. But it doesn't follow N2K standards. It uses PGN127501 and uses the status in pairs. Meanng switch 1 uses status bits 1 and 2. Status switch 2 uses 3 and 4. they are set in the off state as bit 1 = 0 and bit 2 =1 then when on they flip, bit 1=1 and bit 2 = 0.
So you think I need to set the period to 500ms?
you can do 1ms
wow, ok. I was afraid of looking the thread.
locking*
Updates will only come as fast as they sent
Did you look at the n2k-switching plugin?
ok, good to know. Thanks. I am a beginner with signalk programming. But not programming.
There’s some Maretron support there
I think that may already be doing what you are trying to do?
Yes, but only for the actual relay devices
ok
It seems only 126208 is used by the plug in's. And this switch manipulates only 127501 with 2 bits, status 1 and 2 and so on.
Now that I think of it, I assume that is sending out periodic updates, you really should not be missing anything
if they follow the spec…
oops, the spec does not say how often it should be sent.
It does send out periodic updates, about once a second. But 127501 only. It uses 127501 to toggle the switch as well, in a very non standard way.
Non of their products use 127502, except the MConnect, it can toggle standard N2K switching. I worked with them to add that.
Is there a way to register a plugin without the manual npm link statement's so it will survive an update reboot?
do “npm pack”
That will give you a .tar.gz
Then in ~/.signalk
npm install /path/to/my.tar.gz
Once you do that, you can npm link again and it will survive updates
Make sure you leave that .tar.gz where you installed it from
Perfect! Thank you. This was tested on an R-Pi 5, the boat has a 4 so need to make sure the period isn't too fast for the subscribe.
Thank you again Scott!
If this was something like gps location, then the period would probably be overkill. But in this case, your data is not updating that fast. So if you set the period to 100ms but the data updates every second, you will only get updates every second.
I thought the same and 100ms was my first move. Didn't catch everything so I tried 50ms, Then landed on 25ms. 50ms may be alright. I still need to try this in a real N2K network. I spent the weekend changing oil and winterizing. Hopefully can try this out later in the week. The VMM6 does update every second, but it will also update on any change. So pressing switches quickly, as you might while the boat is running, things can get lost.