Do you have a question? Post it now! No Registration Necessary
- Linards Ticmanis
August 9, 2006, 1:51 pm

Hello,
is there in Linux any kind of driver (or driver support infrastructure)
for the DCE end of a RS232 - basically, for running Linux inside a
modem-like device and driving its RS232 interface.
This means especially that the DCD (Data Carrier Detect) and RI (Ring
Indicator) lines must be *output* lines settable by software, not input
lines. It would be best if I could simply use the normal tty_ioctl(4)
interface for that.
I know that there's a concept of "gadget drivers" in the Linux-USB
infrastructure, for running Linux in an USB device. Is there such a
thing for RS232 as well? Or will I have to write my own?
Any help appreciated.
is there in Linux any kind of driver (or driver support infrastructure)
for the DCE end of a RS232 - basically, for running Linux inside a
modem-like device and driving its RS232 interface.
This means especially that the DCD (Data Carrier Detect) and RI (Ring
Indicator) lines must be *output* lines settable by software, not input
lines. It would be best if I could simply use the normal tty_ioctl(4)
interface for that.
I know that there's a concept of "gadget drivers" in the Linux-USB
infrastructure, for running Linux in an USB device. Is there such a
thing for RS232 as well? Or will I have to write my own?
Any help appreciated.
--
Linards Ticmanis
Linards Ticmanis

Re: RS232 modem-side driver - does it exist ?

I've been messing around with Linux serial stuff for a lot of
years and I've never come across a driver like that.

You'll have to write your own anyway, since your hardware is
unique, right?
--
Grant Edwards grante Yow! I selected E5... but
at I didn't hear "Sam the Sham
Grant Edwards grante Yow! I selected E5... but
at I didn't hear "Sam the Sham
We've slightly trimmed the long signature. Click to see the full one.

Re: RS232 modem-side driver - does it exist ?
Hello Grant,
Grant Edwards schrieb:

Ok, thanks, saves me a bunch of searching.

Not quite, it's using an Atmel AT91 CPU, which is an ARM with built in
UART (and other stuff); a "normal" (DTE-end) driver for this UART is
already in the standard kernel sources.
Thanks and best wishes,
Grant Edwards schrieb:

Ok, thanks, saves me a bunch of searching.

Not quite, it's using an Atmel AT91 CPU, which is an ARM with built in
UART (and other stuff); a "normal" (DTE-end) driver for this UART is
already in the standard kernel sources.
Thanks and best wishes,
--
Linards Ticmanis
Linards Ticmanis

Re: RS232 modem-side driver - does it exist ?

It shouldn't be difficult to modify that driver to treat RTS
and DTR as inputs and CTS, DCD, DSR, RI as outputs. I don't
think the tty layer cares -- it just passes the bitmasks back
and forth between userspace and the low-level driver.
--
Grant Edwards grante Yow! Of course, you
at UNDERSTAND about the PLAIDS
Grant Edwards grante Yow! Of course, you
at UNDERSTAND about the PLAIDS
We've slightly trimmed the long signature. Click to see the full one.

Re: RS232 modem-side driver - does it exist ?

You're right. It oughtn't, but it does.

There's no excuse not to make the tty layer DCE/DTE agnostic.
The low-level driver's tiocmset() method should be quite
capable of ignoring bits it can't control (and all the ones
I've ever looked at certainly do).
The tty layer is throwing away perfectly good bits for no
reason.
--
Grant Edwards grante Yow! ... I have read the
at INSTRUCTIONS...
Grant Edwards grante Yow! ... I have read the
at INSTRUCTIONS...
We've slightly trimmed the long signature. Click to see the full one.

Re: RS232 modem-side driver - does it exist ?

I guess I would consider it a block of comon low-level code,
and you're right: it assumes it's DTE (e.g. it tries to set set
RTS+DTR on open).
If I were to write a DCE driver, I'd probably not use
serial_core.c. FWIW, there are still serial drivers that don't
use serial_core.c, since it makes some pretty restrictive
assumptions about how the serial interface hardware works.
--
Grant Edwards grante Yow! I'm a nuclear
at submarine under the
Grant Edwards grante Yow! I'm a nuclear
at submarine under the
We've slightly trimmed the long signature. Click to see the full one.

Re: RS232 modem-side driver - does it exist ?

BTW.:
In this directory I see this file and several files for different
hardware setups.
In /drivers/char there is rtc.c. This seems to be just for the PC based
clock chip but not usable for (e.g.) ARM (as it e.g. uses "CMOS_WRITE"
and friends). How can it be "legal" that there is no hint in the
directory or file name that this is dedicated for a certain class of
hardware ?
Would it not make sense to use a similar two level method as with
serial_core.c ?
I am investigating this, as I am considering doing a "multiple-timer"
driver that uses the RTC (on PC) or some hardware timer (on ARM) as a
quite fast interrupt source and allows multiple user land processes
(threads) to wait for periodic events with an individually definable
frequency, but with certain (somewhat obscure <g>) mutual synchronizing
features. I'd rater use some low level module to hook the interrupt than
just copy the code from the hardware dependent driver into my module.
-Michael

Re: RS232 modem-side driver - does it exist ?

Since you have already rewired the UART Tx to pin 2 on a 9 pin
D-connector and UART Rx to pin 3, for simplified RS-232 handshaking,
why don't you rewire e.g. the DTR UART bit to DCD D-connector pin and
CTS UART bit to the RI pin on the D-connector. The DSR connector pin
could be driven from the DCE power supply +12 V through a resistor.
The software would have to control the DTR and DCD settings to alter
the DCD and RI lines on the serial card.
However, if full DCE RS-232 handshaking is needed, at least the DTR,
RTS inputs and DSR, CTS, DCD and RI outputs would be needed and it is
unlikely that any ordinary UART would have 2 input and 4 output
programmable control lines.
In practice, you would need to assign a separate (parallel) port on
your micro controller and attach a suitable number of RS-232/TTL and
TTL/RS-232 converters to that port and program the data direction
register. Thus, this port would be separate from the serial port and
could easily be controlled by user mode software.
Paul
Site Timeline
- » How to add a new IDE controller chip driver
- — Next thread in » Embedded Linux
-
- » I2C driver terminology and ARM926EJ (AMBA) questions
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » pemohon
- — The site's Newest Thread. Posted in » Electronics Computer-Aided Design
-