Am 14.05.2007 15:00 schrieb Lars K.W. Gohlke: > after searching the mailing list and searching the web, I still don't > know how to access correctly the serial port (in user space known as > /dev/ttyS01) I can only tell you how I did it in the special case of the ser_gigaset driver which drives an ISDN device attached to a serial port: I implemented it as a line discipline which is associated to the appropriate serial port by a userspace daemon. Reading material: Documentation/tty.txt documentation on the line discipline interface include/linux/tty.h include/linux/tty_ldisc.h definitions for same drivers/isdn/gigaset/ser-gigaset.c my code - a simple example of abusing the line discipline interface for your own ends :-) > would somebody be so kind to give me an example: I hope the following will help you some. If not, feel free to ask again. > with this behaviour: > > 1. read from port That's not how things work in the kernel. There is no system call for reading some data that has arrived on that port or blocking if there is none, like a userspace program would do. Instead, when you register your line discipline you provide a callback function (receive_buf) for the serial driver to call when data has been received. That function can be called at any time and has to deal with the data as it gets it. > 2. output via printk() You can of course put a printk() in your receive_buf function. But ultimately you'll want to do more than that with the data, I'm sure. > 3. write to port That's easy. :-) No, it isn't. The serial driver *does* provide a function (aptly called "write") for sending data to the serial port, but you can't just call it any time you like. You have to synchronize with the driver by waiting for it to call your "write_wakeup" callback before you can call its write function again. HTH T. -- Tilman Schmidt E-Mail: [email protected] Bonn, Germany Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
Attachment:
signature.asc
Description: OpenPGP digital signature
- Follow-Ups:
- Re: How to access correctly serial port inside module?
- From: "Lars K.W. Gohlke" <[email protected]>
- Re: How to access correctly serial port inside module?
- References:
- How to access correctly serial port inside module?
- From: "Lars K.W. Gohlke" <[email protected]>
- How to access correctly serial port inside module?
- Prev by Date: Re: [VOYAGER] fix build broken by shift to smp_ops
- Next by Date: Re: [RFC][PATCH 5/14] Introduce union stack
- Previous by thread: Re: How to access correctly serial port inside module?
- Next by thread: Re: How to access correctly serial port inside module?
- Index(es):