* Re: Socketcan correct way to bootup... [not found] <53BD1BE1.8050403@eurekelettronica.it> @ 2014-07-09 11:16 ` Marc Kleine-Budde 2014-07-09 12:29 ` Yegor Yefremov 0 siblings, 1 reply; 5+ messages in thread From: Marc Kleine-Budde @ 2014-07-09 11:16 UTC (permalink / raw) To: gianluca, linux-can@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 1561 bytes --] On 07/09/2014 12:39 PM, gianluca wrote: > 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. > # 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 > > Are there some guidelines on how to approach this startup? i.e. I was > thinking about similar to ifup /etc/network/interface but 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. -- 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 | [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 242 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Socketcan correct way to bootup... 2014-07-09 11:16 ` Socketcan correct way to bootup Marc Kleine-Budde @ 2014-07-09 12:29 ` Yegor Yefremov 2014-07-09 12:36 ` Marc Kleine-Budde 0 siblings, 1 reply; 5+ messages in thread From: Yegor Yefremov @ 2014-07-09 12:29 UTC (permalink / raw) To: Marc Kleine-Budde; +Cc: gianluca, linux-can@vger.kernel.org On Wed, Jul 9, 2014 at 1:16 PM, Marc Kleine-Budde <mkl@pengutronix.de> wrote: > On 07/09/2014 12:39 PM, gianluca wrote: >> 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. > >> # 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 >> >> Are there some guidelines on how to approach this startup? i.e. I was >> thinking about similar to ifup /etc/network/interface but 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. You can also use libsocketcan or libnl to configure CAN interface directly from your application. Yegor ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Socketcan correct way to bootup... 2014-07-09 12:29 ` Yegor Yefremov @ 2014-07-09 12:36 ` Marc Kleine-Budde 2014-07-09 12:44 ` Yegor Yefremov 0 siblings, 1 reply; 5+ messages in thread From: Marc Kleine-Budde @ 2014-07-09 12:36 UTC (permalink / raw) To: Yegor Yefremov; +Cc: gianluca, linux-can@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 890 bytes --] On 07/09/2014 02:29 PM, Yegor Yefremov wrote: >> 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://git.pengutronix.de/?p=tools/libsocketcan.git;a=blob;f=include/libsocketcan.h;h=dc52053b824d1a8976126b043de4ee5d843c1401;hb=0c91940da1c16e01e8220e9fa18c703852ba6d1b http://www.pengutronix.de/software/libsocketcan/download/ Marc -- 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 | [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 242 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Socketcan correct way to bootup... 2014-07-09 12:36 ` Marc Kleine-Budde @ 2014-07-09 12:44 ` Yegor Yefremov 2014-07-09 23:45 ` Oliver Hartkopp 0 siblings, 1 reply; 5+ messages in thread From: Yegor Yefremov @ 2014-07-09 12:44 UTC (permalink / raw) To: Marc Kleine-Budde; +Cc: gianluca, linux-can@vger.kernel.org On Wed, Jul 9, 2014 at 2:36 PM, Marc Kleine-Budde <mkl@pengutronix.de> wrote: > On 07/09/2014 02:29 PM, Yegor Yefremov wrote: >>> 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://git.pengutronix.de/?p=tools/libsocketcan.git;a=blob;f=include/libsocketcan.h;h=dc52053b824d1a8976126b043de4ee5d843c1401;hb=0c91940da1c16e01e8220e9fa18c703852ba6d1b > > http://www.pengutronix.de/software/libsocketcan/download/ 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Socketcan correct way to bootup... 2014-07-09 12:44 ` Yegor Yefremov @ 2014-07-09 23:45 ` Oliver Hartkopp 0 siblings, 0 replies; 5+ messages in thread From: Oliver Hartkopp @ 2014-07-09 23:45 UTC (permalink / raw) To: Yegor Yefremov, Marc Kleine-Budde, gianluca; +Cc: linux-can@vger.kernel.org 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 On 09.07.2014 14:44, Yegor Yefremov wrote: > On Wed, Jul 9, 2014 at 2:36 PM, Marc Kleine-Budde <mkl@pengutronix.de> wrote: >> On 07/09/2014 02:29 PM, Yegor Yefremov wrote: >>>> 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://git.pengutronix.de/?p=tools/libsocketcan.git;a=blob;f=include/libsocketcan.h;h=dc52053b824d1a8976126b043de4ee5d843c1401;hb=0c91940da1c16e01e8220e9fa18c703852ba6d1b >> >> http://www.pengutronix.de/software/libsocketcan/download/ > > 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 majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-09 23:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <53BD1BE1.8050403@eurekelettronica.it>
2014-07-09 11:16 ` Socketcan correct way to bootup Marc Kleine-Budde
2014-07-09 12:29 ` Yegor Yefremov
2014-07-09 12:36 ` Marc Kleine-Budde
2014-07-09 12:44 ` Yegor Yefremov
2014-07-09 23:45 ` Oliver Hartkopp
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).