Using a SUN to sense an external signal
Robert Cohen
cohen at ecse.rpi.edu
Tue Aug 7 12:31:52 AEST 1990
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 at ecse.rpi.edu
Bob Cohen
Image Processing Laboratory
Rensselaer Polytechnic Instute
Troy, New York 12180
More information about the Comp.sys.sun
mailing list