Changes between Version 65 and Version 66 of Developer/Simulators/QEMU/CANEmulation


Ignore:
Timestamp:
Sep 12, 2013, 1:03:04 PM (6 years ago)
Author:
Jinyang
Comment:

/* Step 3: Build a Basic PCI-CAN device in qemu */

Legend:

Unmodified
Added
Removed
Modified
  • Developer/Simulators/QEMU/CANEmulation

    v65 v66  
    410410   { .name = "CAN",          .open = qemu_chr_open_can },
    411411The qemu_char_open_can() function is used to initialize the backend including analyzing the start options, allocating some memory, opening the SocketCAN device, setting the CAN filter etc.
     412==  Add the start options  ==
     413
     414We should start the backend like "-chrdev can,id=sja1000,port=vcan0". The valid options for backend list in qemu_chardev_opts variable. The argument 'port' is part of them, so we can use it directly or you should add the option you want to the qemu_chardev_opts variable. When qemu started, you can get the value using qemu_opt_get() function.
    412415==  Add writing routine  ==
    413416
     
    429432==  Add reading routine  ==
    430433
    431 
    432 
    433 
     434The reading routine is a little complicate than the writing routine. Because we don't known when we should the CAN message, so we should check the file discriptor all the time. I will simply explain how this works.
     435
     436QEMU use IOhandlder thread to deal with this kind of operation. The main_loop_wait() function in main-loop.c will be always be executed. This actually called main_loop_wait()-main-loop.c => os_host_main_loop_wait()-main-loop.c => select(), which means the system call select() will be called all the time.
    434437
    435438