Cruisers Forum
 

Go Back   Cruisers & Sailing Forums > Seamanship, Navigation & Boat Handling > OpenCPN
Cruiser Wiki Click Here to Login
Register Vendors FAQ Community Calendar Today's Posts Log in

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 02-11-2023, 07:37   #1
Registered User

Join Date: Nov 2023
Posts: 1
Cursor position (Lat Long) output to UDP

Hi,

I would like to use OpenCPN as the front end of a project I am developing. Is there a native or plugin based way to capture the current cursor position (Lat, Long) and preferably also mouse events (click, down, scroll, etc) and have these output over UDP or serial? (Or even to a log file from where I can take it.)

I am a newbie in these forums, and trust me, I searched for the answer before asking.

Thank you...

PS: I absolutely love OpenCPN, have it in the office, home and on the boat (GrandBanks 36 Classic) laptop as backup to the Garmins. Thank you developers!
ertem is offline   Reply With Quote
Old 02-11-2023, 15:39   #2
Registered User

Join Date: Mar 2011
Posts: 651
Re: Cursor position (Lat Long) output to UDP

Yes, there are OpenCPN plugin API's that support your requirements. Refer to ocpn_plugin.h
Code:
#define WANTS_CURSOR_LATLON 0x00000002
.....
#define WANTS_MOUSE_EVENTS 0x00080000
.....
void SetCursorLatLon(double lat, double lon);
.....
bool MouseEventHook(wxMouseEvent &event);
Transmitting stuff via UDP is supported by either wxWidgets or OS specific API's.
This is an example of using wxWidgets API's to broadcast over UDP.
Code:
// wxWidgets UDP stuff for debug spew
wxDatagramSocket *debugSocket;
wxIPV4address addrLocal;
wxIPV4address addrPeer;
.....
// Initialize UDP socket for debug spew
addrLocal.Hostname();
addrPeer.Hostname("127.0.0.1");
addrPeer.Service(3002);
debugSocket = new wxDatagramSocket(addrLocal, wxSOCKET_NONE);
.....
if (!debugSocket->IsOk()) {
	wxLogMessage(_T("ERROR: failed to create UDP peer socket"));
}
.....
// Send JSON message for debugging
debugSocket->SendTo(addrPeer, message_body.data(), message_body.Length());
.....
// Clean up debug spew
debugSocket->Close();
None of this is rocket surgery.
stevead is offline   Reply With Quote
Reply


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
display position of an object with UDP conection jgk OpenCPN 9 24-04-2018 08:43
Plugin - Grabbing correct cursor lat/lon dachancellor OpenCPN 23 15-12-2015 07:43
Hi Lat or low Lat conachair Destinations 4 04-04-2012 12:44
Zoom Chart Centered at Cursor Position prjacobs OpenCPN 5 27-09-2010 12:10

Advertise Here


All times are GMT -7. The time now is 04:34.


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.