Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/astro/opencpn/files/patch-src_chart1.cpp
16461 views
1
--- src/chart1.cpp.orig 2020-07-15 18:02:29 UTC
2
+++ src/chart1.cpp
3
@@ -8244,7 +8244,7 @@ void MyFrame::MouseEvent( wxMouseEvent& event )
4
#endif
5
6
#ifdef __WXGTK__
7
-#include <malloc.h>
8
+#include <stdlib.h>
9
#endif
10
11
#if defined(__linux__)
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>
19
#include <sys/ioctl.h>
20
#ifdef __linux__
21
#include <linux/serial.h>
22
+#else
23
+#include <termios.h>
24
#endif
25
26
#endif
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)
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;
40
return 0;
41
-#else /* !NetBSD */
42
+#else
43
+#ifdef __FreeBSD__
44
+ struct termios termAttr;
45
+#else
46
struct serial_struct serinfo;
47
+#endif
48
int ret = 0;
49
50
int fd = open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY);
51
52
// device name is pointing to a real device
53
if(fd >= 0) {
54
+#ifdef __FreeBSD__
55
+ if (tcgetattr(fd, &termAttr) == 0) {
56
+#else
57
if (ioctl(fd, TIOCGSERIAL, &serinfo)==0) {
58
// If device type is no PORT_UNKNOWN we accept the port
59
if (serinfo.type != PORT_UNKNOWN)
60
+#endif
61
ret = 1;
62
}
63
close (fd);
64
}
65
66
return ret;
67
-#endif /* !NetBSD */
68
+#endif
69
}
70
71
72
@@ -10521,10 +10534,17 @@
73
74
//Initialize the pattern table
75
if( devPatern[0] == NULL ) {
76
+#ifdef __FreeBSD__
77
+ paternAdd ( "ttyU" );
78
+ paternAdd ( "ttyu" );
79
+ paternAdd ( "ttyd" );
80
+ paternAdd ( "gps" );
81
+#else
82
paternAdd ( "ttyUSB" );
83
paternAdd ( "ttyACM" );
84
paternAdd ( "ttyGPS" );
85
paternAdd ( "refcom" );
86
+#endif
87
}
88
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];
112
113