New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Patch] linux: serial backend find too many ports #1562

Closed
michaelrsweet opened this Issue Apr 14, 2006 · 2 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Collaborator

michaelrsweet commented Apr 14, 2006

Version: 1.2rc2
CUPS.org User: cryptic

When called without arguments, the serial backend on linux lists all potential serial ports instead of all present serial ports. Many of those ports do not correspond to actual hardware.

This happens because under Linux additional serial port hardware is setup using the device node. So this node needs to be present for any potential port, and serial finds it and lists it.

I fixed this by using an (Linux-specific) ioctl to check whether the serial port was setup, and to skip it if it is not. This only skips ports that are not usable. Ports that do not support the ioctl (i.e. are always setup/present) are listed as before.

Please (feel free to) apply!

Patch is against 1.2rc2

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Apr 14, 2006

CUPS.org User: mike

Fixed in Subversion repository.

I made the code conditional based on the TIOCGSERIAL definition.

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Apr 14, 2006

"cups-serial-backend-linux-12rc2.patch":

--- cups-1.2rc2/backend/serial.c 2006-03-07 23:07:44.000000000 +0100
+++ cups-1.2rc2.new/backend/serial.c 2006-04-13 15:44:03.000000000 +0200
@@ -87,6 +87,10 @@

include <IOKit/IOBSD.h>

#endif /* APPLE */

+#if defined(linux) || defined(linux) || defined(__linux)
+# include <linux/serial.h>
+# include <linux/ioctl.h>
+#endif

/*

  • Local functions...
    @@ -670,13 +674,22 @@
    int i, j; /* Looping vars /
    int fd; /
    File descriptor */

    char device[255]; /* Device filename */

    • struct serial_struct serinfo; /* serial port info */

    for (i = 0; i < 100; i ++)
    {
    sprintf(device, "/dev/ttyS%d", i);
    if ((fd = open(device, O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0)
    {

    •  serinfo.reserved_char[0] = 0; /\* setserial does this as well */
      
    •  if (ioctl(fd, TIOCGSERIAL, &serinfo)!=-1) /\* unsupported ioctl? */
      
    •  {
      
    • if (serinfo.type==PORT_UNKNOWN)
    • {
    • close(fd);
      
    • continue;
      
    • }
    •  }
      
      close(fd);

      if defined(_ARCH_PPC) || defined(powerpc) || defined(__powerpc)

      printf("serial serial:%s?baud=230400 "Unknown" "Serial Port #%d"\n",

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment