johnny | 3 Oct 07:09

Help:Serial / Parallel Port Control Under Linux

Hi, 

Right Now I need to write a simple C code to control the serial / parallel
port under linux working like this:
Detect there is an input signal / voltage change and send some output signal
/ voltage accordingly, eg: if DSR is detected to be high, I want to set RTS
to be high as well; if RI is detected to be high, I want DTR set to be low
etc.

I have read the Serial-How to and Serial programming-How to, however I am
still not so clear regarding to this simple programming.

Could anyone direct me some useful references / codes regarding to this
project?

Thanks & Best Regards,
 
Johnny Xing

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Grant Edwards | 3 Oct 16:26
Favicon

Re: Help:Serial / Parallel Port Control Under Linux

On 2008-10-03, johnny <johnny <at> pan-tone.com.sg> wrote:

> Right Now I need to write a simple C code to control the
> serial / parallel port under linux working like this: Detect
> there is an input signal / voltage change and send some output
> signal / voltage accordingly, eg: if DSR is detected to be
> high, I want to set RTS to be high as well; if RI is detected
> to be high, I want DTR set to be low etc.
>
> I have read the Serial-How to and Serial programming-How to,
> however I am still not so clear regarding to this simple
> programming.

Ignore the serial programming howto.  It's out-of-date,
incomplete, unmaintained and just plain wrong in many areas. I
needs to be gotten rid of, but that doesn't seem to be
possible.

A far better source of information is the Serial Programming
Guide for Posix Operating Systems:

http://www.easysw.com/~mike/serial/serial.html

Specifically, the information about modem control and status
lines is in chapter 5.1:

http://www.easysw.com/~mike/serial/serial.html#5_1

--

-- 
Grant Edwards                   grante             Yow! Inside, I'm already
(Continue reading)

johnny | 6 Oct 10:54

RE: Help:Serial / Parallel Port Control Under Linux

Hi, Grant, 

I have written a simple program based on the POXIS programming guide,
however, it seems that ioctl() function doesn't have a command of
'TIOCMGET'and 'TIOCMSET'.

I am currently using Centos system.

Do you know any other function which could control the serial port pin
status?

Error:

serialIO.c:195: error: `TIOCMGET' undeclared (first use in this function)
serialIO.c:195: error: (Each undeclared identifier is reported only once
serialIO.c:195: error: for each function it appears in.)
serialIO.c:207: error: `TIOCM_CD' undeclared (first use in this function)
serialIO.c:208: error: `TIOCM_CTS' undeclared (first use in this function)
serialIO.c:209: error: `TIOCM_DSR' undeclared (first use in this function)
serialIO.c:210: error: `TIOCM_RI' undeclared (first use in this function)
serialIO.c:212: error: `TIOCM_DTR' undeclared (first use in this function)
serialIO.c:215: error: `TIOCM_RTS' undeclared (first use in this function)
serialIO.c:223: error: `TIOCMSET' undeclared (first use in this function)

-----Original Message-----
From: linux-serial-owner <at> vger.kernel.org
[mailto:linux-serial-owner <at> vger.kernel.org] On Behalf Of Grant Edwards
Sent: 2008年10月3日 22:27
To: linux-serial <at> vger.kernel.org
Subject: Re: Help:Serial / Parallel Port Control Under Linux
(Continue reading)

Andreas Stricker | 6 Oct 11:12
Favicon

Re: Help:Serial / Parallel Port Control Under Linux

johnny schrieb:
> serialIO.c:195: error: `TIOCMGET' undeclared (first use in this function)

Did you include termios.h? (See `man ioctl_list`)

Regards,
Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

johnny | 8 Oct 06:01

RE: Help:Serial / Parallel Port Control Under Linux

I realized that I need to #include iotcl.h as well in order to use TIOCMGET
constant.

If I want to run this small program continuously and detect the changes of
the input pins all the time, can I simply use an infinite loop to do that?
Does it anything wrong to the serial port?

Thanks & Best Regards,

Johnny Xing
-----Original Message-----
From: linux-serial-owner <at> vger.kernel.org
[mailto:linux-serial-owner <at> vger.kernel.org] On Behalf Of Andreas Stricker
Sent: 2008年10月6日 17:13
To: linux-serial <at> vger.kernel.org
Subject: Re: Help:Serial / Parallel Port Control Under Linux

johnny schrieb:
> serialIO.c:195: error: `TIOCMGET' undeclared (first use in this function)

Did you include termios.h? (See `man ioctl_list`)

Regards,
Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
(Continue reading)

Grant Edwards | 8 Oct 12:05
Favicon

Re: Help:Serial / Parallel Port Control Under Linux

On 2008-10-08, johnny <johnny <at> pan-tone.com.sg> wrote:

> If I want to run this small program continuously and detect
> the changes of the input pins all the time, can I simply use
> an infinite loop to do that?

Yes.  Though you may want to sleep a little between polls to
allow other things to run.  Unfortunately, there are no "block
until modem status change" semantics in the Unix tty driver
(one of a number of useful things that the Unix tty driver is
missing).

> Does it anything wrong to the serial port?

No.

--

-- 
Grant

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane