Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 21-12-2019, 17:52   #1
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,460
Signal K Implementation

Hello all...
After exhausting ourselves discussing SignalK at a theoretical level ...
http://www.cruisersforum.com/forums/...-k-155383.html
it is time to investigate a practical implementation.


As "proof of concept", I have implemented a SignalK client model as an integral OCPN connection type. This work is an extension of the excellent work of Anders {BALP}, as part of an un-integrated Pull Request first seen in August, 2018.

Notes:
1. Server: Tested with node.js SignalK server, as supplied with OpenPlotter, installed on rPI 3+. Also works with Artemis java server, with manual port specification: <ip>:55555.
2. Client: The OCPN core with new integral SignalK client has been tested for basic functionality on Win/Mac/Linux.
3. The OCPN client utilizes mDNS/Bonjour service discovery to make installation easier. Practically speaking, this means that the installer/user does not need to know the ip address and port of any accessible SignalK server. However, not all SignalK servers implement service discovery for the subscription/tcp service used by the OCPN client.
4. When enabled, the OCPN SignalK client subscribes to the basic set of navigation data for ownship. This is essentially a superset of the data that would be contained in a standard NMEA0183 RMC message. Depending upon the sensor configuration of the SignalK server, this data could be derived from serial NMEA, N2K, or other sources (e.g. NMEA logfiles). The OCPN client side does not today discriminate on data source at all.
5. OCPN does not re-transmit any data received via the SignalK interface. He is a pure client for his own internal requirements.
6. OCPN core does not synthesize virtual NMEA0183 messages to feed to Dashboard Plugin. So, the Dashboard is non-responsive to SignalK messages coming from the server. This is work TBD. One approach is to adapt Dashboard to be a SignalK client on it's own, running independent of the OCPN core. This is my preferred solution, and more in the spirit of SignalK client/server model. Of course, there are other 3rd party dashboard apps that also integrate directly with a SignalK server, some of which have graphics superior to our own Dashboard.
7. Performance: There is no noticeable performance hit from decoding JSON on systems tested so far, as compared to standard NMEA via tcp connection.

You may inspect the source code at github, master branch. Pre-built installers are available on the cloudsmith repo, as discussed elsewhere. Hopefully, the "Connections" UI for SignalK will be intuitive.

As we have discussed, there are numerous ways in which a SignalK server might be employed in an integrated OCPN system. I have heard anecdotally about some of them. Most seem to require an advanced level of networking experience to configure and use reliably. I'm hoping that this preview will help us to explore those cases, and so refine the entry-level user requirement for the next OCPN release.
There are still some implementation details to discuss.

I look forward to your comments and test results.
Dave
bdbcat is offline   Reply With Quote
Old 22-12-2019, 00:29   #2
bcn
Registered User

Join Date: May 2011
Location: underway whenever possible
Boat: Rangeboat 39
Posts: 4,792
Re: Signal K Implementation

Dave...


macOS version crashes with "divide by zero" at start - tried single and dual canvas.
Virgin opencpn.ini does not help neither.


Hubert


Code:
Process:               OpenCPN [5221]
Path:                  /Applications/OpenCPN 2.app/Contents/MacOS/OpenCPN
Identifier:            org.opencpn
Version:               5.0.522+9d58594 (???)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           OpenCPN [5221]
User ID:               501

Date/Time:             2019-12-22 09:11:45.941 +0100
OS Version:            Mac OS X 10.15.2 (19C57)
Report Version:        12
Anonymous UUID:        3B4E7B11-B4AD-07F5-C446-A58AF64462AC

Sleep/Wake UUID:       6EDEEAAE-7D7C-4B57-BF8D-39451EC3CC88

Time Awake Since Boot: 170000 seconds
Time Since Wake:       1500 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_ARITHMETIC (SIGFPE)
Exception Codes:       EXC_I386_DIV (divide by zero)
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Floating point exception: 8
Termination Reason:    Namespace SIGNAL, Code 0x8
Terminating Process:   exc handler [5221]

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libwx_osx_cocoau_core-3.1.1.0.0.dylib    0x0000000106284291 wxNonOwnedWindowImpl::FindFromWXWindow(NSWindow*) + 9
1   libwx_osx_cocoau_core-3.1.2.0.0.dylib    0x00000001010aef25 -[wxNonOwnedWindowController windowDidResize:] + 37
2   com.apple.CoreFoundation          0x00007fff2c4efe4a __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
3   com.apple.CoreFoundation          0x00007fff2c4efdde ___CFXRegistrationPost1_block_invoke + 63
4   com.apple.CoreFoundation          0x00007fff2c4efd53 _CFXRegistrationPost1 + 372
5   com.apple.CoreFoundation          0x00007fff2c4ef9a9 ___CFXNotificationPost_block_invoke + 97
6   com.apple.CoreFoundation          0x00007fff2c4bf808 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1773
7   com.apple.CoreFoundation          0x00007fff2c4bebaf _CFXNotificationPost + 1586
8   com.apple.Foundation              0x00007fff2eb68a02 -[NSNotificationCenter postNotificationName:object:userInfo:] + 59
9   com.apple.AppKit                  0x00007fff2970b185 -[NSWindow _setFrameCommon:display:fromServer:] + 3296
10  libwx_osx_cocoau_core-3.1.2.0.0.dylib    0x00000001010b024a wxNonOwnedWindowCocoaImpl::MoveWindow(int, int, int, int) + 298
11  libwx_osx_cocoau_core-3.1.2.0.0.dylib    0x0000000101004865 wxNonOwnedWindow::DoMoveWindow(int, int, int, int) + 37
12  libwx_osx_cocoau_core-3.1.2.0.0.dylib    0x000000010100b9fb wxWindow::DoSetSize(int, int, int, int, int) + 331
13  org.opencpn                       0x000000010036819c options::RecalculateSize() + 140
14  org.opencpn                       0x00000001003675ed options::CreateControls() + 2605
15  org.opencpn                       0x000000010036620b options::options(MyFrame*, int, wxString const&, wxPoint const&, wxSize const&, long) + 747
16  org.opencpn                       0x000000010036837d options::options(MyFrame*, int, wxString const&, wxPoint const&, wxSize const&, long) + 13
17  org.opencpn                       0x00000001001c2542 MyFrame::OnInitTimer(wxTimerEvent&) + 322
18  libwx_baseu-3.1.2.0.0.dylib       0x000000010175967f wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) + 223
19  libwx_baseu-3.1.2.0.0.dylib       0x000000010175a3ca wxEvtHandler::ProcessEventLocally(wxEvent&) + 90
20  libwx_baseu-3.1.2.0.0.dylib       0x000000010175a2b0 wxEvtHandler::ProcessEvent(wxEvent&) + 96
21  libwx_baseu-3.1.2.0.0.dylib       0x000000010175a74c wxEvtHandler::SafelyProcessEvent(wxEvent&) + 12
22  libwx_baseu-3.1.2.0.0.dylib       0x0000000101705dba wxTimerImpl::SendEvent() + 90
23  com.apple.CoreFoundation          0x00007fff2c515456 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
24  com.apple.CoreFoundation          0x00007fff2c515010 __CFRunLoopDoTimer + 872
25  com.apple.CoreFoundation          0x00007fff2c514ae3 __CFRunLoopDoTimers + 317
26  com.apple.CoreFoundation          0x00007fff2c4f9660 __CFRunLoopRun + 2227
27  com.apple.CoreFoundation          0x00007fff2c4f8738 CFRunLoopRunSpecific + 503
28  com.apple.HIToolbox               0x00007fff2b03f65d RunCurrentEventLoopInMode + 292
29  com.apple.HIToolbox               0x00007fff2b03f2a9 ReceiveNextEventCommon + 356
30  com.apple.HIToolbox               0x00007fff2b03f127 _BlockUntilNextEventMatchingListInModeWithFilter + 64
31  com.apple.AppKit                  0x00007fff296b0eb4 _DPSNextEvent + 990
32  com.apple.AppKit                  0x00007fff296af690 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
33  com.apple.AppKit                  0x00007fff296a13ae -[NSApplication run] + 658
34  libwx_osx_cocoau_core-3.1.2.0.0.dylib    0x00000001010a469e wxGUIEventLoop::OSXDoRun() + 174
35  libwx_baseu-3.1.2.0.0.dylib       0x000000010173be51 wxCFEventLoop::DoRun() + 49
36  libwx_baseu-3.1.2.0.0.dylib       0x00000001016a0f75 wxEventLoopBase::Run() + 85
37  libwx_baseu-3.1.2.0.0.dylib       0x0000000101679a74 wxAppConsoleBase::MainLoop() + 116
38  libwx_osx_cocoau_core-3.1.2.0.0.dylib    0x000000010104370a wxApp::OnRun() + 26
39  libwx_baseu-3.1.2.0.0.dylib       0x00000001016cfbf8 wxEntry(int&, wchar_t**) + 56
40  org.opencpn                       0x00000001001af7a4 main + 20
41  libdyld.dylib                     0x00007fff63c067fd start + 1
bcn is offline   Reply With Quote
Old 22-12-2019, 06:12   #3
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave..
On Win10.

Not sure how or what to test but so far:
NMEA nav-data stream on UDP 10110, AIS NMEA in on UDP 10111 and Serial receiver on COM2
- Whilst active connection UDP incoming data & 10110 and active connection serial COM2 outgoing data:
Add new serial. "Automatic server discovery" checked. -> No response.
Click: "Discover now..." -> "Signal K-server not found"
I disconnected the UDP connection & 10110.
Add new Network. Click: "Discover now..." -> "Signal K-server not found"


Switched to:
NMEA stream in on Serial COM2 and Serial receiver on COM2. Still AIS NMEA in on UDP 10111
Add new serial connection. Click: "Discover now..." -> "Signal K-server not found"


Any bug trace hints?


Håkan
Hakan is offline   Reply With Quote
Old 22-12-2019, 06:17   #4
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave...
Forgot:
Whilst unconnected and connect serial COM2 the following log: (Nothing new I suppose)

3:14:30 PM: Closing NMEA Datastream Serial:COM2
3:14:30 PM: Stopping Secondary Thread
3:14:31 PM: Stopped in 1 sec.

3:14:56 PM: makeDataStream Serial:COM2
3:14:56 PM: ConnectionParams CTOR
Hakan is offline   Reply With Quote
Old 22-12-2019, 07:07   #5
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave..
Please...Log is flooding..
could we change: (chart1 ~8785)

wxLogMessage(wxString::Format(_T("SatsInView: %d"), no));
To: for example:
wxLogDebug(wxString::Format(_T("SatsInView: %d"), no));
And in total approx. 6 similar around.

Håkan
Hakan is offline   Reply With Quote
Old 22-12-2019, 07:16   #6
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,460
Re: Signal K Implementation

Hakan...


That's a bug.
You should not see "Discover now..." button except when Network/SignalK connection is selected. And of course, if there is no Signal K server on the net, the discovery will so report.


github fix is on the way...


Thanks
Dave
bdbcat is offline   Reply With Quote
Old 22-12-2019, 07:34   #7
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave..
OK..
So next Q: How to implement/activate a Signal-k Server? Obviously not included in this patch? Probably a "stupid question" but without those us dummies we'll never know
Thanks
Hakan is offline   Reply With Quote
Old 22-12-2019, 07:58   #8
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,460
Re: Signal K Implementation

Hakan...


No stupid questions. Signal K is a whole new world to explore.
We have not determined our strategy for integrating a Signal K server within OCPN. There are some servers that will install and run on your standard Win10 machine. I have not yet gotten there.



So, the easy way: Install OpenPlotter on an rPI. It contains an integrated SignalK server, with interfaces to serial NMEA, some N2K, and also VDR-like simulation streamer.
I burned a separate SDCard with this image, so as not to disturb my existing rPI build environment. But this was probably not necessary. OpenPlotter is based on a standard "stretch" raspbian build.


Make sure the rPI is accessible on your network. Activate the SignalK server on it. And then run OCPN on another machine, e.g. your win10 daily driver.


This would be a "real-world" installation, as commonly discussed and described.
Also note: I have not yet tried the Signal K version of O as native run on rPI. In this case, on OpenPlotter, the Signal K server would be accessed from "localhost". More options....


As I said, a whole new world.



Dave
bdbcat is offline   Reply With Quote
Old 22-12-2019, 08:46   #9
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave..
I happened to have a RPi4 and OpenPlotter v ..18. To the Signal-K I've a hand help GPS connected.



And Yes! it was found by my Win O, see shot.


Some initial notes before dinner:
  1. NMEA debug window didn't include these data.
  2. Before the GPS had found enough sats my O was computing the data without any filter so the GPS status was circle green and the boat sometimes positioned at Lat 0, Lon 0.
  3. After GPS position was established O first crashed but on next start he saw the position.
Some more to do here but a good start! I'll come back with more...
Thanks
Håkan
Attached Thumbnails
Click image for larger version

Name:	sigK.png
Views:	203
Size:	11.5 KB
ID:	205499  
Hakan is offline   Reply With Quote
Old 22-12-2019, 10:03   #10
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave...
More short notes:
When "good" data is received from S-K, Signal-K, O runs wo crash.

O's multiplexer is not by-passing what's received from Signal-K. See shot.
I don't know if that's intended or not? Maybe a discussion point? We may not need it since S_K is multiplexing. On the other hand is O's multiplexer really functional. As seen from the shot I use to multiplex all to UDP 10112, at home and in the boat as well.

The crash when shifting between bad and good data was not repeated a second time.
Example of "bad" GPS data in shot 2 (From RPi). These would be sorted out and not try to position the boat.


Håkan
Attached Thumbnails
Click image for larger version

Name:	sigK.png
Views:	173
Size:	97.6 KB
ID:	205502   Click image for larger version

Name:	GPS_bad.png
Views:	191
Size:	147.7 KB
ID:	205503  

Hakan is offline   Reply With Quote
Old 22-12-2019, 11:22   #11
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave..
We may need some more log message cleaning..
This package every second: (Now 270 000 rows in a rather short period of time.)


7:52:58 PM: ***** Position Update
7:52:58 PM: ***** COG: 6.283185, 360.000000
7:52:58 PM: ***** SOG: 0.000000, 0.000000
7:52:58 PM: ** Signal K unhandled update: navigation.magneticVariationAgeOfService
7:52:58 PM: ** Signal K unhandled update: navigation.datetime
7:52:59 PM: SignalK Event received: {
"context" : "vessels.urn:mrn:imo:mmsi:265599690",
"updates" : [
{
"source" : {
"talker" : "GP",
"label" : "prolific",
"sentence" : "GGA",
"type" : "NMEA0183"
},
"timestamp" : "2019-12-22T18:52:58.000Z",
"values" : [
{
"path" : "navigation.position",
"value" : {
"latitude" : 58.22618333,
"longitude" : 11.76275
}
},
{
"path" : "navigation.gnss.methodQuality",
"value" : "GNSS Fix"
},
{
"path" : "navigation.gnss.satellites",
"value" : 8
},
{
"path" : "navigation.gnss.antennaAltitude",
"value" : 42
},
{
"path" : "navigation.gnss.horizontalDilution",
"value" : 2
},
{
"path" : "navigation.gnss.differentialAge",
"value" : 0
},
{
"path" : "navigation.gnss.differentialReference",
"value" : 0
}
]
}
]
}
7:52:59 PM: ***** Position Update
7:52:59 PM: ** Signal K unhandled update: navigation.gnss.methodQuality
7:52:59 PM: ** Signal K unhandled update: navigation.gnss.antennaAltitude
7:52:59 PM: ** Signal K unhandled update: navigation.gnss.horizontalDilution
7:52:59 PM: ** Signal K unhandled update: navigation.gnss.differentialAge
7:52:59 PM: ** Signal K unhandled update: navigation.gnss.differentialReference
7:52:59 PM: SignalK Event received: {
"context" : "vessels.urn:mrn:imo:mmsi:265599690",
Hakan is offline   Reply With Quote
Old 22-12-2019, 11:39   #12
Registered User

Join Date: Dec 2005
Location: Helsingborg
Boat: Dufour 35
Posts: 3,891
Re: Signal K Implementation

Dave

Never tried SK before so I installed the "Signal K Node Server" on an Ubuntu 19.10 box. Quite a few warnings about compatibility ( no surprise with 19.10), but no show stopper.
Running the "signalk-server --sample-nmea0183-data" O finds the SK server and "Own ship" is moved to Finland, so it works.
Very good for a proof of concept!

Thomas
cagney is offline   Reply With Quote
Old 22-12-2019, 12:15   #13
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave..
Maybe a short summary of my succeeded attempts:
The SK server is on a RPi4, OpenPlotter v 2.0.18-beta.
-RPi4 OCPN connected via O-connections: TCP localhost 10110 (= SK)

Two active SK server connections: See shot
- One serial GPS via RPi USB.
- One Network, USB 10111
One out TCP 10110 and (I think) the server itself on 8375

On my Win PC:
- OCPN connected to "Signal K" IP: 8375
- Own test program playing AIS-VDR.txt to UDP 10111

Both OCPN received the same data from SK.

Next is to update my RPi3 to the home brewed Git source and test a SK connection. (Just some hours to compile..)

Håkan
Attached Thumbnails
Click image for larger version

Name:	sk_node.png
Views:	169
Size:	33.3 KB
ID:	205513  
Hakan is offline   Reply With Quote
Old 22-12-2019, 13:37   #14
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 7,460
Re: Signal K Implementation

bcn...


re: Crash on MacOS.
Tried here on Mojave 10.14.5. Normal install and startup. No crash.
Maybe the problem is some legacy plugins causing trouble? Disable manually in config file to test.


Dave
bdbcat is offline   Reply With Quote
Old 22-12-2019, 13:41   #15
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,233
Re: Signal K Implementation

Dave..
RPi3 (stretch) build was fine as well. Also that device now connected to same net described above. GPS and AIS are there.
Håkan
Attached Thumbnails
Click image for larger version

Name:	rpi3_sk.png
Views:	188
Size:	111.4 KB
ID:	205521  
Hakan is offline   Reply With Quote
Reply

Tags
men


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open source implementation of PACTOR-3 and -4 Jammer Marine Electronics 53 02-02-2019 16:30
Navico BR24 Radar - Open Source protocol implementation maxxflow OpenCPN 23 30-07-2012 04:20
New Waypoint Properties Implementation nohal OpenCPN 206 14-07-2012 12:38
GPS signal too weak on Datamarine 5000 phorvati Marine Electronics 2 11-08-2009 14:26
Info on Signal flag Fonts ? JMRmarinero Flotsam & Sailing Miscellany 2 28-06-2007 08:54

Advertise Here


All times are GMT -7. The time now is 20:23.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.