[ECOS] problem with layered drivers

Andrew Lunn andrew@lunn.ch
Tue Nov 7 10:38:00 GMT 2006

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);
      case 0x10:
      case 0x11:
        // Bytes for thread B
        cyg_mbox_put(&thread_B_mbox, c);
        // Hardware has gone crazy!!

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list