How to detect a short pulse on a serial port?

How to detect a short pulse on a serial port?

Post by Per Espen Hage » Thu, 02 Oct 1997 04:00:00


I'm writing a small piece of code to synchronize the clock of my Sun
UltraSparc 1 running Solaris 2.5.1 to a GPS receiver.  The GPS receiver
sends a short ASCII string with a timestamp (every second), and about
0.5 seconds later it sends a very short pulse on another line (CTS/RTS,
I think).  Problem is, how do I make the machine detect the changing
state of the line?  I've tried a quick-and-dirty approach of polling the
line continuously, like this:

   ioctl(link, TIOCMGET, &oldbit);
      ioctl(link, TIOCMGET, &bit);
   while (bit == oldbit);

but this doesn't work very well; the pulse is so short that the program
skips a  pulse every now and then.  Ideally, I would want the system to
send my program a signal when the pulse arrives.  Alternatively, I would
like a flag to be set when the sync line changes state -- and NOT
cleared when the sync line goes low again.  Is there a simple (and
preferably standard) way to do this?  I've looked through lots of
ioctl/termios stuff, but haven't found anything so far.  Can anyone give
me a nudge in the right direction?

(Please answer both by news and mail -- our newsserver is less than 100%



1. What port # is for short accepting short messages?

  Just wondering if anyone knows what port number is used for sending
short messges (if there is one defined). I mean something like "net send
<username> <message>". I wanted to write a similar unix program to do
this. I do know a bit of socket programming. Anyone knows what port # is
'NT's net send' listening to? Thanks.


2. creating users

3. polling a port addres for a clock pulse and reading and writing data to RS422 port

4. Processes killed after boot

5. serial ports not detected

6. Signal 7 error termination

7. Program to detect jammed lpd printer on serial port

8. redhat up2date - ever able to get in?

9. serial port on v490 and Serial port on StorEdge 3510

10. Code to detect serial port activity?

11. Serial port to serial port copying software

12. Auto-detecting IRQ's of serial ports??

13. How to detect DCD on serial port