tonyrog / can

CAN driver and router
45 stars 20 forks source link

support for nonblocking sockets? #7

Open johnnyhh opened 7 years ago

johnnyhh commented 7 years ago

We've been using can_sock_drv.erl in a context where the can network can become disconnected, which causes the write() call in can_sock_drv.c to block before we can restart the interface after detecting a BUS_OFF error frame. Adding the O_NONBLOCK flag to the socket in can_sock_drv_start fixes this issue. Saw some EAGAINs in the code, so it seems like at some point you considered using nonblocking sockets? Did you come across any problems with implementing nonblocking sockets that stopped you from using them?

tonyrog commented 7 years ago

Hi! I think the part of the code is from regular sockets that was nonblocking and when the code was adopted to CAN sockets I assumed that blocking was not an issue. But I am happy to accept a pull request. Thanks.

tonyrog commented 7 years ago

Ping?