0

I have a serial port ttyUSB0, and open it with NONBLOCK.

fd = open(args_info.dev_arg, O_RDWR | O_NONBLOCK);

use read will immediate return, everything is ok. But when use libev

ev_io_init(&serial->recv_ctx->io, serial_recv_cb, fd, EV_READ);

serial_recv_cb will block until 100bytes. if data length less than 100bytes, serial_recv_cb will never be called.

[root@jane client]# ./tcptrans --dev /dev/ttyUSB0 -d 7 --nic wlp2s0
serial.c +163 serial_recv_cb(): DEBUG: fd: 5, size: 100
serial.c +163 serial_recv_cb(): DEBUG: fd: 5, size: 100

I think serial_recv_cb will be called immediate. Why libev will block ?

jianxi sun
  • 340
  • 1
  • 19

1 Answers1

0

termios have VMIN and VTIME.My VMIN set 100 and VTIME is 0. so will wait until 100bytes.

jianxi sun
  • 340
  • 1
  • 19