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 26-05-2019, 14:52   #16
Registered User

Join Date: Mar 2011
Posts: 725
Re: Twocan - a new Plugin

First of all, my apologies for the compile error.

With the release of the recent TwoCan plugin (version 1.4), it requires updated Windows plugin drivers. I've only updated the Kvaser driver, but in my haste, have not git pushed the changed driver utility include files, hence the CONST_DATARX_EVENT error. I'll check my code and push the fixes soon.

Secondly my apologies that the Windows drivers do not have an installation utility.

I have yet to have mastered the intricacies of cmake, nsis etc. It's bad enough struggling with wxWidgets and wxFormbuilder !

(I take my hat off to all of the OpenCPN contributors who have combined their knowledge of wxWidgets, cmake, nsis, poedit to enable OpenCPN to support multiple platforms!)

On my Windows machine I use the following commands to build and "install" the drivers.

1. From the Visual Studio Tools, run a developer command prompt with admin credentials.
2. Change to the plugin drivers build directory. (Eg. On my machine: cd d:\code\plugindrivers\build)
3. Build the drivers (Eg. cmake --build . --config release)
4. Create the Twocan plugin driver directory for OpenCPN (Eg. mkdir "C:\Program Files\OpenCPN\plugins\twocan_pi\drivers")
5. Copy the drivers into the directory (Eg. copy D:\Code\TwoCanPluginDrivers\build\Cantact\Release\ Cantact.dll "C:\Program Files\OpenCPN\plugins\twocan_pi\drivers")


(repeat this command for each of the plugin drivers or at least for the driver that is required)

From the above OpenCPN log messages:
9:46:25 PM: TwoCan Settings, Driver Path: C:\Program Files (x86)\OpenCPN 4.8.8\plugins\twocan_pi\drivers\
9:46:25 PM: TwoCan Settings, driver folder not found

I can only presume that there is no directory named "C:\Program Files (x86)\OpenCPN 4.8.8\plugins\twocan_pi\drivers" and presumably no TwoCan plugin drivers are present.
stevead is offline   Reply With Quote
Old 26-05-2019, 15:49   #17
Registered User

Join Date: Mar 2011
Posts: 725
Re: Twocan - a new Plugin

To answer some of the other questions.
Quote:
1. Does this or could it support NMEA 2000 RAW protocol?

Example below:

Messages sent from Device to PC have the following form:
hh:mm:ss.ddd D msgid b0 b1 b2 b3 b4 b5 b6 b7<CR><LF>
The NMEA 2000 raw protocol described above is a log file format used by Yacht Devices equipment. It is not the "on the wire" format used by NMEA 2000 itself.

There is however a TwoCan plugin driver that supports the Yacht Devices log file format, so a log file created by Yacht Devices equipment can be replayed by the TwoCan plugin.

In addition there are three other log file formats supported by the TwoCan plugin; TwoCan raw format, Candump (Linux utility) and Kees (canboat).

Quote:
I'd like to understand how TwoCan_pi relates to
OpenSkipper is a C# .Net application that displays and decodes NMEA 0183 sentences and NMEA 2000 messages derived either from log files or from the Actisense NGT-1 adapter. It's a good tool for visualising the data and in fact I have used it to verify some of my NMEA 2000 parsing. It does not integrate with OpenCPN nor does it convert NMEA 2000 messages to NMEA 0183 sentences.

Canboat is a utility that decodes NMEA 2000 messages. It derives it's data either from log files, an Actisense NGT-1 adapter and on Linux via SocketCAN. It does not directly integrate with OpenCPN but with several scripts can pipe its output to other applications such as a Signal K Server to produce data in either the Signal K JSON format or via a Signal K Server plugin into NMEA 0183 sentences which could then be consumed by OpenCPN.

Signal K is a JSON data format for exchanging marine/nautical data. There are Signal K servers (both Open Source and proprietary) that decode NMEA0183 sentences and NMEA 2000 messages to produce Signal K JSON data and Signal K clients that display the data. Signal K JSON data cannot be directly consumed by OpenCPN.

The TwoCan plugin is a simple solution for integrating NMEA 2000 data into OpenCPN. It decodes NMEA 2000 messages directly from the NMEA 2000 network using inexpensive CAN bus adapters and converts the NMEA 2000 messages to NMEA 0183 sentences which are inserted directly into OpenCPN. Today on Windows three different CAN bus adapters are supported whilst on Linux (including Raspberry Pi) any CAN bus adapters that use the SocketCAN interface are supported.
stevead is offline   Reply With Quote
Old 26-05-2019, 17:50   #18
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Correct. I placed them under the "data" directory. Sorry.

Now here.



Quote:
C:\Program Files (x86)\OpenCPN 4.8.8\plugins\twocan_pi\drivers

Now it shows
Quote:
8:38:04 PM: PlugInManager: Loading PlugIn: C:\Program Files (x86)\OpenCPN 4.8.8\plugins\twocan_pi.dll
8:38:04 PM: C:\Program Files (x86)\OpenCPN 4.8.8\plugins\twocan_pi.dll
API Version detected: 108
PlugIn Version detected: 104
8:38:04 PM: Error: TwoCan Plugin, No driver selected. Device not started

So under Preferences I found the Nmea2000 dropdown and picked yachtd , then twocan, then candump, kees, and the last one, and they all failed and crashed O.


Sorry.
rgleason is offline   Reply With Quote
Old 27-05-2019, 02:38   #19
Registered User

Join Date: Mar 2011
Posts: 725
Re: Twocan - a new Plugin

Thanks for your perseverance Rick.

Unfortunately you have discovered the one known bug in the plugin, which is that when changing the TwoCan Windows driver plugin mid stream from the settings drop down list, that upon saving the settings, it crashes OpenCPN. I have yet to successfully debug this, the problem lies somewhere in twocanplugin.cpp, in the ShowSettingsDialog function.

The workaround is to manually edit the opencpn.ini file and change the TwoCan adapter setting. Eg, something like this:
Code:
[PlugIns/TwoCan]
Adapter=C:\\Program Files\\OpenCPN\\plugins\\twocan_pi\\drivers\\candumplog.dll
.....
BTW, Either an interesting bug in either OpenCPN or wxWidgets or a gap in my knowledge. Even though the TwoCan plugin has saved its settings, if OpenCPN crashes (which is clearly bad behaviour from a plugin perspective), the settings are not written to the opencpn.ini file. After a plugin calls settings->write, when exactly does OpenCPN or wxWidgets write the settings ? Or should I be also calling settings->Flush ? None of the samples seem to do this.

Regarding the log files, other than the TwoCan raw log format, I guess I should add some extra sample log formats for candump, kees and yacht devices. I'll add some to the github.com/twocanplugin/twocanplugindrivers repository.

Please note that for Windows users, the twocan, candump, kees and yacht devices log files must be named "twocanraw.log", "candump.log", "kees.log" and "yachtdevices.log" respectively and must be placed in the users "My Documents" folder.

For Linux users, irrespective of the log file format it must be named "twocan.log" and placed in the users home folder (aka ~)

Thanks to everyone for their feedback.
stevead is offline   Reply With Quote
Old 27-05-2019, 04:06   #20
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Thank you Steven,

I wonder if any of the programmers in this forum can suggest some code to help fix this bug? It would be much appreciated.



Quote:
Originally Posted by stevead View Post
Thanks for your perseverance Rick.

Unfortunately you have discovered the one known bug in the plugin, which is that when changing the TwoCan Windows driver plugin mid stream from the settings drop down list, that upon saving the settings, it crashes OpenCPN. I have yet to successfully debug this, the problem lies somewhere in twocanplugin.cpp, in the ShowSettingsDialog function.

The workaround is to manually edit the opencpn.ini file and change the TwoCan adapter setting. Eg, something like this:
Code:
[PlugIns/TwoCan]
Adapter=C:\\Program Files\\OpenCPN\\plugins\\twocan_pi\\drivers\\candumplog.dll
.....
BTW, Either an interesting bug in either OpenCPN or wxWidgets or a gap in my knowledge. Even though the TwoCan plugin has saved its settings, if OpenCPN crashes (which is clearly bad behaviour from a plugin perspective), the settings are not written to the opencpn.ini file. After a plugin calls settings->write, when exactly does OpenCPN or wxWidgets write the settings ? Or should I be also calling settings->Flush ? None of the samples seem to do this.

Regarding the log files, other than the TwoCan raw log format, I guess I should add some extra sample log formats for candump, kees and yacht devices. I'll add some to the github.com/twocanplugin/twocanplugindrivers repository.

Please note that for Windows users, the twocan, candump, kees and yacht devices log files must be named "twocanraw.log", "candump.log", "kees.log" and "yachtdevices.log" respectively and must be placed in the users "My Documents" folder.

For Linux users, irrespective of the log file format it must be named "twocan.log" and placed in the users home folder (aka ~)

Thanks to everyone for their feedback.
rgleason is offline   Reply With Quote
Old 27-05-2019, 04:22   #21
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Steven,


Thank you for the succinct overview. I find it very helpful and would like to start a page in the manual for this, may I quote?

Don't know if it should be an "Overview" page in the Twocan_pi manual or a separate page under Supplimentary Software.

https://opencpn.org/wiki/dokuwiki/do...gins:twocan_pi


https://opencpn.org/wiki/dokuwiki/do...ntary_software


Quote:
Originally Posted by stevead View Post
To answer some of the other questions.
The NMEA 2000 raw protocol described above is a log file format used by Yacht Devices equipment. It is not the "on the wire" format used by NMEA 2000 itself.

There is however a TwoCan plugin driver that supports the Yacht Devices log file format, so a log file created by Yacht Devices equipment can be replayed by the TwoCan plugin.

In addition there are three other log file formats supported by the TwoCan plugin; TwoCan raw format, Candump (Linux utility) and Kees (canboat).

OpenSkipper is a C# .Net application that displays and decodes NMEA 0183 sentences and NMEA 2000 messages derived either from log files or from the Actisense NGT-1 adapter. It's a good tool for visualising the data and in fact I have used it to verify some of my NMEA 2000 parsing. It does not integrate with OpenCPN nor does it convert NMEA 2000 messages to NMEA 0183 sentences.

Canboat is a utility that decodes NMEA 2000 messages. It derives it's data either from log files, an Actisense NGT-1 adapter and on Linux via SocketCAN. It does not directly integrate with OpenCPN but with several scripts can pipe its output to other applications such as a Signal K Server to produce data in either the Signal K JSON format or via a Signal K Server plugin into NMEA 0183 sentences which could then be consumed by OpenCPN.

Signal K is a JSON data format for exchanging marine/nautical data. There are Signal K servers (both Open Source and proprietary) that decode NMEA0183 sentences and NMEA 2000 messages to produce Signal K JSON data and Signal K clients that display the data. Signal K JSON data cannot be directly consumed by OpenCPN.

The TwoCan plugin is a simple solution for integrating NMEA 2000 data into OpenCPN. It decodes NMEA 2000 messages directly from the NMEA 2000 network using inexpensive CAN bus adapters and converts the NMEA 2000 messages to NMEA 0183 sentences which are inserted directly into OpenCPN. Today on Windows three different CAN bus adapters are supported whilst on Linux (including Raspberry Pi) any CAN bus adapters that use the SocketCAN interface are supported.
rgleason is offline   Reply With Quote
Old 27-05-2019, 19:34   #22
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Steven,


The branch ov50 on my repos has some changes to get the verison numbers included in the plugin executable. I'll make a pr to you.
This is the appveyor result
https://ci.appveyor.com/project/rgle...0539/artifacts


I have not done the twocandrivers.
rgleason is offline   Reply With Quote
Old 27-05-2019, 19:47   #23
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

This branch ov42 on my repos builds with the version number and ov42 the artifact file is here

https://ci.appveyor.com/project/rgle...0884/artifacts
rgleason is offline   Reply With Quote
Old 30-05-2019, 13:47   #24
Registered User

Join Date: May 2016
Location: Gothenburg, Sweden
Boat: Aphrodite 34
Posts: 13
Re: Twocan - a new Plugin

Quote:
Originally Posted by stevead View Post
To answer some of the other questions.
The NMEA 2000 raw protocol described above is a log file format used by Yacht Devices equipment. It is not the "on the wire" format used by NMEA 2000 itself.

There is however a TwoCan plugin driver that supports the Yacht Devices log file format, so a log file created by Yacht Devices equipment can be replayed by the TwoCan plugin.

In addition there are three other log file formats supported by the TwoCan plugin; TwoCan raw format, Candump (Linux utility) and Kees (canboat).
Thats true, but the raw format is not strictly used for logging but also tx/rx via tcp or udp through their WiFi router and gateway.
SYSkidbladner is offline   Reply With Quote
Old 30-05-2019, 15:02   #25
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Right now for Windows users, we're kind of stuck on this problem

Drop down driver selection crashes Opencpn

Steven suggests simply editing the opencpn.ini file to enter the correct name as the workaround for Windows users. Which we can do.

However this plugin looks like it might have great utility and users should ge familiar with it. To fix this should not be too hard.


There are a couple of other small issues with the twocandriver plugin too
https://github.com/TwoCanPlugIn/TwoC...Drivers/issues


It would be nice if someone could fix them.
rgleason is offline   Reply With Quote
Old 31-05-2019, 12:33   #26
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Steven,
Twocandrivers does not depend on any of the opencpn buildwin binaries or wxWidgets does it?


I am getting this Error C2065 for kvaser.c line 121

Quote:
C:\Users\Rick\Documents\GitHub\TwoCanPluginDrivers \Kvaser\src\Kvaser.c(121): error C2065: 'CONST_DATARX_EVENT' : undeclared
identifier [C:\Users\Rick\Documents\GitHub\TwoCanPluginDrivers \build\Kvaser\kvaser.vcxproj]
2 Warning(s) 1 Error(s)
https://docs.microsoft.com/en-us/cpp...5?view=vs-2019


Quote:
DllExport int OpenAdapter(void) {
// Create an event that is used to notify the caller of a received frame
frameReceivedEvent = CreateEvent(NULL, FALSE, FALSE, CONST_DATARX_EVENT); <---LINE 121

if (frameReceivedEvent == NULL)
{
// Fatal Error
DebugPrintf(L"Create FrameReceivedEvent failed (%d)\n", GetLastError());
return SET_ERROR(TWOCAN_RESULT_FATAL, TWOCAN_SOURCE_DRIVER, TWOCAN_ERROR_CREATE_FRAME_RECEIVED_EVENT);
}

I think that if we could get this bug fixed, then maybe we try to package it so it installs into the correct twocan_pii directory to make insttallation easier.


Then we need to get the crash bug fixed.
rgleason is offline   Reply With Quote
Old 31-05-2019, 14:41   #27
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

I just decided to declare it at the top and it compiled. Probably a hack.

https://github.com/rgleason/TwoCanPl...052d57e065f5c5


https://ci.appveyor.com/project/rgle...uilds/24962241


Next perhaps try to package it to install in the twocan_p/data/driver directory.
rgleason is offline   Reply With Quote
Old 31-05-2019, 14:57   #28
Registered User

Join Date: Mar 2011
Posts: 725
Re: Twocan - a new Plugin

None of the TwoCan plugin drivers have dependencies on wxWidgets or OpenCPN build libraries.

One of them, the Kvaser driver does have a dependency on a Kvaser library, but I have included that library and the accompanying include files in the git hub repository.

Regarding the error below
Quote:
C:\Users\Rick\Documents\GitHub\TwoCanPluginDrivers \Kvaser\src\Kvaser.c(121): error C2065: 'CONST_DATARX_EVENT' : undeclared
identifier [C:\Users\Rick\Documents\GitHub\TwoCanPluginDrivers \build\Kvaser\kvaser.vcxproj]
2 Warning(s) 1 Error(s
that was a simple error on my part, hastily pushing the updated version of the kvaser.c source file, without also pushing the changed twocandriver.h file in which that constant macro was defined.



I have now pushed changes to ensure that all the driver source files use the same constant macro definition. They "should" all compile without error. My sincere apologies.
stevead is offline   Reply With Quote
Old 01-06-2019, 05:44   #29
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Steve,
That fixed Kvaser, but now there is another error
Quote:
C:\project\twocandrivers\YachtDeviceslog\src\yacht deviceslog.cpp(116): error C2065: 'CONST_EVENT_NAME': undeclared identifier [C:\project\twocandrivers\build\YachtDeviceslog\yac htdeviceslog.vcxproj]
0 Warning(s)
1 Error(s)
Made this change and it works.
https://github.com/rgleason/TwoCanPl...47a04a6d9ff78f


Note the green appveyor check.
https://github.com/rgleason/TwoCanPl...commits/master


Follow that to the "Details" TAB

https://ci.appveyor.com/project/rgle...uilds/24970927
Then pick the "Artifacts" TAB
https://ci.appveyor.com/project/rgle...0927/artifacts


I need to package the drivers and they will show up here.




Quote:
Originally Posted by stevead View Post
None of the TwoCan plugin drivers have dependencies on wxWidgets or OpenCPN build libraries.

One of them, the Kvaser driver does have a dependency on a Kvaser library, but I have included that library and the accompanying include files in the git hub repository.

Regarding the error below that was a simple error on my part, hastily pushing the updated version of the kvaser.c source file, without also pushing the changed twocandriver.h file in which that constant macro was defined.



I have now pushed changes to ensure that all the driver source files use the same constant macro definition. They "should" all compile without error. My sincere apologies.
rgleason is offline   Reply With Quote
Old 01-06-2019, 07:44   #30
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,752
Images: 2
Re: Twocan - a new Plugin

Now, using appveyor all the dlls are copied to the appveyor build directory
https://ci.appveyor.com/project/rgle...2006/artifacts

We just need to package this now
rgleason is offline   Reply With Quote
Reply

Tags
plug


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
New IAC Fleetcode Plugin for OpenCPN CBorchardt OpenCPN 77 23-04-2019 05:40
Plugin development... How to receive chart objects in my plugin? dmartinez OpenCPN 6 04-08-2017 00:56
New History Plugin for OpenCPN seandepagnier OpenCPN 11 04-10-2010 14:11

Advertise Here


All times are GMT -7. The time now is 21:57.


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.