File tree 4 files changed +31
-3
lines changed
4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def pack_filters(can_filters: Optional[typechecking.CanFilters] = None) -> bytes
38
38
return struct .pack (can_filter_fmt , * filter_data )
39
39
40
40
41
- _PATTERN_CAN_INTERFACE = re .compile (r"v ?can\d+" )
41
+ _PATTERN_CAN_INTERFACE = re .compile (r"(sl|v|vx) ?can\d+" )
42
42
43
43
44
44
def find_available_interfaces () -> Iterable [str ]:
Original file line number Diff line number Diff line change @@ -57,6 +57,28 @@ existing ``can0`` interface with a bitrate of 1MB:
57
57
58
58
sudo ip link set can0 up type can bitrate 1000000
59
59
60
+ CAN over Serial / SLCAN
61
+ ~~~~~~~~~~~~~~~~~~~~~~~
62
+
63
+ SLCAN adapters can be used directly via :doc: `/interfaces/slcan `, or
64
+ via :doc: `/interfaces/socketcan ` with some help from the ``slcand `` utility
65
+ which can be found in the `can-utils <https://github.com/linux-can/can-utils >`_ package.
66
+
67
+ To create a socketcan interface for an SLCAN adapter run the following:
68
+
69
+ .. code-block :: bash
70
+
71
+ slcand -f -o -c -s5 /dev/ttyAMA0
72
+ ip link set up slcan0
73
+
74
+ Names of the interfaces created by ``slcand `` match the ``slcan\d+ `` regex.
75
+ If a custom name is required, it can be specified as the last argument. E.g.:
76
+
77
+ .. code-block :: bash
78
+
79
+ slcand -f -o -c -s5 /dev/ttyAMA0 can0
80
+ ip link set up can0
81
+
60
82
.. _socketcan-pcan :
61
83
62
84
PCAN
Original file line number Diff line number Diff line change 5
5
modprobe vcan
6
6
ip link add dev vcan0 type vcan
7
7
ip link set up vcan0 mtu 72
8
+ ip link add dev vxcan0 type vcan
9
+ ip link set up vxcan0 mtu 72
10
+ ip link add dev slcan0 type vcan
11
+ ip link set up slcan0 mtu 72
Original file line number Diff line number Diff line change @@ -31,10 +31,12 @@ def test_find_available_interfaces(self):
31
31
result = list (find_available_interfaces ())
32
32
self .assertGreaterEqual (len (result ), 0 )
33
33
for entry in result :
34
- self .assertRegex (entry , r"v ?can\d+" )
34
+ self .assertRegex (entry , r"(sl|v|vx) ?can\d+" )
35
35
if TEST_INTERFACE_SOCKETCAN :
36
- self .assertGreaterEqual (len (result ), 1 )
36
+ self .assertGreaterEqual (len (result ), 3 )
37
37
self .assertIn ("vcan0" , result )
38
+ self .assertIn ("vxcan0" , result )
39
+ self .assertIn ("slcan0" , result )
38
40
39
41
40
42
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments