Skip to content

Commit fce32d2

Browse files
authored
Merge branch 'develop' into fix-sphinx-errors
2 parents 691fbcf + 0b7de38 commit fce32d2

72 files changed

Lines changed: 3010 additions & 1832 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.appveyor.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
environment:
2-
32
matrix:
43

54
# For Python versions available on Appveyor, see
65
# http://www.appveyor.com/docs/installed-software#python
76

87
- PYTHON: "C:\\Python27"
9-
- PYTHON: "C:\\Python33"
108
- PYTHON: "C:\\Python34"
119
- PYTHON: "C:\\Python35"
1210
- PYTHON: "C:\\Python36"
1311
- PYTHON: "C:\\Python27-x64"
14-
- PYTHON: "C:\\Python33-x64"
1512
- PYTHON: "C:\\Python34-x64"
1613
- PYTHON: "C:\\Python35-x64"
1714
- PYTHON: "C:\\Python36-x64"
1815

16+
# Python 3.3 has reached EOL
17+
1918
install:
20-
# We need our usual libraries
21-
- "%PYTHON%\\python.exe -m pip install -r requirements.txt"
19+
# Prepend Python installation to PATH
20+
- set PATH=%PYTHON_INSTALL%;%PATH%
21+
22+
# Prepend Python scripts to PATH (e.g. py.test)
23+
- set PATH=%PYTHON_INSTALL%\\Scripts;%PATH%
24+
2225
# We need to install the python-can library itself
23-
- "%PYTHON%\\python.exe -m pip install ."
26+
- "python -m pip install .[test]"
2427

2528
build: off
2629

2730
test_script:
28-
# Note that you must use the environment variable %PYTHON% to refer to
29-
# the interpreter you're using - Appveyor does not do anything special
30-
# to put the Python version you want to use on PATH.
31-
- "%PYTHON%\\python.exe setup.py test"
31+
- "pytest -v --timeout=300"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ nosetests.xml
4646
coverage.xml
4747
*,cover
4848
.hypothesis/
49+
test.*
4950

5051
# Translations
5152
*.mo

.travis.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ language: python
33
python:
44
# CPython:
55
- "2.7"
6-
- "3.3"
6+
# Python 3.3 has reached EOL and pytest fails there
77
- "3.4"
88
- "3.5"
99
- "3.6"
10-
- "3.7-dev" # TODO: change to "3.7" once it gets released
10+
- "3.7-dev" # TODO: change to "3.7" once it is supported by travis-ci
1111
- "nightly"
1212
# PyPy:
1313
- "pypy"
14-
- "pypy3"
14+
- "pypy3.5"
1515

1616
os:
1717
- linux # Linux is officially supported and we test the library under
@@ -37,14 +37,20 @@ matrix:
3737
- os: osx
3838
python: "nightly"
3939

40-
# allow all nighly builds to fail, since these python versions might be unstable
41-
# we do not allow dev builds to fail, since these builds are stable enough
4240
allow_failures:
41+
# allow all nighly builds to fail, since these python versions might be unstable
4342
- python: "nightly"
4443

44+
# we do not allow dev builds to fail, since these builds are considered stable enough
45+
4546
install:
46-
- travis_retry pip install .
47-
- travis_retry pip install -r requirements.txt
47+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash test/open_vcan.sh ; fi
48+
- travis_retry pip install .[test]
49+
- travis_retry pip install sphinx
4850

4951
script:
50-
- py.test -v
52+
- pytest -v --timeout=300
53+
# Build Docs with Sphinx
54+
#
55+
# -a Write all files
56+
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then python -m sphinx -an doc build; fi

README.rst

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ python-can
99

1010
.. |docs| image:: https://readthedocs.org/projects/python-can/badge/?version=stable
1111
:target: https://python-can.readthedocs.io/en/stable/
12-
:alt: Documentation build Status
13-
12+
:alt: Documentation
13+
1414
.. |build_travis| image:: https://travis-ci.org/hardbyte/python-can.svg?branch=develop
1515
:target: https://travis-ci.org/hardbyte/python-can/branches
1616
:alt: Travis CI Server for develop branch
@@ -22,15 +22,56 @@ python-can
2222

2323
The **C**\ ontroller **A**\ rea **N**\ etwork is a bus standard designed
2424
to allow microcontrollers and devices to communicate with each other. It
25-
has priority based bus arbitration, reliable deterministic
25+
has priority based bus arbitration and reliable deterministic
2626
communication. It is used in cars, trucks, boats, wheelchairs and more.
2727

2828
The ``can`` package provides controller area network support for
29-
Python developers; providing `common abstractions to
30-
different hardware devices`, and a suite of utilities for sending and receiving
29+
Python developers; providing common abstractions to
30+
different hardware devices, and a suite of utilities for sending and receiving
3131
messages on a can bus.
3232

33-
The library supports Python 2.7, Python 3.3+ as well as PyPy and runs on Mac, Linux and Windows.
33+
The library supports Python 2.7, Python 3.4+ as well as PyPy 2 & 3 and runs on Mac, Linux and Windows.
34+
35+
36+
Features
37+
--------
38+
39+
- common abstractions for CAN communication
40+
- support for many different backends (see the `docs <https://python-can.readthedocs.io/en/master/interfaces.html>`__)
41+
- receiving, sending, and periodically sending messages
42+
- normal and extended arbitration IDs
43+
- limited `CAN FD <https://en.wikipedia.org/wiki/CAN_FD>`__ support
44+
- many different loggers and readers supporting playback: ASC (CANalyzer format), BLF (Binary Logging Format by Vector), CSV, SQLite and Canutils log
45+
- efficient in-kernel or in-hardware filtering of messages on supported interfaces
46+
- bus configuration reading from file or environment variables
47+
- more
48+
49+
50+
Example usage
51+
-------------
52+
53+
::
54+
55+
# import the library
56+
import can
57+
58+
# create a bus instance
59+
# many other interfaces are supported as well (see below)
60+
bus = can.Bus(interface='socketcan',
61+
channel='vcan0',
62+
receive_own_messages=True)
63+
64+
# send a message
65+
message = can.Message(arbitration_id=123, extended_id=True,
66+
data=[0x11, 0x22, 0x33])
67+
bus.send(message, timeout=0.2)
68+
69+
# iterate over received messages
70+
for msg in bus:
71+
print("{X}: {}".format(msg.arbitration_id, msg.data))
72+
73+
# or use an asynchronous notifier
74+
notifier = can.Notifier(bus, [can.Logger("recorded.log"), can.Printer()])
3475

3576
You can find more information in the documentation, online at
3677
`python-can.readthedocs.org <https://python-can.readthedocs.org/en/stable/>`__.
@@ -40,7 +81,7 @@ Discussion
4081
----------
4182

4283
If you run into bugs, you can file them in our
43-
`issue tracker <https://github.com/hardbyte/python-can/issues>`__.
84+
`issue tracker <https://github.com/hardbyte/python-can/issues>`__ on GitHub.
4485

4586
There is also a `python-can <https://groups.google.com/forum/#!forum/python-can>`__
4687
mailing list for development discussion.
@@ -51,6 +92,7 @@ questions and answers tagged with ``python+can``.
5192
Wherever we interact, we strive to follow the
5293
`Python Community Code of Conduct <https://www.python.org/psf/codeofconduct/>`__.
5394

95+
5496
Contributing
5597
------------
5698

can/CAN.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
however all functionality has been refactored out. This API
88
is left intact for version 2.0 to 2.3 to aide with migration.
99
10-
WARNING:
11-
This module is deprecated an will get removed in version 2.4.
10+
WARNING:
11+
This module is deprecated an will get removed in version 2.4.
1212
Please use `import can` instead.
1313
"""
1414

can/__init__.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,44 @@
22
# coding: utf-8
33

44
"""
5-
can is an object-orient Controller Area Network interface module.
5+
``can`` is an object-orient Controller Area Network (CAN) interface module.
66
"""
77

88
from __future__ import absolute_import
99

1010
import logging
1111

12-
__version__ = "2.1.1-dev"
12+
__version__ = "2.2.0-dev"
1313

1414
log = logging.getLogger('can')
1515

1616
rc = dict()
1717

1818

1919
class CanError(IOError):
20+
"""Indicates an error with the CAN network.
21+
22+
"""
2023
pass
2124

22-
from can.listener import Listener, BufferedReader, RedirectReader
25+
from .listener import Listener, BufferedReader, RedirectReader
2326

24-
from can.io import Logger, Printer, LogReader
25-
from can.io import ASCWriter, ASCReader
26-
from can.io import BLFReader, BLFWriter
27-
from can.io import CanutilsLogReader, CanutilsLogWriter
28-
from can.io import CSVWriter, CSVReader
29-
from can.io import SqliteWriter, SqliteReader
27+
from .io import Logger, Printer, LogReader, MessageSync
28+
from .io import ASCWriter, ASCReader
29+
from .io import BLFReader, BLFWriter
30+
from .io import CanutilsLogReader, CanutilsLogWriter
31+
from .io import CSVWriter, CSVReader
32+
from .io import SqliteWriter, SqliteReader
3033

31-
from can.util import set_logging_level
34+
from .util import set_logging_level
3235

33-
from can.message import Message
34-
from can.bus import BusABC
35-
from can.notifier import Notifier
36-
from can.interfaces import VALID_INTERFACES
36+
from .message import Message
37+
from .bus import BusABC
38+
from .thread_safe_bus import ThreadSafeBus
39+
from .notifier import Notifier
40+
from .interfaces import VALID_INTERFACES
3741
from . import interface
38-
from .interface import Bus
42+
from .interface import Bus, detect_available_configs
3943

4044
from can.broadcastmanager import send_periodic, \
4145
CyclicSendTaskABC, \

can/broadcastmanager.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33

44
"""
55
Exposes several methods for transmitting cyclic messages.
6+
7+
The main entry point to these classes should be through
8+
:meth:`can.BusABC.send_periodic`.
69
"""
710

8-
import can
911
import abc
1012
import logging
1113
import threading
1214
import time
1315

16+
1417
log = logging.getLogger('can.bcm')
15-
log.debug("Loading base broadcast manager functionality")
1618

1719

1820
class CyclicTask(object):
@@ -38,6 +40,7 @@ def __init__(self, message, period):
3840
"""
3941
self.message = message
4042
self.can_id = message.arbitration_id
43+
self.arbitration_id = message.arbitration_id
4144
self.period = period
4245
super(CyclicSendTaskABC, self).__init__()
4346

@@ -72,8 +75,9 @@ def modify_data(self, message):
7275
"""Update the contents of this periodically sent message without altering
7376
the timing.
7477
75-
:param message: The :class:`~can.Message` with new :attr:`Message.data`. Note
76-
the arbitration ID cannot be changed.
78+
:param message:
79+
The :class:`~can.Message` with new :attr:`can.Message.data`.
80+
Note: The arbitration ID cannot be changed.
7781
"""
7882
self.message = message
7983

@@ -138,13 +142,15 @@ def _run(self):
138142
time.sleep(max(0.0, delay))
139143

140144

141-
def send_periodic(bus, message, period):
145+
def send_periodic(bus, message, period, *args, **kwargs):
142146
"""
143147
Send a :class:`~can.Message` every `period` seconds on the given bus.
144148
145149
:param `~can.BusABC` bus: A CAN bus which supports sending.
146150
:param `~can.Message` message: Message to send periodically.
147151
:param float period: The minimum time between sending messages.
148-
152+
:return: A started task instance
149153
"""
150-
return can.interface.CyclicSendTask(bus, message, period)
154+
log.warning("The function `can.send_periodic` is deprecated and will " +
155+
"be removed in version 2.3. Please use `can.Bus.send_periodic` instead.")
156+
return bus.send_periodic(message, period, *args, **kwargs)

0 commit comments

Comments
 (0)