Hi all, spent the whole last evening and todays morning trying to get this SocketCAN stuff running with my SLCAN adapter. Here are my experiences and a little description which may help other SLCAN users.
I use an Advantech 686 Embedded PC with a homemade Mictronics- style SLCAN interface connected to the USB. It appears as "ttyUSB0" device. The OS is a Debian 5 "stable" running a "squeeze" kernel 2.6.32.5. The sources of SocketCAN are compiled against this kernel without problems. First of all i searched a way to set the serial baudrate as high as possible (460800Bd or 921600Bd) to get a stable communication on higher CAN bitrates with heavy CAN busload (the SLCAN protocol has a lot of overhead). So until now i did this by hardcoding the serial baudrate into slcand.c. But with my last sync to the svn the code structure changed and i had to find another way. What it did was stty: stty -F /dev/ttyUSB0 921600 line 0 cs8 -onlcr -echo raw min 100 time 2 (these parameters worked for me, on other systems the parameters may vary. I determined working parameters with a screen terminal and then with some console test, e.g.: echo -e -n "v\r" > /dev/ttyUSB0 and cat < /dev/ttyUSB0 in another terminal/screen. So there was no need for a special terminal to install) The next step was to set a dedicated CAN bitrate (S0..8). Until now this was also done with some parameters of slcand ( S6 O -- C ), but this is also omitted with the latest sources. So i tried to use "slcan_attach -o -s6 -c /dev/ttyUSB0" similar to the descrition in the command line help of slcan_attach. IMHO there is an error: the SLCAN interface must be closed to accept a new bitrate code, so the correct command should be "slcan_attach -c -s6 -o /dev/ttyUSB0". Nevertheless i can't get the bitrate changed properly with slcan_attach. The solution was the echo command (to be honest i tried to change the CAN bitrate before determining the working serial parameters): echo -e -n "C\rS6\rO\r" > /dev/ttyUSB0 With this simple command i always got the correct bitrate when changing. To get the SLCAN damon running i used: slcand ttyUSB0 slcan0 To bring the interface up i used: ifconfig slcan0 up So a little script "startslcan" to do all the stuff in sequence could look like this: #! /bin/bash stty -F /dev/ttyUSB0 921600 line 0 cs8 -onlcr -echo raw min 100 time 2 sleep 1 echo -e -n "C\rS6\rO\r" > /dev/ttyUSB0 sleep 1 slcand ttyUSB0 slcan0 sleep 1 ifconfig slcan0 up That worked perfect for me so far. Next i wanted to have this SocketCAN stuff to be setup on system start. Therefore i copied the initscript of my LCD daemon (/etc/init.d/LCDd) to /etc/init.d/SLCANd and modified it to do the described sequence on startup and doing a "ifconfig slcan0 down" and SLCAN daemon killing on shutdown. With the "rcconf" i generated all the runlevel stuff. On the whole this works, but it seems that on startup the initscript is called more than one time and this isn't really considered when calling "stty..." and "echo... > /dev/ttyUSB0" in the initscript. Have to dig deep in that initscripting. But that's another story... :-) Finally i will try to get the interface run with CAN-Festival... Regards, Thorsten _______________________________________________ Socketcan-users mailing list Socketcan-users@lists.berlios.de https://lists.berlios.de/mailman/listinfo/socketcan-users