Skip to content

Commit d66fe91

Browse files
committed
Documenting configuration
1 parent fd91477 commit d66fe91

File tree

5 files changed

+79
-48
lines changed

5 files changed

+79
-48
lines changed

can/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def load_config(path=None):
9797
The returned dictionary may look like this::
9898
9999
{
100-
'interface': '<python-can backend interface to use',
100+
'interface': 'python-can backend interface to use',
101101
'channel': 'default channel to use',
102102
}
103103
@@ -116,6 +116,7 @@ def load_config(path=None):
116116

117117
return config
118118

119+
119120
def choose_socketcan_implementation():
120121
"""Set the best version of SocketCAN for this system.
121122

doc/api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ A form of CAN interface is also required.
1818
bcm
1919

2020

21+
22+
Utilities
23+
---------
24+
25+
.. automodule:: can.util
26+
:members:
27+
28+
2129
.. _notifier:
2230

2331
Notifier

doc/conf.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
# python-can documentation build configuration file
44
#
55
# This file is execfile()d with the current directory set to its containing dir.
6-
#
7-
# Note that not all possible configuration values are present in this
8-
# autogenerated file.
9-
#
10-
# All configuration values have a default; values that are commented out
11-
# serve to show the default.
126

137
import sys
148
import os
159

10+
# General information about the project.
11+
project = u'python-can'
12+
13+
# The version info for the project you're documenting, acts as replacement for
14+
# |version| and |release|, also used in various other places throughout the
15+
# built documents.
16+
#
17+
# The short X.Y version.
18+
version = '1.5'
19+
# The full version, including alpha/beta/rc tags.
20+
release = '1.5.2'
21+
1622
# If extensions (or modules to document with autodoc) are in another directory,
1723
# add these directories to sys.path here. If the directory is relative to the
1824
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -54,19 +60,6 @@
5460
# The master toctree document.
5561
master_doc = 'index'
5662

57-
# General information about the project.
58-
project = u'python-can'
59-
60-
copyright = u'2013 Dynamic Controls'
61-
62-
# The version info for the project you're documenting, acts as replacement for
63-
# |version| and |release|, also used in various other places throughout the
64-
# built documents.
65-
#
66-
# The short X.Y version.
67-
version = '1.5'
68-
# The full version, including alpha/beta/rc tags.
69-
release = '1.5.2'
7063

7164
# The language for content autogenerated by Sphinx. Refer to documentation
7265
# for a list of supported languages.

doc/configuration.rst

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@ Configuration
22
=============
33

44

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.
59

610
In Code
711
-------
812

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``.
1115

1216
::
1317

1418
import can
1519
can.rc['interface'] = 'socketcan'
20+
can.rc['channel'] = 'vcan0'
1621
from can.interfaces.interface import Bus
17-
can_interface = 'vcan0'
18-
bus = Bus(can_interface)
22+
23+
bus = Bus()
1924

2025

2126
Configuration File
2227
------------------
2328

24-
Usually this library is used with a particular CAN interface, this can be specified in
25-
a configuration file.
26-
2729
On Linux systems the config file is searched in the following paths:
2830

2931
1. ``/etc/can.conf``
@@ -43,3 +45,35 @@ The configuration file sets the default interface and channel:
4345
interface = <the name of the interface to use>
4446
channel = <the channel to use by default>
4547

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+
+---------------------+-------------------------------------+

doc/interfaces.rst

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,20 @@ area network adapters in interface dependant modules. However as each hardware
66
device is different, you should carefully go through your interface's
77
documentation.
88

9-
The interfaces currently available are:
10-
11-
+---------------------+-------------------------------------+
12-
| Name | Documentation |
13-
+=====================+=====================================+
14-
| ``"socketcan"`` | :doc:`interfaces/socketcan` |
15-
+---------------------+-------------------------------------+
16-
| ``"kvaser"`` | :doc:`interfaces/kvaser` |
17-
+---------------------+-------------------------------------+
18-
| ``"serial"`` | :doc:`interfaces/serial` |
19-
+---------------------+-------------------------------------+
20-
| ``"ixxat"`` | :doc:`interfaces/ixxat` |
21-
+---------------------+-------------------------------------+
22-
| ``"pcan"`` | :doc:`interfaces/pcan` |
23-
+---------------------+-------------------------------------+
24-
| ``"usb2can"`` | :doc:`interfaces/usb2can` |
25-
+---------------------+-------------------------------------+
26-
| ``"virtual"`` | :doc:`interfaces/virtual` |
27-
+---------------------+-------------------------------------+
28-
29-
The `Interface Name` is used in :doc:`configuration`.
9+
The available interfaces are:
10+
11+
.. toctree::
12+
:maxdepth: 1
13+
14+
interfaces/socketcan
15+
interfaces/kvaser
16+
interfaces/serial
17+
interfaces/ixxat
18+
interfaces/pcan
19+
interfaces/usb2can
20+
interfaces/virtual
21+
22+
23+
24+
The *Interface Names* are listed in :doc:`configuration`.
3025

0 commit comments

Comments
 (0)