3 Sllin is TTY discipline enabling you to create LIN Master out of
5 Hardware needed is Hardware UART embedded into the computer + simple
6 voltage level LIN converter.
11 To successfully compile sllin, it is necessary to have source code
12 to Linux kernel actually running on the computer.
20 To use sllin, it is necessary to set sllin TTY discipline to some
21 existing serial device.
23 It is possible to use slightly modified slcan_attach program --
24 particular patch from canutils-patches folder has to be applied.
26 After successful compilation and loading of sllin, patching and
27 compiling of slcan_attach, it is possible to run:
29 $ sudo slcan_attach -w /dev/ttyS0
30 attached tty /dev/ttyS0 to netdevice sllin0
31 Press any key to detach /dev/ttyS0 ...
33 # Run from another terminal
35 [157600.564071] sllin: sllin_kwthread stopped.
36 [157600.572058] netconsole: network logging stopped, interface sllin0 unregistered
37 [157608.437260] sllin: serial line LIN interface driver
38 [157608.437267] sllin: 10 dynamic interface channels.
39 [157608.437271] sllin: Break is generated manually with tiny sleep.
40 [157610.513646] sllin: sllin_open() invoked
41 [157610.519502] sllin: sllin_kwthread started.
43 $ ip link show dev sllin0
44 11: sllin0: <NOARP> mtu 16 qdisc noop state DOWN qlen 10
47 $ sudo ip link set sllin0 up
49 $ sudo ip link set sllin0 up
50 lisovros@pc-lisovy:~/src/lin/pcan_lin/sllin$ ip link show dev sllin0
51 11: sllin0: <NOARP,UP,LOWER_UP> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
54 # state UNKNOWN in this case is considered as wanted
59 Communication with sllin is done by sending different types of CAN
63 Configuration on internal "frame cache".
66 Send LIN header with LIN ID corresponding to can_id in this
70 Send LIN header immediately (with LIN ID corresponding to can_id
71 in this particular CAN frame) followed by LIN response containing
72 same data as this particular CAN frame.
78 # Some outputs might be modified for more comfortable reading
84 make -C /lib/modules/2.6.36.2-00398-g504e6a6-dirty/build M=/h.../sllin modules
85 make[1]: Entering directory `/h.../kernel/build/glab-2.6.36'
86 make -C /h.../kernel/2.6.36 O=/h.../kernel/build/glab-2.6.36/. modules ARCH=i386
87 CC [M] /h.../sllin/sllin.o
88 Building modules, stage 2.
90 LD [M] /h.../sllin/sllin.ko
91 make[1]: Leaving directory `/h.../kernel/build/glab-2.6.36'
93 $ sudo insmod ./sllin.ko
96 [158268.949289] sllin: serial line LIN interface driver
97 [158268.949296] sllin: 10 dynamic interface channels.
98 [158268.949300] sllin: Break is generated manually with tiny sleep.
100 # Run in another terminal
101 $ sudo slcan_attach -w /dev/ttyS0
102 attached tty /dev/ttyS0 to netdevice sllin0
103 Press any key to detach /dev/ttyS0 ...
105 $ sudo ip link set sllin0 up
107 $ ip link show dev sllin0
108 12: sllin0: <NOARP,UP,LOWER_UP> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
111 # Run "candump sllin0" in another terminal
114 # ----- Simple RTR CAN frame -----
115 # Patched version of cangen
116 $ cangen sllin0 -r -I 1 -n 1 -L 0
118 # Output from candump
119 sllin0 1 [0] remote request
122 # First line: RTR sent to sllin0
123 # Second line: Response obtained from LIN bus (there was LIN slave
124 # device on the LIN bus answering to LIN ID 1with data 0x00 0x00).
127 # ----- RX_TIMEOUT -----
128 $ cangen sllin0 -r -I 8 -n 1 -L 0
130 # LIN_ERR_RX_TIMEOUT flag set -- nobody answered to our LIN header
132 sllin0 8 [0] remote request
136 # ----- Configure frame cache -----
137 # Configure frame cache to answer on LIN ID = 8
138 $ cangen sllin0 -e -I 0x848 -n 1 -L 2 -D beef
142 # Try RTR CAN frame with ID = 8 again
143 $ cangen sllin0 -r -I 8 -n 1 -L 0
145 # Everything went better than expected
146 sllin0 8 [0] remote request
151 # ----- non-RTR CAN frame -----
152 $ cangen sllin0 -I 7 -n 1 -L 2 -D f00f