home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sun / hardware / 6383 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.2 KB  |  81 lines

  1. Newsgroups: comp.sys.sun.hardware
  2. Path: sparky!uunet!usc!rpi!batcomputer!cornell!rochester!udel!news.udel.edu!bach.udel.edu!flaregun
  3. From: flaregun@bach.udel.edu (Edwin Phillips)
  4. Subject: Re: Flow control and /dev/ttya serial port
  5. Message-ID: <BzI0pB.991@news.udel.edu>
  6. Keywords: flow,serial,port,communication
  7. Sender: usenet@news.udel.edu
  8. Nntp-Posting-Host: bach.udel.edu
  9. Organization: University of Delaware
  10. References: <BzFCAM.2H8@news.udel.edu>
  11. Distribution: na
  12. Date: Sat, 19 Dec 1992 08:53:34 GMT
  13. Lines: 66
  14.  
  15.   Thanks for all of the responses so far on this...
  16.   I negleted to mention that I also fiddled with the /etc/printcap extensively.
  17. The printcap entry looks like this:
  18.  
  19. DeskJet Plus|lp|prt1:\
  20.     :lp=/dev/ttya:\
  21.     :br#9600:\
  22.     :ms=cs8,-parenb,-clocal,cread,-opost:\
  23.     :sd=/var/spool/lpd-deskjet:\
  24.     :cf=/usr/local/XWP/shbin/wpp:
  25.  
  26.   This is not really used though because I'm not using lpr during testing.
  27. Here's a bit of the code I've used to test with: (I realize it does not
  28. set master.c_cc but I've set them as well during testing).
  29.  
  30.   struct termios master;
  31.  
  32.   lp = open(PRINTER, O_WRONLY | O_NOCTTY);
  33.   if (lp < 0)
  34.   {
  35.     printf("Error opening printer device %s\n", PRINTER);
  36.     return;
  37.   }
  38.  
  39.   master.c_iflag = IGNBRK | IGNPAR | IXON;
  40.   master.c_oflag = OPOST | ONLCR;
  41.   master.c_cflag = B9600 | CS8 | CREAD;
  42.   master.c_lflag = ISIG;
  43.   master.c_line = 0;
  44.  
  45.   noterr = ioctl(lp, TCSETS, &master);
  46.   if (noterr < 0)
  47.   {
  48.     printf("Return code from ioctl() = %d\n\n", noterr);
  49.     perror("ioctl()");
  50.     return;
  51.   }
  52.   printf("termio setup\n");
  53.   checkterm(lp);              /* get the termios for lp and prints out vals */
  54.  
  55.   noterr = 1;
  56.   while (noterr > 0)
  57.   {
  58.     noterr = read(0, buff, BUFF_SIZE);
  59.     if (noterr > 0)
  60.     {
  61.       if (write(lp, buff, noterr) != noterr)
  62.       {
  63.     printf("write() error %d", noterr);
  64.     perror("write()");
  65.     return;
  66.       }
  67.     }
  68.   }
  69.  
  70.   if (noterr < 0)
  71.     perror("read() error");    
  72.   else
  73.     printf("\n\nComplete.\n\n");
  74.   close(lp);
  75.  
  76. -- 
  77. /***************************************************************************/
  78. /* Ed Phillips  flaregun@brahms.udel.edu       University of Delaware      */
  79. /* Jr. Systems Programmer  (302) 831-1129      NSS/Software Systems        */
  80. /***************************************************************************/
  81.