Stuart wrote in the following that he doesn't have a way to assign which CAN 
interface the slcan device will be brought up on.  We developed a work around 
for this problem 2 years ago, and have been shipping production code since 
2.6.28 with this patch.  We will resubmit the patch to Oliver.  We take 
advantage of an unused stty flag from teletype days to tell the slcan tty 
driver which device number we want to assign on the open. (by default it uses a 
pseudo round robin assignment, linearly increasing mod 10, but will reuse 
earlier numbers if they are unloaded)
-Steve

Hi Thorsten,

On 2010-04-14 04:31, Thorsten Godau wrote:
> Hi Stuart,
> 
> i am playing around with my TinyCAN-I in SLCAN mode and SocketCAN, but 
> can not get this thing working with SocketCAN.
> The CAN interface works well when i use a dumb terminal to send and 
> receive some frames.
> 
> Can you give me some quick hints how to setup the interface corectly?
> 
> What i do is (and it is based on an old description of Huber Hoegl, 
> who did some experiments with TinyCAN-I and SocketCAN in 2008):
> 
> - load the kernelmodules can, can_raw, can-dev and slcan on boot
>   (i checked this with lsmod, all modules loaded)
> - set up the ttyUSB0 baudrate with "stty -F /dev/ttyUSB0 57600"
> - Attach the interface with "slcan_attach -o -s8 -c /dev/ttyUSB0"
> - Start the daemon with "slcand ttyUSB0"
> - Setup network interface with "ifconfig slc0 up"

        We have the el-cheapo Lawicel AB CANUSB devices... which I note don't 
always function first-go under Windows.  In Linux; with the patch applied to 
the SocketCAN tree... if I manually have to set it up...

# slcand ttyUSB0 S8 O -- C

CANUSB device starts working at this point and a slc0 device is created.
 To bring the interface up in Linux:

# ifconfig slc0 up

Host platform here is Gentoo Linux/MIPS on a Lemote Yeeloong.  I haven't tried 
the patch on i386 yet.  With the patch applied, it is possible for udev to 
handle CANUSB.  This is my /etc/udev/rules.d/99-canusb.rules file:

SUBSYSTEM!="tty", GOTO="canusb_rules_end"

SYSFS{idVendor}=="0403", SYSFS{idProduct}=="ffa8", SUBSYSTEM=="tty", 
KERNEL=="ttyUSB[0-9]*", RUN+="/etc/hotplug/usb/canusb.hotplug"

LABEL="canusb_rules_end"

Then in /etc/hotplug/usb/canusb.hotplug:
#!/bin/sh

if [ "${ACTION}" = "add" ]; then
        sleep 5
        slcand $( basename ${DEVNAME} ) S8 O -- C
        exit $?
elif [ "${ACTION}" = "remove" ]; then
        kill -TERM $(< /var/run/slcand-$( basename ${DEVNAME} ).pid )
        sleep 5
        kill -KILL $(< /var/run/slcand-$( basename ${DEVNAME} ).pid )
        exit $?
fi

        With this arrangement, I can skip the slcand step when bringing the 
interface up.  I can't easily do the `ifconfig slc0 up` step however as I don't 
know which slcX device the unit will appear, otherwise you could add that after 
the slcand call.  (Or you can assume only one device is plugged in.)

        The other interesting note, I can't seem to get slcand to terminate 
gracefully... I have to kill it with a SIGKILL.  This is before I attempt 
unplugging the CANUSB device.  Not sure what the procedure is for cleanly 
shutting down the slcan device before unplugging it... as merely bringing the 
slcX device down does not terminate slcand, and it won't respond to SIGTERM.

Regards,
-- 
Stuart Longland (aka Redhatter, VK4MSL)      .'''.
Gentoo Linux/MIPS Cobalt and Docs Developer  '.'` :
. . . . . . . . . . . . . . . . . . . . . .   .'.'
http://dev.gentoo.org/~redhatter             :.'

I haven't lost my mind...
  ...it's backed up on a tape somewhere.
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users

Reply via email to