[clug] device driver writing to serial port

David Gibson david at gibson.dropbear.id.au
Fri Mar 5 01:32:25 GMT 2004

On Fri, Mar 05, 2004 at 12:14:49PM +1100, Martin Pool wrote:
> On  4 Mar 2004, <caloykoy_one at pacific.net.ph> wrote:
> > guys i'm really sorry if i only got to mail now. i'm caloy, the one
> > inquiring about device drivers for my project for the rv-m1 robot
> > arm.
> >  
> > may i ask how a device driver can write to the serial port? my
> > device driver needs to access/write data to the serial port, how
> > would i go about that?

Well, I think the best answer is "don't".  As several people have
already said, you really, *really* want to do this in userspace.

> I guess you need to make a kind of loopback connection where your
> "driver" opens the character device provided by the real serial
> driver.  There is a kernel-internal function filp_open that does
> something similar to open(2), which will give you something you can
> read and write.  Grep for that function to see how it is used.
> Having one so-called driver open another seems like bad style and I
> don't know if it would actually work reliably.

If you insist on doing this, the way to do it is using the
serport/serio infrastructure.  Mostly that's used for making unified
input layer drivers for serial joysticks and the like, but it can be
used for other driver-on-top-of-a-serial-port things, too.

> I still think this is a Really Bad Idea.  You could the same work done
> in one tenth the time if you just made a userspace daemon.  Do
> yourself a favour.


David Gibson			| For every complex problem there is a
david AT gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/linux/attachments/20040305/95917152/attachment.bin

More information about the linux mailing list