Path: blob/main/astro/opencpn/files/patch-src_chart1.cpp
16461 views
--- src/chart1.cpp.orig 2020-07-15 18:02:29 UTC1+++ src/chart1.cpp2@@ -8244,7 +8244,7 @@ void MyFrame::MouseEvent( wxMouseEvent& event )3#endif45#ifdef __WXGTK__6-#include <malloc.h>7+#include <stdlib.h>8#endif910#if defined(__linux__)11@@ -10382,10 +10382,14 @@12#if defined(__UNIX__) && !defined(__OCPN__ANDROID__) && !defined(__WXOSX__)13extern "C" int wait(int *); // POSIX wait() for process1415+#include <sys/param.h>16#include <termios.h>17+#include <fcntl.h>18#include <sys/ioctl.h>19#ifdef __linux__20#include <linux/serial.h>21+#else22+#include <termios.h>23#endif2425#endif26@@ -10452,7 +10456,8 @@2728int isTTYreal(const char *dev)29{30-#ifdef __NetBSD__31+#ifdef __FreeBSD__32+ wxLogMessage( _T("FreeBSD") );33if (strncmp("/dev/tty0", dev, 9) == 0)34return 1;35if (strncmp("/dev/ttyU", dev, 9) == 0)36@@ -10460,24 +10465,32 @@37if (strcmp("/dev/gps", dev) == 0)38return 1;39return 0;40-#else /* !NetBSD */41+#else42+#ifdef __FreeBSD__43+ struct termios termAttr;44+#else45struct serial_struct serinfo;46+#endif47int ret = 0;4849int fd = open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY);5051// device name is pointing to a real device52if(fd >= 0) {53+#ifdef __FreeBSD__54+ if (tcgetattr(fd, &termAttr) == 0) {55+#else56if (ioctl(fd, TIOCGSERIAL, &serinfo)==0) {57// If device type is no PORT_UNKNOWN we accept the port58if (serinfo.type != PORT_UNKNOWN)59+#endif60ret = 1;61}62close (fd);63}6465return ret;66-#endif /* !NetBSD */67+#endif68}697071@@ -10521,10 +10534,17 @@7273//Initialize the pattern table74if( devPatern[0] == NULL ) {75+#ifdef __FreeBSD__76+ paternAdd ( "ttyU" );77+ paternAdd ( "ttyu" );78+ paternAdd ( "ttyd" );79+ paternAdd ( "gps" );80+#else81paternAdd ( "ttyUSB" );82paternAdd ( "ttyACM" );83paternAdd ( "ttyGPS" );84paternAdd ( "refcom" );85+#endif86}8788// Looking for user privilege openable devices in /dev89@@ -11019,6 +11039,12 @@90if(!result1.size())91wxExecute(_T("stat -c %G /dev/ttyACM0"), result1);9293+ if(!result1.size())94+ wxExecute(_T("stat -f %g /dev/ttyu0"), result1);95+96+ if(!result1.size())97+ wxExecute(_T("stat -f %g /dev/ttyU0"), result1);98+99wxString msg1 = _("OpenCPN requires access to serial ports to use serial NMEA data.\n");100if(!result1.size()) {101wxString msg = msg1 + _("No Serial Ports can be found on this system.\n\102@@ -11032,7 +11058,7 @@103wxString user = wxGetUserId(), group = result1[0];104105wxArrayString result2;106- wxExecute(_T("groups ") + user, result2);107+ wxExecute(_T("id -G ") + user, result2);108109if(result2.size()) {110wxString user_groups = result2[0];111112113