Naturally, I forgot the patch file. Sigh.
diff --git a/freebsd.c b/freebsd.c
index 387b2f8..4148bec 100644
--- a/freebsd.c
+++ b/freebsd.c
@@ -18,61 +18,18 @@
  */
 
 /*
- * FreeBSD platform specific serial port information:
- *
- * FreeBSD has two device nodes for each serial port:
- *
- *  1) a call-in port
- *  2) a call-out port
- *
- * Quoting FreeBSD Handbook section 26.2.1
- * (https://www.freebsd.org/doc/handbook/serial.html)
- *
- * In FreeBSD, each serial port is accessed through an entry in /dev.
- * There are two different kinds of entries:
- *
- * 1) Call-in ports are named /dev/ttyuN where N is the port number,
- *    starting from zero. If a terminal is connected to the first serial port
- *    (COM1), use /dev/ttyu0 to refer to the terminal. If the terminal is on
- *    the second serial port (COM2), use /dev/ttyu1, and so forth.
- *    Generally, the call-in port is used for terminals. Call-in ports require
- *    that the serial line assert the "Data Carrier Detect" signal to work
- *    correctly.
- *
- * 2) Call-out ports are named /dev/cuauN on FreeBSD versions 10.x and higher
- *    and /dev/cuadN on FreeBSD versions 9.x and lower. Call-out ports are
- *    usually not used for terminals, but are used for modems. The call-out
- *    port can be used if the serial cable or the terminal does not support
- *    the "Data Carrier Detect" signal.
- *
- * FreeBSD also provides initialization devices (/dev/ttyuN.init and
- * /dev/cuauN.init or /dev/cuadN.init) and locking devices (/dev/ttyuN.lock
- * and /dev/cuauN.lock or /dev/cuadN.lock). The initialization devices are
- * used to initialize communications port parameters each time a port is
- * opened, such as crtscts for modems which use RTS/CTS signaling for flow
- * control. The locking devices are used to lock flags on ports to prevent
- * users or programs changing certain parameters.
- *
- * In line with the above device naming USB-serial devices have
- * the following naming:
- *
- * 1) call-in ports: /dev/ttyUN where N is the port number
- * 2) call-out ports: /dev/cuaUN where N is the port number
- *
- * See also: ucom(4), https://www.freebsd.org/cgi/man.cgi?query=ucom
- *
  * Getting USB serial port device description:
  *
  * In order to query USB serial ports for device description - the mapping
  * between the kernel device driver instances must be correlated with the
  * above mentioned device nodes.
  *
- * 1) For each USB-serial port (/dev/cuaUN) use libusb to lookup the device
+ * 1) For each USB-serial port (/dev/ttyUN) use libusb to lookup the device
  *    description and the name of the kernel device driver instance.
  * 2) Query sysctl for the kernel device driver instance info.
  * 3) Derive the ttyname and (serial) port count for the kernel device
  *    driver instance.
- * 4) If sysctl ttyname and port matches /dev/cuaUN apply the libusb
+ * 4) If sysctl ttyname and port matches /dev/tty apply the libusb
  *    device description.
  */
 
@@ -91,7 +48,7 @@
 #include "libserialport.h"
 #include "libserialport_internal.h"
 
-#define DEV_CUA_PATH "/dev/cua"
+#define DEV_TTY_PATH "/dev/tty"
 
 //#define DBG(...) printf(__VA_ARGS__)
 #define DBG(...)
@@ -240,24 +197,25 @@ SP_PRIV enum sp_return get_port_details(struct sp_port 
*port)
        struct libusb20_backend *be;
        struct libusb20_device *dev, *dev_last;
        char tbuf[FILENAME_MAX];
-       char *cua_sfx;
-       int cua_dev_found;
+       char *tty_sfx;
+       int tty_dev_found;
        uint8_t idx;
        int sub_inst;
 
        DBG("Portname: '%s'\n", port->name);
 
-       if (!strncmp(port->name, DEV_CUA_PATH, strlen(DEV_CUA_PATH))) {
-               cua_sfx = port->name + strlen(DEV_CUA_PATH);
-               DBG("'%s': '%s'\n", DEV_CUA_PATH, cua_sfx);
-       } else {
+       if (!strncmp(port->name, DEV_TTY_PATH, strlen(DEV_TTY_PATH))) {
+               tty_sfx = port->name + strlen(DEV_TTY_PATH);
+               DBG("'%s': '%s'\n", DEV_TTY_PATH, tty_sfx);
+
+        } else {
                RETURN_ERROR(SP_ERR_ARG, "Device name not recognized");
        }
 
        /* Native UART enumeration. */
-       if ((cua_sfx[0] == 'u') || (cua_sfx[0] == 'd')) {
+       if ((tty_sfx[0] == 'u') || (tty_sfx[0] == 'd')) {
                port->transport = SP_TRANSPORT_NATIVE;
-               snprintf(tbuf, sizeof(tbuf), "cua%s", cua_sfx);
+               snprintf(tbuf, sizeof(tbuf), "tty%s", tty_sfx);
                port->description = strdup(tbuf);
                RETURN_OK();
        }
@@ -265,8 +223,8 @@ SP_PRIV enum sp_return get_port_details(struct sp_port 
*port)
        /* USB device enumeration. */
        dev = dev_last = NULL;
        be = libusb20_be_alloc_default();
-       cua_dev_found = 0;
-       while (cua_dev_found == 0) {
+       tty_dev_found = 0;
+       while (tty_dev_found == 0) {
                dev = libusb20_be_device_foreach(be, dev_last);
                if (!dev)
                        break;
@@ -291,9 +249,9 @@ SP_PRIV enum sp_return get_port_details(struct sp_port 
*port)
                                                        snprintf(tbuf, 
sizeof(tbuf), "%s", ttyname);
                                                else
                                                        snprintf(tbuf, 
sizeof(tbuf), "%s.%d", ttyname, sub_inst);
-                                               if (!strcmp(cua_sfx, tbuf)) {
-                                                       DBG("MATCH: '%s' == 
'%s'\n", cua_sfx, tbuf);
-                                                       cua_dev_found = 1;
+                                               if (!strcmp(tty_sfx, tbuf)) {
+                                                       DBG("MATCH: '%s' == 
'%s'\n", tty_sfx, tbuf);
+                                                       tty_dev_found = 1;
                                                        
populate_port_struct_from_libusb_desc(port, dev);
                                                        break; /* Break out of 
sub instance loop. */
                                                }
@@ -308,7 +266,7 @@ SP_PRIV enum sp_return get_port_details(struct sp_port 
*port)
                                free(drv_name_str);
                        if (drv_inst_str)
                                free(drv_inst_str);
-                       if (cua_dev_found)
+                       if (tty_dev_found)
                                break; /* Break out of USB device port idx 
loop. */
                }
                libusb20_dev_close(dev);
@@ -316,8 +274,8 @@ SP_PRIV enum sp_return get_port_details(struct sp_port 
*port)
        }
        libusb20_be_free(be);
 
-       if (cua_dev_found == 0)
-               DBG("WARN: Found no match '%s' %s'\n", port->name, cua_sfx);
+       if (tty_dev_found == 0)
+               DBG("WARN: Found no match '%s' %s'\n", port->name, tty_sfx);
 
        RETURN_OK();
 }
@@ -340,9 +298,9 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list)
                ret = SP_OK;
                if (entry.d_type != DT_CHR)
                        continue;
-               if (strncmp(entry.d_name, "cuaU", 4) != 0)
-                       if (strncmp(entry.d_name, "cuau", 4) != 0)
-                               if (strncmp(entry.d_name, "cuad", 4) != 0)
+               if (strncmp(entry.d_name, "ttyU", 4) != 0)
+                       if (strncmp(entry.d_name, "ttyu", 4) != 0)
+                               if (strncmp(entry.d_name, "ttyd", 4) != 0)
                                        continue;
                if (strend(entry.d_name, ".init"))
                        continue;
@@ -352,7 +310,7 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list)
                snprintf(name, sizeof(name), "/dev/%s", entry.d_name);
                DEBUG_FMT("Found device %s", name);
 
-               /* Check that we can open tty/cua device in rw mode - we need 
that. */
+               /* Check that we can open tty device in rw mode - we need that. 
*/
                if ((fd = open(name, O_RDWR | O_NONBLOCK | O_NOCTTY | 
O_TTY_INIT | O_CLOEXEC)) < 0) {
                        DEBUG("Open failed, skipping");
                        continue;
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to