On 10/26/2010 03:16 PM, Alexander Stein wrote: > Hello, > > I'm just wondering what's the correct way to change the bitrate. I already > noticed I need to shutdown the can interface previously. So I use system() > with "ip link..." to shutdown, set the new bitrate and restart the interface. > I kept my sockets during bitrate change and the first read() or write() call > return ENETDOWN once. Afterwards those sockets work normally. > So, how can I get rid of this ENETDOWN? Close the sockets on this interface > previously?
Yes. Shuttig down the interface causes all sockets bind()ed to that
interface to get an -ENETDOWN. Either don't bind() to a specific can
interface or close the sockets prior to shutdown and reopen them after.
cheers, Marc
BTW: If you don't want to use that ugly system("ip link ...") call you
can use libsocketcan:
http://www.pengutronix.de/software/libsocketcan/download/
http://git.pengutronix.de/?p=tools/libsocketcan.git;a=blob;f=include/libsocketcan.h
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Socketcan-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-users
