- Timestamp:
-
09/12/13 13:03:04 (11 years ago)
- Author:
-
Jinyang
- Comment:
-
/* Step 3: Build a Basic PCI-CAN device in qemu */
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v65
|
v66
|
|
410 | 410 | { .name = "CAN", .open = qemu_chr_open_can }, |
411 | 411 | The 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 | |
| 414 | We 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. |
412 | 415 | == Add writing routine == |
413 | 416 | |
… |
… |
|
429 | 432 | == Add reading routine == |
430 | 433 | |
431 | | |
432 | | |
433 | | |
| 434 | The 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 | |
| 436 | QEMU 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. |
434 | 437 | |
435 | 438 | |