[En-Nut-Discussion] How to implement a stream
Harald Kipp
harald.kipp at egnite.de
Mon Sep 20 18:09:10 CEST 2004
Hi Ole,
a very short roadmap:
1. Create a NUTDEVICE structure similar to devUsartAvr0
in dev/usart0avr.c.
2. Implement the functions given in NUTDEVICE
dev_init
dev_ioctl
dev_read
dev_write
dev_write_P
dev_open
dev_close
dev_size
similar to the routines found in dev/usart.c. Actually
usart.c is quite complicated, because it is divided into
a framework and a hardware dependent part. dev/debug0.c
is a very simple one, but no input.
Note that dev_open returns a NUTFILE pointer, which is
passed back by stdio, when calling the other functions
of your driver.
3. The rest is easy. The app calls NutRegisterDevice
with a pointer to your NUTDEVICE structure. Then it
calls fopen (or similar) with the name stored in your
NUTDEVICE structure and that's it. You have a stream.
All buffering is done in your driver. To avoid too much
data copying, the stdio functions do not do buffering.
Thus fputc() will call your dev_write on each character,
which may be not optimal for btnode.
Harald
At 17:31 20.09.2004 +0200, you wrote:
>Hi all,
>
>I asked the same question some time ago but nobody could help me until
>now, so I ask again:
>
>Could anybody give me a short description how to implement a stream? I
>have a generator (in my case the l2cap layer of btnode) and would like
>to write the generated characters into a stream.
>
>In other words: I would like to use printf / scanf to send and read data
>over my l2cap connection.
>
>Somthing like:
>
>connect your creator / consumer funktion with the following libc
>function... would help me.
>
>Sincerly,
>
>Ole Reinhardt
>--
>kernel concepts Tel: +49-271-771091-14
>Dreisbachstr. 24 Fax: +49-271-771091-19
>D-57250 Netphen E+ : +49-177-7420433
>--
>
>
>_______________________________________________
>En-Nut-Discussion mailing list
>En-Nut-Discussion at egnite.de
>http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
More information about the En-Nut-Discussion
mailing list