home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / alt / sys / sun / 3380 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.4 KB  |  58 lines

  1. Path: sparky!uunet!mcsun!uknet!keele!seq1!cca20
  2. From: cca20@keele.ac.uk (J. Atherton)
  3. Newsgroups: alt.sys.sun
  4. Subject: terminal input using select()
  5. Message-ID: <BxM8rs.MLy@gabriel.keele.ac.uk>
  6. Date: 12 Nov 92 18:31:03 GMT
  7. Sender: news@gabriel.keele.ac.uk (UseNet News Service)
  8. Organization: Keele University, England
  9. Lines: 45
  10. Nntp-Posting-Host: seq1.cc.keele.ac.uk
  11. X-Newsreader: TIN [version 1.1 PL6]
  12.  
  13. Greetings,
  14. unfamiliar with UNIX internals.
  15.  
  16. Any suggestions, hints/tips or example code would be wunderful. Thanks
  17. Just in case you are interested......
  18.  
  19. int door;
  20. Any tweaks or example programs etc/etc would be most welcome. All my tweaks have
  21.  
  22.  
  23. int door ;
  24.  
  25. main()
  26. {
  27. int i,x,reed,num,flags,mode,c;
  28. struct sgttyb s, *sarg;
  29. fd_set fdset;
  30. path = "/dev/ttyh1" ;
  31. flags= O_RDWR ;
  32. mode = 7 ;
  33.  
  34. sarg= &s ;
  35. sarg->sg_flags= EVENP | CBREAK ;
  36. sarg->sg_ispeed=B1200;
  37. sarg->sg_ospeed=B1200;
  38.  
  39. if ((door = open(path,flags,mode)) < 0 ) printf("can't open line\n") ;
  40.  
  41. if ( (num = ioctl(door,TIOCSDTR,0)) < 0 ) printf("dtr clear failed\n");
  42. if ( (num = ioctl(door,TIOCSETP,sarg) ) < 0 ) {
  43.     printf("ioctl failed\n");
  44.     printf("error code =%d\n",num);
  45.     printf("error number = %d\n",errno);
  46.     }
  47. if ( (num = fcntl(door,F_SETFL,FNDELAY) ) < 0 ) printf("fn failed\n");
  48. reed = 1 << door ;    /*set up bit mask for select*/
  49.  
  50. }
  51. if ((num=select(32,&reed,NULL,NULL,NULL)) > 0 ) c = read(door,buf2,1);
  52.  
  53. printf("buf= %x\n",buf2);
  54. printf("c= %d, errno = %d\n",c,errno);
  55. }
  56.  
  57. } /* end program */
  58.