Socketcan correct way to bootup...
A message that is not in the archive (sent off-list or not yet received): [email protected]
Marc Kleine-Budde
maintainerQuoted 3 lines · gianluca
I was wondering if there is some "Offical" way to bring-up a socketcan interface during bootup of a Linux System. Actually I write a simple script BEFORE running my application in this way:
Depends on your Distribution/init system.
Quoted 15 lines
# run.sh 125000 75 can0[
run.sh]
#!/bin/sh
BITRATE=$1
SAMPLE=".$2"
INTERFACE=$3
ip link set $INTERFACE up type can bitrate ${BITRATE} sample-point ${SAMPLE}
ip -details link show $INTERFACE
while [ true ];
do
./myapplication
done
Quoted 3 lines
Are there some guidelines on how to approach this startup? i.e. I was thinking about similar to ifup
/etc/network/interfacebut with the addendum of the bitrate and sample point...
On recent Debian based Distris you can use ifup/ifdown for CAN interfaces. See the man page of interfaces.
If you use busybox's ifup/ifdown you can fall back to the "inet manual" mode and specify /sbin/ip commands to configure and up/down your interface. On systemd you can add a service that starts CAN and runs before your actual program.
Marc
BTW: you probably want to integrate your application into the automatic startup via an init script or in new designs with systemd...and _not_ start it by hand.
Signature · 4 lines
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 |
Quoted 34 lines · Marc Kleine-Budde
Quoted 3 lines · gianluca
I was wondering if there is some "Offical" way to bring-up a socketcan interface during bootup of a Linux System. Actually I write a simple script BEFORE running my application in this way:
Depends on your Distribution/init system.
Quoted 15 lines
# run.sh 125000 75 can0[
run.sh]
#!/bin/sh
BITRATE=$1
SAMPLE=".$2"
INTERFACE=$3
ip link set $INTERFACE up type can bitrate ${BITRATE} sample-point ${SAMPLE}
ip -details link show $INTERFACE
while [ true ];
do
./myapplication
doneQuoted 3 lines
Are there some guidelines on how to approach this startup? i.e. I was thinking about similar to ifup
/etc/network/interfacebut with the addendum of the bitrate and sample point...On recent Debian based Distris you can use ifup/ifdown for CAN interfaces. See the man page of interfaces.
If you use busybox's ifup/ifdown you can fall back to the "inet manual" mode and specify
/sbin/ipcommands to configure and up/down your interface. On systemd you can add a service that starts CAN and runs before your actual program.
Quoted 5 lines
Marc
BTW: you probably want to integrate your application into the automatic startup via an init script or in new designs with systemd...and _not_ start it by hand.
You can also use libsocketcan or libnl to configure CAN interface directly from your application.
Yegor
Marc Kleine-Budde
maintainerQuoted 6 lines · Yegor Yefremov
Quoted 3 lines
BTW: you probably want to integrate your application into the automatic startup via an init script or in new designs with systemd...and _not_ start it by hand.
You can also use libsocketcan or libnl to configure CAN interface directly from your application.
Good point.
here's libsocketcan's API:
http://www.pengutronix.de/software/libsocketcan/download/
Marc
Signature · 4 lines
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 |
Quoted 8 lines · Marc Kleine-Budde
Quoted 6 lines · Yegor Yefremov
Quoted 3 lines
BTW: you probably want to integrate your application into the automatic startup via an init script or in new designs with systemd...and _not_ start it by hand.
You can also use libsocketcan or libnl to configure CAN interface directly from your application.
Quoted 7 lines
Good point.
here's libsocketcan's API:
If you're using Buildroot (http://buildroot.uclibc.org/) or OpenWrt
(https://openwrt.org/) you'll find libsocketcan already being integrated into their repositories. I don't know about OpenEmbedded universe.
Yegor
For Debian systems I use this script:
https://gitorious.org/linux-can/can-misc/source/etc/can_if
Just copy can_if to /etc/init.d and say
update-rc.d can_if defaults
Btw. Debian changed to systemd. So far this script still run's with the latest Debian unstable (which used systemd).
Regards,
Oliver
Quoted 28 lines · Yegor Yefremov
Quoted 8 lines · Marc Kleine-Budde
Quoted 6 lines · Yegor Yefremov
Quoted 3 lines
BTW: you probably want to integrate your application into the automatic startup via an init script or in new designs with systemd...and _not_ start it by hand.
You can also use libsocketcan or libnl to configure CAN interface directly from your application.
Quoted 7 lines
Good point.
here's libsocketcan's API:
If you're using Buildroot (http://buildroot.uclibc.org/) or OpenWrt
(https://openwrt.org/) you'll find libsocketcan already being integrated into their repositories. I don't know about OpenEmbedded universe.Yegor
--
To unsubscribe from this list: send the line "unsubscribe linux-can" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html