]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The serial backend didn't support the flow control options.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 10 Nov 2000 15:53:39 +0000 (15:53 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 10 Nov 2000 15:53:39 +0000 (15:53 +0000)
Added support for DTR/DSR flow control in the serial backend (primarily
for dot-matrix printers)

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@1436 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES.txt
backend/serial.c

index 7e809b706da472c2d4fea827646c6132c32bfb21..85e9af1c64e8dd23e28bbf4ca58b74a748de1fbf 100644 (file)
@@ -80,19 +80,27 @@ CHANGES IN CUPS V1.1.5
        - The mimeLoadType() function didn't handle the
           3-argument contains() function.
        - The LoadPPDs() function in the scheduler didn't
-         properly set the alloc_ppds variable or handle
-         a PPD database containing 0 printers.
-       - The scheduler FindAvailablePrinter() function
-         didn't use the same queuing logic as the
-         CheckJobs() function.  This caused classes to
-         stall if a remote printer was always busy.
+         properly set the alloc_ppds variable or handle a PPD
+         database containing 0 printers.
+       - The scheduler FindAvailablePrinter() function didn't
+         use the same queuing logic as the CheckJobs()
+         function.  This caused classes to stall if a remote
+         printer was always busy.
        - Jobs are now assigned to printers in a class
-         round-robin style.  This should prevent the
-         first server in the class from bearing the
-         brunt of the jobs.
-       - The scheduler's LoadAllJobs() function didn't
-         always restore remote printers for queued jobs
-         on startup.
+         round-robin style.  This should prevent the first
+         server in the class from bearing the brunt of the
+         jobs.
+       - The scheduler's LoadAllJobs() function didn't always
+         restore remote printers for queued jobs on startup.
+       - The serial backend didn't support the higher baud
+         rates with the old termios interface. It now supports
+         57600 and 115200 baud.
+       - The serial backend now supports different types of
+         flow control; previously it ignored the flow=XYZ
+         option in the device URI.
+       - The serial backend now supports DTR/DSR flow control,
+         which is popular on dot-matrix printers (access with
+         "flow=dtrdsr" in the device URI)
 
 
 CHANGES IN CUPS v1.1.4
index a17c469d5c788f5e7ec2815835ee4c6d787011a6..bf5a8fcd5f80667c9944f1da5c2267268d07cb13 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: serial.c,v 1.19 2000/10/13 01:04:36 mike Exp $"
+ * "$Id: serial.c,v 1.20 2000/11/10 15:53:39 mike Exp $"
  *
  *   Serial port backend for the Common UNIX Printing System (CUPS).
  *
 #  endif /* !INV_EPP_ECP_PLP */
 #endif /* __sgi */
 
+#ifndef CRTSCTS
+#  ifdef CNEW_RTSCTS
+#    define CRTSCTS CNEW_RTSCTS
+#  else
+#    define CRTSCTS 0
+#  endif /* CNEW_RTSCTS */
+#endif /* !CRTSCTS */
+
 
 /*
  * Local functions...
@@ -92,6 +100,8 @@ main(int  argc,              /* I - Number of command-line arguments (6 or 7) */
   int          wbytes;         /* Number of bytes written */
   size_t       nbytes,         /* Number of bytes read */
                tbytes;         /* Total number of bytes written */
+  int          dtrdsr;         /* Do dtr/dsr flow control? */
+  int          bufsize;        /* Size of output buffer for writes */
   char         buffer[8192],   /* Output buffer */
                *bufptr;        /* Pointer into buffer */
   struct termios opts;         /* Parallel port options */
@@ -186,6 +196,9 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
 
   opts.c_lflag &= ~(ICANON | ECHO | ISIG);     /* Raw mode */
 
+  bufsize = 480;       /* 9600 baud / 10 bits/char / 2Hz */
+  dtrdsr  = 0;         /* No dtr/dsr flow control */
+
   if (options != NULL)
     while (*options)
     {
@@ -225,6 +238,8 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
         * Set the baud rate...
        */
 
+        bufsize = atoi(value) / 20;
+
 #if B19200 == 19200
         cfsetispeed(&opts, atoi(value));
        cfsetospeed(&opts, atoi(value));
@@ -255,6 +270,18 @@ main(int  argc,            /* I - Number of command-line arguments (6 or 7) */
              cfsetispeed(&opts, B38400);
              cfsetospeed(&opts, B38400);
              break;
+#ifdef B57600
+         case 57600 :
+             cfsetispeed(&opts, B57600);
+             cfsetospeed(&opts, B57600);
+             break;
+#endif /* B57600 */
+#ifdef B115200
+         case 115200 :
+             cfsetispeed(&opts, B115200);
+             cfsetospeed(&opts, B115200);
+             break;
+#endif /* B115200 */
           default :
              fprintf(stderr, "WARNING: Unsupported baud rate %s!\n", value);
              break;
@@ -301,6 +328,36 @@ main(int  argc,            /* I - Number of command-line arguments (6 or 7) */
        else if (strcasecmp(value, "none") == 0)
          opts.c_cflag &= ~PARENB;
       }
+      else if (strcasecmp(name, "flow") == 0)
+      {
+       /*
+       * Set flow control...
+       */
+
+       if (strcasecmp(value, "none") == 0)
+       {
+         opts.c_iflag &= ~(IXON | IXOFF | IXANY);
+          opts.c_cflag &= ~CRTSCTS;
+       }
+       else if (strcasecmp(value, "soft") == 0)
+       {
+         opts.c_iflag |= IXON | IXOFF | IXANY;
+          opts.c_cflag &= ~CRTSCTS;
+       }
+       else if (strcasecmp(value, "hard") == 0 ||
+                strcasecmp(value, "rtscts") == 0)
+        {
+         opts.c_iflag &= ~(IXON | IXOFF | IXANY);
+          opts.c_cflag |= CRTSCTS;
+       }
+       else if (strcasecmp(value, "dtrdsr") == 0)
+       {
+         opts.c_iflag &= ~(IXON | IXOFF | IXANY);
+          opts.c_cflag &= ~CRTSCTS;
+
+         dtrdsr = 1;
+       }
+      }
     }
 
   tcsetattr(fd, TCSANOW, &opts);
@@ -327,6 +384,9 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
   * Finally, send the print file...
   */
 
+  if (bufsize > sizeof(buffer))
+    bufsize = sizeof(buffer);
+
   while (copies > 0)
   {
     copies --;
@@ -337,8 +397,38 @@ main(int  argc,            /* I - Number of command-line arguments (6 or 7) */
       rewind(fp);
     }
 
+    if (dtrdsr)
+    {
+     /*
+      * Check the port and sleep until DSR is set...
+      */
+
+      int status;
+
+
+      if (!ioctl(fd, TIOCMGET, &status))
+        if (!(status & TIOCM_DSR))
+       {
+        /*
+         * Wait for DSR to go high...
+         */
+
+         fputs("DEBUG: DSR is low; waiting for device...\n", stderr);
+
+          do
+         {
+           sleep(1);
+           if (ioctl(fd, TIOCMGET, &status))
+             break;
+         }
+         while (!(status & TIOCM_DSR));
+
+         fputs("DEBUG: DSR is high; writing to device...\n", stderr);
+        }
+    }
+
     tbytes = 0;
-    while ((nbytes = fread(buffer, 1, sizeof(buffer), fp)) > 0)
+    while ((nbytes = fread(buffer, 1, bufsize, fp)) > 0)
     {
      /*
       * Write the print data to the printer...
@@ -703,5 +793,5 @@ list_devices(void)
 
 
 /*
- * End of "$Id: serial.c,v 1.19 2000/10/13 01:04:36 mike Exp $".
+ * End of "$Id: serial.c,v 1.20 2000/11/10 15:53:39 mike Exp $".
  */