Skip to content

Commit 2e2f157

Browse files
authored
Documentation update for 4.1.0 (#1434)
* Quick pass through all interface docs * Move plugin and virtual interface docs up * Minor doc spring cleaning * Update readme to include basic installation * Remove (mostly unused) mailing list from the readme * Include TRC section in listener docs * Fix broken links to virtual interfaces * Add to changelog * Refactor api docs * Fix bug in bus example * Doc updates after review
1 parent 2d6e996 commit 2e2f157

38 files changed

+486
-365
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Features
3131
xlFlushReceiveQueue to xldriver (#1387).
3232
* Vector: Raise a CanInitializationError, if the CAN settings can not
3333
be applied according to the arguments of ``VectorBus.__init__`` (#1426).
34+
* Ixxat bus now implements BusState api and detects errors (#1141)
3435

3536
Bug Fixes
3637
---------

README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Library Version Python
6262
------------------------------ -----------
6363
2.x 2.6+, 3.4+
6464
3.x 2.7+, 3.5+
65-
4.x *(currently on develop)* 3.7+
65+
4.x 3.7+
6666
============================== ===========
6767

6868

@@ -74,7 +74,7 @@ Features
7474
- receiving, sending, and periodically sending messages
7575
- normal and extended arbitration IDs
7676
- `CAN FD <https://en.wikipedia.org/wiki/CAN_FD>`__ support
77-
- many different loggers and readers supporting playback: ASC (CANalyzer format), BLF (Binary Logging Format by Vector), CSV, SQLite and Canutils log
77+
- many different loggers and readers supporting playback: ASC (CANalyzer format), BLF (Binary Logging Format by Vector), TRC, CSV, SQLite, and Canutils log
7878
- efficient in-kernel or in-hardware filtering of messages on supported interfaces
7979
- bus configuration reading from a file or from environment variables
8080
- command line tools for working with CAN buses (see the `docs <https://python-can.readthedocs.io/en/stable/scripts.html>`__)
@@ -84,6 +84,8 @@ Features
8484
Example usage
8585
-------------
8686

87+
``pip install python-can``
88+
8789
.. code:: python
8890
8991
# import the library
@@ -117,9 +119,6 @@ Discussion
117119
If you run into bugs, you can file them in our
118120
`issue tracker <https://github.com/hardbyte/python-can/issues>`__ on GitHub.
119121

120-
There is also a `python-can <https://groups.google.com/forum/#!forum/python-can>`__
121-
mailing list for development discussion.
122-
123122
`Stackoverflow <https://stackoverflow.com/questions/tagged/can+python>`__ has several
124123
questions and answers tagged with ``python+can``.
125124

can/interfaces/cantact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
except ImportError:
2121
cantact = None
2222
logger.warning(
23-
"The CANtact module is not installed. Install it using `python -m pip install cantact`"
23+
"The CANtact module is not installed. Install it using `pip install cantact`"
2424
)
2525

2626

can/interfaces/udp_multicast/bus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class UdpMulticastBus(BusABC):
5555
.. warning::
5656
This interface does not make guarantees on reliable delivery and message ordering, and also does not
5757
implement rate limiting or ID arbitration/prioritization under high loads. Please refer to the section
58-
:ref:`other_virtual_interfaces` for more information on this and a comparison to alternatives.
58+
:ref:`virtual_interfaces_doc` for more information on this and a comparison to alternatives.
5959
6060
:param channel: A multicast IPv4 address (in `224.0.0.0/4`) or an IPv6 address (in `ff00::/8`).
6161
This defines which version of IP is used. See

can/interfaces/virtual.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class VirtualBus(BusABC):
5151
.. warning::
5252
This interface guarantees reliable delivery and message ordering, but does *not* implement rate
5353
limiting or ID arbitration/prioritization under high loads. Please refer to the section
54-
:ref:`other_virtual_interfaces` for more information on this and a comparison to alternatives.
54+
:ref:`virtual_interfaces_doc` for more information on this and a comparison to alternatives.
5555
"""
5656

5757
def __init__(

doc/api.rst

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,9 @@ A form of CAN interface is also required.
1717
listeners
1818
asyncio
1919
bcm
20+
errors
2021
bit_timing
22+
utils
2123
internal-api
2224

2325

24-
Utilities
25-
---------
26-
27-
28-
.. autofunction:: can.detect_available_configs
29-
30-
31-
.. _notifier:
32-
33-
Notifier
34-
--------
35-
36-
The Notifier object is used as a message distributor for a bus. Notifier creates a thread to read messages from the bus and distributes them to listeners.
37-
38-
.. autoclass:: can.Notifier
39-
:members:
40-
41-
42-
.. _errors:
43-
44-
Errors
45-
------
46-
47-
.. automodule:: can.exceptions
48-
:members:
49-
:show-inheritance:

doc/bus.rst

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,55 @@
33
Bus
44
---
55

6-
The :class:`~can.BusABC` class, as the name suggests, provides an abstraction of a CAN bus.
7-
The bus provides a wrapper around a physical or virtual CAN Bus.
8-
An interface specific instance of the :class:`~can.BusABC` is created by the :class:`~can.Bus`
9-
class, for example::
6+
The :class:`~can.Bus` provides a wrapper around a physical or virtual CAN Bus.
7+
8+
An interface specific instance is created by instantiating the :class:`~can.Bus`
9+
class with a particular ``interface``, for example::
1010

1111
vector_bus = can.Bus(interface='vector', ...)
1212

13-
That bus is then able to handle the interface specific software/hardware interactions
14-
and implements the :class:`~can.BusABC` API.
13+
The created bus is then able to handle the interface specific software/hardware interactions
14+
while giving the user the same top level API.
1515

1616
A thread safe bus wrapper is also available, see `Thread safe bus`_.
1717

18-
.. autoclass:: can.Bus
19-
:class-doc-from: class
20-
:show-inheritance:
21-
:members:
22-
:inherited-members:
23-
24-
.. autoclass:: can.bus.BusState
25-
:members:
26-
:undoc-members:
27-
2818

2919
Transmitting
3020
''''''''''''
3121

3222
Writing individual messages to the bus is done by calling the :meth:`~can.BusABC.send` method
33-
and passing a :class:`~can.Message` instance. Periodic sending is controlled by the
34-
:ref:`broadcast manager <bcm>`.
23+
and passing a :class:`~can.Message` instance.
24+
25+
.. code-block:: python
26+
:emphasize-lines: 8
27+
28+
with can.Bus() as bus:
29+
msg = can.Message(
30+
arbitration_id=0xC0FFEE,
31+
data=[0, 25, 0, 1, 3, 1, 4, 1],
32+
is_extended_id=True
33+
)
34+
try:
35+
bus.send(msg)
36+
print(f"Message sent on {bus.channel_info}")
37+
except can.CanError:
38+
print("Message NOT sent")
3539
3640
41+
Periodic sending is controlled by the :ref:`broadcast manager <bcm>`.
42+
3743
Receiving
3844
'''''''''
3945

4046
Reading from the bus is achieved by either calling the :meth:`~can.BusABC.recv` method or
4147
by directly iterating over the bus::
4248

43-
for msg in bus:
44-
print(msg.data)
49+
with can.Bus() as bus:
50+
for msg in bus:
51+
print(msg.data)
4552

46-
Alternatively the :class:`~can.Listener` api can be used, which is a list of :class:`~can.Listener`
47-
subclasses that receive notifications when new messages arrive.
53+
Alternatively the :ref:`listeners_doc` api can be used, which is a list of various
54+
:class:`~can.Listener` implementations that receive and handle messages from a :class:`~can.Notifier`.
4855

4956

5057
Filtering
@@ -67,6 +74,20 @@ Example defining two filters, one to pass 11-bit ID ``0x451``, the other to pass
6774
6875
See :meth:`~can.BusABC.set_filters` for the implementation.
6976

77+
Bus API
78+
'''''''
79+
80+
.. autoclass:: can.Bus
81+
:class-doc-from: class
82+
:show-inheritance:
83+
:members:
84+
:inherited-members:
85+
86+
.. autoclass:: can.bus.BusState
87+
:members:
88+
:undoc-members:
89+
90+
7091
Thread safe bus
7192
'''''''''''''''
7293

doc/errors.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _errors:
2+
3+
Error Handling
4+
==============
5+
6+
.. automodule:: can.exceptions
7+
:members:
8+
:show-inheritance:

doc/history.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
History and Roadmap
2-
===================
1+
History
2+
=======
33

44
Background
55
----------

doc/index.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ different hardware devices, and a suite of utilities for sending and receiving
88
messages on a CAN bus.
99

1010
**python-can** runs any where Python runs; from high powered computers
11-
with commercial `CAN to usb` devices right down to low powered devices running
11+
with commercial `CAN to USB` devices right down to low powered devices running
1212
linux such as a BeagleBone or RaspberryPi.
1313

1414
More concretely, some example uses of the library:
1515

16-
- Passively logging what occurs on a CAN bus. For example monitoring a
16+
* Passively logging what occurs on a CAN bus. For example monitoring a
1717
commercial vehicle using its **OBD-II** port.
1818

19-
- Testing of hardware that interacts via CAN. Modules found in
20-
modern cars, motocycles, boats, and even wheelchairs have had components tested
19+
* Testing of hardware that interacts via CAN. Modules found in
20+
modern cars, motorcycles, boats, and even wheelchairs have had components tested
2121
from Python using this library.
2222

23-
- Prototyping new hardware modules or software algorithms in-the-loop. Easily
23+
* Prototyping new hardware modules or software algorithms in-the-loop. Easily
2424
interact with an existing bus.
2525

26-
- Creating virtual modules to prototype CAN bus communication.
26+
* Creating virtual modules to prototype CAN bus communication.
2727

2828

2929
Brief example of the library in action: connecting to a CAN bus, creating and sending a message:
@@ -37,12 +37,14 @@ Brief example of the library in action: connecting to a CAN bus, creating and se
3737
Contents:
3838

3939
.. toctree::
40-
:maxdepth: 2
40+
:maxdepth: 1
4141

4242
installation
4343
configuration
4444
api
4545
interfaces
46+
virtual-interfaces
47+
plugin-interface
4648
scripts
4749
development
4850
history

0 commit comments

Comments
 (0)