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 09-10-2018, 18:11   #1
Registered User

Join Date: Oct 2018
Location: Boston
Boat: Pacific Seacraft Flicka 20
Posts: 2
OpenCPN not engaging virtual port

Hello OpenCPN experts,


I am new to this wonderful application so please forgive me if the answer to the question is simple. But I have search high and low for a solution to my problem in the docs, and here and elsewhere and I am stumped. I would like to set up OpenCPN so that it opens a connection to a virtual (pseudo) port and receives GPS data through that port. I am hoping to share GPS data that I receive through a network socket with OpenCPN and other programs on the computer. So far, I have been able to set up a working virtual port using python and I have confirmed its function by sending test GPS data through this port to another program (Terminal running Screen). But when I then set up the connection in OpenCPN and then try to receive the data to through the virtual port the NEMA Debug Monitor shows no received data. I know that OpenCPN has been installed properly and has the potential to work with serial ports because I found that it can receive data from a GPS unit via a USB serial port connection.



I am using a Mac with OS 10.11 (El Capitan) and OpenCPN 4.8.6
I set up port: /dev/ptyp0 at 115200 using python and confirmed that it worked by writing to it and then getting the data from /dev/ttyp0 using Terminal

Data connection: Serial, /dev/ttyp0, priority 1, 115200, Connection input, filters none

the test data that I sent was: $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4 ,230394,003.1,W*6A


I would greatly appreciate any help! Thank you!


Jay
Flicka_1977 is offline   Reply With Quote
Old 09-10-2018, 19:27   #2
Registered User
 
SeanPatrick's Avatar

Join Date: Dec 2012
Location: Norfolk, VA USA
Posts: 691
Re: OpenCPN not engaging virtual port

Do you have the correct driver installed? From the OpenCPN wiki:


Quote:
Attaching a GPS device to a Mac is done via one of the USB ports. Whether using a device with its own USB lead or via a serial-USB adapter lead or an NMEA multiplexer with USB port, the appropriate OS X driver needs to be installed. Nearly all hardware uses one of just two chip makes: those from FTDI or Prolific. Both those companies make OS X drivers available on their web sites, but manufacturers of GPS devices usually package the driver with device.


When the driver is installed and the device connected, start OpenCPN, select the Toolbox and click the GPS tab. Open the “NMEA Data Source” menu & select the the device from the list. It is not always obvious which is the correct one, but in general the device will have a name starting: ”/dev/cu.“ or ”/dev/tty.“. Some manufacturers make it obvious, like ”/dev/cu.MiniPlex-99000125“, but others may be more generic, like: ”/dev/cu.usbserial“. Set the “NMEA Baud Rate” to 4800 and click “OK”. If the correct selection has been made, you should see the GPS status icon change from red to green.
SeanPatrick is offline   Reply With Quote
Old 10-10-2018, 12:48   #3
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,237
Re: OpenCPN not engaging virtual port

Quote:
Originally Posted by Flicka_1977 View Post
Hello OpenCPN experts,


I am new to this wonderful application so please forgive me if the answer to the question is simple. But I have search high and low for a solution to my problem in the docs, and here and elsewhere and I am stumped. I would like to set up OpenCPN so that it opens a connection to a virtual (pseudo) port and receives GPS data through that port. I am hoping to share GPS data that I receive through a network socket with OpenCPN and other programs on the computer. So far, I have been able to set up a working virtual port using python and I have confirmed its function by sending test GPS data through this port to another program (Terminal running Screen). But when I then set up the connection in OpenCPN and then try to receive the data to through the virtual port the NEMA Debug Monitor shows no received data. I know that OpenCPN has been installed properly and has the potential to work with serial ports because I found that it can receive data from a GPS unit via a USB serial port connection.



I am using a Mac with OS 10.11 (El Capitan) and OpenCPN 4.8.6
I set up port: /dev/ptyp0 at 115200 using python and confirmed that it worked by writing to it and then getting the data from /dev/ttyp0 using Terminal

Data connection: Serial, /dev/ttyp0, priority 1, 115200, Connection input, filters none

the test data that I sent was: $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4 ,230394,003.1,W*6A


I would greatly appreciate any help! Thank you!


Jay
Only one application at a time may normally have the TTY open at a time, make sure whatever else you may have using that port is not running when you try to use the "port" with OpenCPN.

May we see your logfile? And, much better, your python code?
It would of course be much better to use network connection, preferably UDP multicast, for any scenario other than for some unknown reason trying to simulate a serial device you actually do not have.

Pavel
nohal is offline   Reply With Quote
Old 10-10-2018, 13:28   #4
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,237
Re: OpenCPN not engaging virtual port

BTW, the checksum of your test sentence is wrong (should be 4A) and if I should bet you are not sending "\r\n" at the end of it as required by the standard.

If you try this
Code:
#!/usr/bin/python

import serial
import time

ser = serial.Serial('/dev/ptyp0')
while True:
  ser.write("$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4 ,230394,003.1,W*4A\r\n")
  time.sleep(1)
does it still not work on your machine?

Pavel
nohal is offline   Reply With Quote
Old 10-10-2018, 18:17   #5
Registered User

Join Date: Oct 2018
Location: Boston
Boat: Pacific Seacraft Flicka 20
Posts: 2
Re: OpenCPN not engaging virtual port

Thank you, very much, SeanPatrick and Pavel! I greatly appreciate your advice!!

SeanPatrick, your instructions worked very well for connecting the GPS unit via a USB port and driver for sending the data to OpenCPN. Using that method, I was able to confirm that OpenCPN was installed properly on my machine and that it was able to receive the data strings. But my problem was not being able to connect to OpenCPN via a virtual port and capture simulated GPS data sent by a python script. The virtual ports on the Mac don’t need drivers and even when properly set up, they are not listed using shell and ls /dev/{tty,cu}. Still, your advice was very helpful and thank you.

Pavel your solution worked great! You are right, the lack of the carriage return and newline characters was stopping the data reception by OpenCPN. I was only guessing that OpenCPN was accessing the virtual port. This is because I could not reinitialize the virtual port using python unless I quit OpenCPN. But I had no idea why the datagrams were not being shown. My python script was just like yours - I was using Pyserial as well. As an aside, I had copied the $GPRMC string from the web - I should have checked out the checksum before using it. But in testing whether the “\r\n” or the checksum was stopping the data flow, I found that the CR and NL were the issue - the troubleshooting window still showed the data with the appended "\r\n" even with the incorrect checksum.

You are absolutely right - my ultimate goal is to use a UDP multicast. This is because as you mentioned virtual ports don’t multiplex well. I tried using a UDP multicast approach first but I was unsuccessful in getting OpenCPN to display the data. I was trying to learn about UDP multicast and the port configurations as I was going along and I was getting nowhere and a little frustrated. So I thought that I’d try out a virtual port first to see how things worked. I will now go back to the UDP multicast method and see if adding the “\r\n” helps in getting that data stream to work. So far, I have been able to transmit the GPS data using a GPS-WIFI system running micropython and collect the UDP packets through a socket established using python on my Mac. I tried using python on the Mac because I read that not all routers will pass UDP multicast packets and I could not find the snooping setting on my router configuring software. So I resorted to using python to receive the data via the socket first. I’ll now go back to work on on figuring how to get the UDP packets into OpenCPN - first, checking whether the lack of “\r\n” was holding me up. Or, maybe I still need to figure out how to set the network port on OpenCPN correctly. If I get all this to work, I’ll make a write up so that others can see if the system works for them as well.

Again, thank you!! Jay
Flicka_1977 is offline   Reply With Quote
Reply

Tags
enc, opencpn


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
Opencpn not accepting NavmonPC virtual port? Franziska OpenCPN 10 14-06-2019 15:27
Native Virtual Com Port integration with OpenCPN Peter McNamara OpenCPN 0 27-08-2014 00:16
OpenCPN not recognising Virtual COM port LifePart2 OpenCPN 92 24-04-2014 10:08
OpenCPN does not see STM32 virtual port in MAC OSX GREENGHOST OpenCPN 9 24-02-2014 12:40
Virtual OpenCPN - 'OpenCPN on a Stick' r.fairman OpenCPN 23 16-10-2011 19:51

Advertise Here
  Vendor Spotlight
No Threads to Display.


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


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.