Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!bcm!rice!rice!sun-spots-request From: cohen@ecse.rpi.edu (Robert Cohen) Newsgroups: comp.sys.sun Subject: Using a SUN to sense an external signal Keywords: Hardware Message-ID: <1990Aug9.023001.8123@rice.edu> Date: 7 Aug 90 02:31:52 GMT Sender: sun-spots-request@rice.edu Organization: Sun-Spots Lines: 38 Approved: Sun-Spots@rice.edu Originator: spots@titan.rice.edu X-Sun-Spots-Digest: Volume 9, Issue 297, message 9 I want to interface an external signal to a SUN (4/370, but the same applies to any other SUN), so I am converting this TTL signal to RS232 levels (+/- 9V in this case), and am feeding the signal into pin 8 (Carrier Detect) on serial port ttya. I want a program execute a command immediatly after this signal goes high. So far, the fastest way I've found is to set up ttya using ioctl(), and then executing the following loop: do { ioctl(Fp, TIOCMGET, &i) } while(!(i & TIOCM_CAR)); ... where Fp is the file number returned by opening /dev/ttya using: Fp=open("/dev/ttya", O_RDWR|FNBIO). The commands that need to be executed after pin 8 is asserted appear after this loop. My goal is to have as little delay as possible between the time the line is asserted and the the post-loop code is executed. Here is the problem: This delay is affected by the system load, even if no swapping is occurring. Sometimes this delay is too long for my application. Questions: 1: Is there a faster way to write the above loop? 2: Is there a faster, perhaps different way to sense an external signal? 3: If this delay cannot be made shorter, a long delay is acceptable if it is guaranteed to be almost fixed. Can this type of precision be achieved (+/- 30 microseconds)? Thanks in advance, cohen@ecse.rpi.edu Bob Cohen Image Processing Laboratory Rensselaer Polytechnic Instute Troy, New York 12180