Skip to content

Commit 51eae1c

Browse files
committed
added "Creating a new interface/backend" section to the documentation pages
1 parent e1e6931 commit 51eae1c

2 files changed

Lines changed: 53 additions & 33 deletions

File tree

can/bus.py

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,6 @@
2222
class BusABC(object):
2323
"""The CAN Bus Abstract Base Class that serves as the basis
2424
for all concrete interfaces.
25-
26-
Concrete implementations *have to* implement the following:
27-
* :meth:`~can.BusABC.send` to send individual messages
28-
* :meth:`~can.BusABC._recv_internal` to receive individual messages
29-
(see note below)
30-
* set the :attr:`~can.BusABC.channel_info` attribute to a string describing
31-
the underlying bus and/or channel
32-
33-
They *might* implement the following:
34-
* :meth:`~can.BusABC.flush_tx_buffer` to allow discrading any
35-
messages yet to be sent
36-
* :meth:`~can.BusABC.shutdown` to override how the bus should
37-
shut down
38-
* :meth:`~can.BusABC.send_periodic` to override the software based
39-
periodic sending and push it down to the kernel or hardware
40-
* :meth:`~can.BusABC._apply_filters` to apply efficient filters
41-
to lower level systems like the OS kernel or hardware
42-
* :meth:`~can.BusABC._detect_available_configs` to allow the interface
43-
to report which configurations are currently available for new
44-
connections
45-
* :meth:`~can.BusABC.state` property to allow reading and/or changing
46-
the bus state
47-
48-
.. note::
49-
50-
Previously, concrete bus classes had to override :meth:`~can.BusABC.recv`
51-
directly instead of :meth:`~can.BusABC._recv_internal`, but that has
52-
changed to allow the abstract base class to handle in-software message
53-
filtering as a fallback. Older (custom) interfaces might still be
54-
implemented like that and thus might not provide message filtering.
55-
5625
"""
5726

5827
#: a string describing the underlying bus and/or channel
@@ -150,7 +119,9 @@ def _recv_internal(self, timeout):
150119
over time for some interfaces, like for example in the Kvaser interface.
151120
Thus it cannot be simplified to a constant value.
152121
153-
:param float timeout: seconds to wait for a message
122+
:param float timeout: seconds to wait for a message,
123+
see :meth:`can.BusABC.send`
124+
154125
:rtype: tuple[can.Message, bool] or tuple[None, bool]
155126
:return:
156127
1. a message that was read or None on timeout

doc/development.rst

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,55 @@ The following assumes that the commands are executed from the root of the reposi
2727
makes Sphinx complain about more subtle problems.
2828

2929

30+
Creating a new interface/backend
31+
--------------------------------
32+
33+
These steps are a guideline on how to add a new backend to python-can.
34+
35+
- Create a module (either a ``*.py`` or an entire subdirctory depending
36+
on the complexity) inside ``can.interfaces``
37+
- Implement the central part of the backend: the bus class that extends
38+
:class:`can.BusABC`. See below for more info on this one!
39+
- Register your backend bus class in ``can.interface.BACKENDS`` and
40+
``can.interfaces.VALID_INTERFACES``.
41+
- Add docs where appropiate, like in ``doc/interfaces.rst`` and add
42+
an entry in ``doc/interface/*``.
43+
- Add tests in ``test/*`` where appropiate.
44+
45+
About the ``BusABC`` class
46+
==========================
47+
48+
Concrete implementations *have to* implement the following:
49+
* :meth:`~can.BusABC.send` to send individual messages
50+
* :meth:`~can.BusABC._recv_internal` to receive individual messages
51+
(see note below)
52+
* set the :attr:`~can.BusABC.channel_info` attribute to a string describing
53+
the underlying bus and/or channel
54+
55+
They *might* implement the following:
56+
* :meth:`~can.BusABC.flush_tx_buffer` to allow discrading any
57+
messages yet to be sent
58+
* :meth:`~can.BusABC.shutdown` to override how the bus should
59+
shut down
60+
* :meth:`~can.BusABC.send_periodic` to override the software based
61+
periodic sending and push it down to the kernel or hardware
62+
* :meth:`~can.BusABC._apply_filters` to apply efficient filters
63+
to lower level systems like the OS kernel or hardware
64+
* :meth:`~can.BusABC._detect_available_configs` to allow the interface
65+
to report which configurations are currently available for new
66+
connections
67+
* :meth:`~can.BusABC.state` property to allow reading and/or changing
68+
the bus state
69+
70+
.. note::
71+
72+
Previously, concrete bus classes had to override :meth:`~can.BusABC.recv`
73+
directly instead of :meth:`~can.BusABC._recv_internal`, but that has
74+
changed to allow the abstract base class to handle in-software message
75+
filtering as a fallback. Older (custom) interfaces might still be
76+
implemented like that and thus might not provide message filtering.
77+
78+
3079
Creating a Release
3180
------------------
3281

@@ -41,7 +90,7 @@ Creating a Release
4190
- Upload with twine ``twine upload dist/python-can-X.Y.Z*``
4291
- In a new virtual env check that the package can be installed with pip: ``pip install python-can==X.Y.Z``
4392
- Create a new tag in the repository.
44-
- Check the release on PyPi, readthedocs and github.
93+
- Check the release on PyPi, Read the Docs and GitHub.
4594

4695

4796
Code Structure

0 commit comments

Comments
 (0)