Lines 1-6
Link Here
|
1 |
--- src/chart1.cpp.orig 2020-07-15 18:02:29 UTC |
1 |
--- src/chart1.cpp.orig 2020-07-15 18:02:29 UTC |
2 |
+++ src/chart1.cpp |
2 |
+++ src/chart1.cpp |
3 |
@@ -8226,7 +8226,7 @@ void MyFrame::MouseEvent( wxMouseEvent& event ) |
3 |
@@ -8244,7 +8244,7 @@ void MyFrame::MouseEvent( wxMouseEvent& event ) |
4 |
#endif |
4 |
#endif |
5 |
|
5 |
|
6 |
#ifdef __WXGTK__ |
6 |
#ifdef __WXGTK__ |
Lines 9-15
Link Here
|
9 |
#endif |
9 |
#endif |
10 |
|
10 |
|
11 |
#if defined(__linux__) |
11 |
#if defined(__linux__) |
12 |
@@ -10370,6 +10370,8 @@ extern "C" int wait(int *); // POS |
12 |
@@ -10382,10 +10382,14 @@ |
|
|
13 |
#if defined(__UNIX__) && !defined(__OCPN__ANDROID__) && !defined(__WXOSX__) |
14 |
extern "C" int wait(int *); // POSIX wait() for process |
15 |
|
16 |
+#include <sys/param.h> |
17 |
#include <termios.h> |
18 |
+#include <fcntl.h> |
13 |
#include <sys/ioctl.h> |
19 |
#include <sys/ioctl.h> |
14 |
#ifdef __linux__ |
20 |
#ifdef __linux__ |
15 |
#include <linux/serial.h> |
21 |
#include <linux/serial.h> |
Lines 18-32
Link Here
|
18 |
#endif |
24 |
#endif |
19 |
|
25 |
|
20 |
#endif |
26 |
#endif |
21 |
@@ -10445,17 +10447,25 @@ int isTTYreal(const char *dev) |
27 |
@@ -10452,7 +10456,8 @@ |
|
|
28 |
|
29 |
int isTTYreal(const char *dev) |
30 |
{ |
31 |
-#ifdef __NetBSD__ |
32 |
+#ifdef __FreeBSD__ |
33 |
+ wxLogMessage( _T("FreeBSD") ); |
34 |
if (strncmp("/dev/tty0", dev, 9) == 0) |
22 |
return 1; |
35 |
return 1; |
|
|
36 |
if (strncmp("/dev/ttyU", dev, 9) == 0) |
37 |
@@ -10460,24 +10465,32 @@ |
38 |
if (strcmp("/dev/gps", dev) == 0) |
39 |
return 1; |
23 |
return 0; |
40 |
return 0; |
24 |
#else /* !NetBSD */ |
41 |
-#else /* !NetBSD */ |
25 |
+#ifdef __linux__ |
42 |
+#else |
|
|
43 |
+#ifdef __FreeBSD__ |
44 |
+ struct termios termAttr; |
45 |
+#else |
26 |
struct serial_struct serinfo; |
46 |
struct serial_struct serinfo; |
27 |
+#else |
47 |
+#endif |
28 |
+ struct termios termattr; |
|
|
29 |
+#endif |
30 |
int ret = 0; |
48 |
int ret = 0; |
31 |
|
49 |
|
32 |
int fd = open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY); |
50 |
int fd = open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY); |
Lines 33-65
Link Here
|
33 |
|
51 |
|
34 |
// device name is pointing to a real device |
52 |
// device name is pointing to a real device |
35 |
if(fd >= 0) { |
53 |
if(fd >= 0) { |
36 |
+#ifdef __linux__ |
54 |
+#ifdef __FreeBSD__ |
|
|
55 |
+ if (tcgetattr(fd, &termAttr) == 0) { |
56 |
+#else |
37 |
if (ioctl(fd, TIOCGSERIAL, &serinfo)==0) { |
57 |
if (ioctl(fd, TIOCGSERIAL, &serinfo)==0) { |
38 |
// If device type is no PORT_UNKNOWN we accept the port |
58 |
// If device type is no PORT_UNKNOWN we accept the port |
39 |
if (serinfo.type != PORT_UNKNOWN) |
59 |
if (serinfo.type != PORT_UNKNOWN) |
40 |
- ret = 1; |
|
|
41 |
+#else |
42 |
+ if (tcgetattr(fd, &termattr) == 0) { |
43 |
+#endif |
60 |
+#endif |
44 |
+ ret = 1; |
61 |
ret = 1; |
45 |
} |
62 |
} |
46 |
close (fd); |
63 |
close (fd); |
47 |
} |
64 |
} |
48 |
@@ -10505,10 +10515,17 @@ wxArrayString *EnumerateSerialPorts( void ) |
|
|
49 |
|
65 |
|
|
|
66 |
return ret; |
67 |
-#endif /* !NetBSD */ |
68 |
+#endif |
69 |
} |
70 |
|
71 |
|
72 |
@@ -10521,10 +10534,17 @@ |
73 |
|
50 |
//Initialize the pattern table |
74 |
//Initialize the pattern table |
51 |
if( devPatern[0] == NULL ) { |
75 |
if( devPatern[0] == NULL ) { |
52 |
+#ifdef __linux__ |
76 |
+#ifdef __FreeBSD__ |
|
|
77 |
+ paternAdd ( "ttyU" ); |
78 |
+ paternAdd ( "ttyu" ); |
79 |
+ paternAdd ( "ttyd" ); |
80 |
+ paternAdd ( "gps" ); |
81 |
+#else |
53 |
paternAdd ( "ttyUSB" ); |
82 |
paternAdd ( "ttyUSB" ); |
54 |
paternAdd ( "ttyACM" ); |
83 |
paternAdd ( "ttyACM" ); |
55 |
paternAdd ( "ttyGPS" ); |
84 |
paternAdd ( "ttyGPS" ); |
56 |
paternAdd ( "refcom" ); |
85 |
paternAdd ( "refcom" ); |
57 |
+#else |
|
|
58 |
+ paternAdd ( "ttyU" ); |
59 |
+ paternAdd ( "ttyu" ); |
60 |
+ paternAdd ( "ttyd" ); |
61 |
+ paternAdd ( "gps" ); |
62 |
+#endif |
86 |
+#endif |
63 |
} |
87 |
} |
64 |
|
88 |
|
65 |
// Looking for user privilege openable devices in /dev |
89 |
// Looking for user privilege openable devices in /dev |
|
|
90 |
@@ -11019,6 +11039,12 @@ |
91 |
if(!result1.size()) |
92 |
wxExecute(_T("stat -c %G /dev/ttyACM0"), result1); |
93 |
|
94 |
+ if(!result1.size()) |
95 |
+ wxExecute(_T("stat -f %g /dev/ttyu0"), result1); |
96 |
+ |
97 |
+ if(!result1.size()) |
98 |
+ wxExecute(_T("stat -f %g /dev/ttyU0"), result1); |
99 |
+ |
100 |
wxString msg1 = _("OpenCPN requires access to serial ports to use serial NMEA data.\n"); |
101 |
if(!result1.size()) { |
102 |
wxString msg = msg1 + _("No Serial Ports can be found on this system.\n\ |
103 |
@@ -11032,7 +11058,7 @@ |
104 |
wxString user = wxGetUserId(), group = result1[0]; |
105 |
|
106 |
wxArrayString result2; |
107 |
- wxExecute(_T("groups ") + user, result2); |
108 |
+ wxExecute(_T("id -G ") + user, result2); |
109 |
|
110 |
if(result2.size()) { |
111 |
wxString user_groups = result2[0]; |