The attached patch populates the PTT serial port drop-down with detected TTYs using special FreeBSD magic (ie: /dev/tty* minus known non-serial device names).

Should only impact FreeBSD systems.
Index: src/dlg_ptt.cpp
===================================================================
--- src/dlg_ptt.cpp	(revision 1468)
+++ src/dlg_ptt.cpp	(working copy)
@@ -25,6 +25,10 @@
 #ifdef __WIN32__
 #include <wx/msw/registry.h>
 #endif
+#ifdef __FreeBSD__
+#include <glob.h>
+#include <string.h>
+#endif
 
 #include <sstream>
 
@@ -252,12 +256,39 @@
     m_cbSerialPort->Append(aStr);
 #endif
 #ifdef __WXGTK__
+    m_cbSerialPort->Clear();
+#ifdef __FreeBSD__
+	glob_t	gl;
+	if(glob("/dev/tty*", GLOB_MARK, NULL, &gl)==0) {
+		for(unsigned int i=0; i<gl.gl_pathc; i++) {
+			if(gl.gl_pathv[i][strlen(gl.gl_pathv[i])-1]=='/')
+				continue;
+				
+			/* Exclude pseudo TTYs */
+			if(gl.gl_pathv[i][8] >= 'l' && gl.gl_pathv[i][8] <= 's')
+				continue;
+			if(gl.gl_pathv[i][8] >= 'L' && gl.gl_pathv[i][8] <= 'S')
+				continue;
+
+			/* Exclude virtual TTYs */
+			if(gl.gl_pathv[i][8] == 'v')
+				continue;
+
+			/* Exclude initial-state and lock-state devices */
+			if(strchr(gl.gl_pathv[i], '.') != NULL)
+				continue;
+
+			m_cbSerialPort->Append(gl.gl_pathv[i]);
+		}
+		globfree(&gl);
+	}
+#else
     /* TODO(Joel): http://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them */
-    m_cbSerialPort->Clear();
     m_cbSerialPort->Append("/dev/ttyUSB0");
     m_cbSerialPort->Append("/dev/ttyUSB1");
     m_cbSerialPort->Append("/dev/ttyS0");
     m_cbSerialPort->Append("/dev/ttyS1");
+#endif
     /*
     m_txtCtlDevicePath->Clear();
     m_txtCtlDevicePath->Append("/dev/ttyUSB0");
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Freetel-codec2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freetel-codec2

Reply via email to