This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with layered drivers


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]