🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.sys5.r3
3 messages
3 total messages Started by eric Tue, 22 Nov 1994 19:55
HELP! Controlling RS232 ports in C
#96
Author: eric
Date: Tue, 22 Nov 1994 19:55
23 lines
1878 bytes
...After RTFM'ing to no avail, I can only hope someone out here 
has done this or knows how it's done...

We're writing a server that handles a cluster of serial ports under 
SCO (System V release 3.2-based Unix) and we need to know how to
detect loss of carrier on the ports.  
According to the manuals, this is generally done by making a serial
port the controlling terminal,
	newgid=setgid();
	open("/dev/ttyport",O_RDWR) etc...
..then wait for the hangup signal to indicate that the carrier has 
been dropped.   This is fine if you only have one serial port, but
if you have 10, and need to know exactly when CD goes down, this 
won't work.
	Currently, we have a loop that writes 0 bytes to each port,
and checks the return values for errors, but this appears to be a
problematic kludge at best.  Is there a way under SVR3.2 to 
either be asynchronously notified of port status changes, or to
poll the kernel for serial port status?

Your help will be immensely appreciated.
Eric@dataradio.com
Eric@micro.org
Re: HELP! Controlling RS232 ports in C
#95
Author: Lawrence Kirby
Date: Thu, 01 Dec 1994 21:45
17 lines
1704 bytes
In article <3atibr$h54@ns.RezoNet.NET> eric@dataradio.com  writes:

>        Currently, we have a loop that writes 0 bytes to each port,
>and checks the return values for errors, but this appears to be a
>problematic kludge at best.  Is there a way under SVR3.2 to 
>either be asynchronously notified of port status changes, or to
>poll the kernel for serial port status?

Check out select() and poll() which seem to work fine with serial ports under
SCO (although of course 3rd party serial ports have to support them in their
drivers - most do).

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Re: HELP! Controlling RS232 ports in C
#94
Author: Per Bergqvist
Date: Sun, 11 Dec 1994 18:10
39 lines
2375 bytes
eric@dataradio.com wrote:
>
> We're writing a server that handles a cluster of serial ports under 
> SCO (System V release 3.2-based Unix) and we need to know how to
> detect loss of carrier on the ports.  
> According to the manuals, this is generally done by making a serial
> port the controlling terminal,
> 	newgid=setgid();
> 	open("/dev/ttyport",O_RDWR) etc...
> ...then wait for the hangup signal to indicate that the carrier has 
> been dropped.   This is fine if you only have one serial port, but
> if you have 10, and need to know exactly when CD goes down, this 
> won't work.

I had to build a server like that a couple of months ago myself 
(written under ISC 4.1).

I didn't find any other solution than to fork a child for 
every port I'm controlling and catch SIGHUP. select never
informs you of a CD loss. 

If somebody got a better solution, please let me know.


Anyway, some hints: to receive a SIGHUP the terminal device must be 
the controlling terminal AND the terminal device must support
modem control.

At least under ISC it is not possible to change the CLOCAL bit 
with with an ioctl so you have to use a device that supports 
modem control (/dev/ttydxx or /dev/acuxxx).

If you are using a serial port expansion box of some kind you 
are probably also using a non-standard asy device driver.

Check with your docs what devices names to use for modem control
and hope that it is actually implemented.

/Per
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads