Hi, all
I'm a beginner with QEMU. I'm trying to write a CAN device and also a
backend.

However while I try to write a backend receiving routine, some thing
confuse me. I hope I can get some help here.

Actually, I try to figure out how backend udp works at first, also a serial
pci acts as a frontend. The functions qemu_set_fd_handler2() and
qemu_chr_add_handlers() are used for backend udp and frontend serial pci
seperatly to register the necessary routines. In the function
main_loop_wait() in main-loop.c will check whether we need to receive some
data, if needed, data will be read from backend.

Following is the question. I change serial_can_receive1()-hw/serial.c which
is registered to test if we need data to return 1 always. So that means we
always need data. In main_loop_wait() which actually call
main_loop_wait()->os_host_main_loop_wait()->select(), I have checked that
before select() called the udp file descriptor has set in rfds. So, if we
send some data to the udp backend, the bit in rfds should be set and
finally the receive routine we register though qemu_chr_add_handlers()
should be called. However, the receiving routine has never been called. I
do not know why?

And then I try to start QEMU with the following commands,
       -serial none  -chardev udp,id=UDPserial,port=3334 -device
pci-serial,chardev=UDPserial
and connect it with "nc -u -l -p 3334". Before I insert the linux driver, I
try to send some data to qemu, the receiving routine still never be called.
After the driver has been inserted, input command "echo test>/dev/ttyS0"
then the receiving routine is called. Why? When input "cat /dev/ttyS0" and
input some characters in host, the receiving routine is also called. I
think this is correct.

So what is the correct routine to receive some data from backend? How does
this work?

Can anyone help me with that. I will appreciate it very much.

Thanks,
Jin Yang

Reply via email to