This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: problem with layered drivers
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Michele Paselli <miguelon at tiscali dot it>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Tue, 7 Nov 2006 11:35:35 +0100
- Subject: Re: [ECOS] problem with layered drivers
- References: <32843526.1162894594399.JavaMail.root@ps9>
On Tue, Nov 07, 2006 at 11:16:34AM +0100, Michele Paselli wrote:
> Hi Bernard,
> could you please be more precise? Where can I find the open function
> and how can I use that?
> Thanks
He means the normal open(2) function. You can
fd = open("/dev/ser0",O_RDWR);
and then do normal read(2) and write(2) on the file descriptor.
What Barnard is suggesting, is that you have a thread doing the
demultiplexing. So you have something like
void demux(void) {
fd = open("/dev/ser0",O_RDWR);
for (;;) {
read(fd, c, 1);
switch(c) {
case 0x01:
case 0x02:
case 0x03:
// Bytes for thread A
cyg_mbox_put(&thread_A_mbox, c);
break;
case 0x10:
case 0x11:
// Bytes for thread B
cyg_mbox_put(&thread_B_mbox, c);
break;
default:
// Hardware has gone crazy!!
HAL_PLATFORM_RESET();
}
}
}
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss