@@ -2,28 +2,30 @@ Configuration
2
2
=============
3
3
4
4
5
+ Usually this library is used with a particular CAN interface, this can be
6
+ specified in code, read from configuration files or environment variables.
7
+
8
+ See :func: `can.util.load_config ` for implementation.
5
9
6
10
In Code
7
11
-------
8
12
9
- The ``can `` object exposes an ``rc `` dictionary which can be used to set the ** interface **
10
- before importing from ``can.interfaces ``.
13
+ The ``can `` object exposes an ``rc `` dictionary which can be used to set
14
+ the ** interface ** and ** channel ** before importing from ``can.interfaces ``.
11
15
12
16
::
13
17
14
18
import can
15
19
can.rc['interface'] = 'socketcan'
20
+ can.rc['channel'] = 'vcan0'
16
21
from can.interfaces.interface import Bus
17
- can_interface = 'vcan0'
18
- bus = Bus(can_interface )
22
+
23
+ bus = Bus()
19
24
20
25
21
26
Configuration File
22
27
------------------
23
28
24
- Usually this library is used with a particular CAN interface, this can be specified in
25
- a configuration file.
26
-
27
29
On Linux systems the config file is searched in the following paths:
28
30
29
31
1. ``/etc/can.conf ``
@@ -43,3 +45,35 @@ The configuration file sets the default interface and channel:
43
45
interface = <the name of the interface to use>
44
46
channel = <the channel to use by default>
45
47
48
+
49
+ Environment Variables
50
+ ---------------------
51
+
52
+ Configuration can be pulled from these environmental variables:
53
+
54
+ * CAN_INTERFACE
55
+ * CAN_CHANNEL
56
+
57
+
58
+ Interface Names
59
+ ---------------
60
+
61
+ Lookup table of interface names:
62
+
63
+ +---------------------+-------------------------------------+
64
+ | Name | Documentation |
65
+ +=====================+=====================================+
66
+ | ``"socketcan" `` | :doc: `interfaces/socketcan ` |
67
+ +---------------------+-------------------------------------+
68
+ | ``"kvaser" `` | :doc: `interfaces/kvaser ` |
69
+ +---------------------+-------------------------------------+
70
+ | ``"serial" `` | :doc: `interfaces/serial ` |
71
+ +---------------------+-------------------------------------+
72
+ | ``"ixxat" `` | :doc: `interfaces/ixxat ` |
73
+ +---------------------+-------------------------------------+
74
+ | ``"pcan" `` | :doc: `interfaces/pcan ` |
75
+ +---------------------+-------------------------------------+
76
+ | ``"usb2can" `` | :doc: `interfaces/usb2can ` |
77
+ +---------------------+-------------------------------------+
78
+ | ``"virtual" `` | :doc: `interfaces/virtual ` |
79
+ +---------------------+-------------------------------------+
0 commit comments