Skip to content

Commit 0b10255

Browse files
authored
Merge pull request hardbyte#344 from hardbyte/release-2.2.0
Merge develop into master for release 2.2.0
2 parents 338d211 + 49eb730 commit 0b10255

Some content is hidden

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

104 files changed

+3920
-2294
lines changed

.appveyor.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
environment:
2+
matrix:
3+
4+
# For Python versions available on Appveyor, see
5+
# http://www.appveyor.com/docs/installed-software#python
6+
7+
- PYTHON: "C:\\Python27"
8+
- PYTHON: "C:\\Python34"
9+
- PYTHON: "C:\\Python35"
10+
- PYTHON: "C:\\Python36"
11+
- PYTHON: "C:\\Python27-x64"
12+
- PYTHON: "C:\\Python34-x64"
13+
- PYTHON: "C:\\Python35-x64"
14+
- PYTHON: "C:\\Python36-x64"
15+
16+
# Python 3.3 has reached EOL
17+
18+
install:
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+
25+
# We need to install the python-can library itself
26+
- "python -m pip install .[test]"
27+
28+
build: off
29+
30+
test_script:
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

CHANGELOG.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2+
Version 2.2.0 (2018-06-30)
3+
=====
4+
5+
* Fallback message filtering implemented in Python for interfaces that don't offer better accelerated mechanism.
6+
* SocketCAN interfaces have been merged (Now use `socketcan` instead of either `socketcan_native` and `socketcan_ctypes`),
7+
this is now completely transparent for the library user.
8+
* automatic detection of available configs/channels in supported interfaces.
9+
* Added synchronized (thread-safe) Bus variant.
10+
* context manager support for the Bus class.
11+
* Dropped support for Python 3.3 (officially reached end-of-life in Sept. 2017)
12+
* Deprecated the old `CAN` module, please use the newer `can` entry point (will be removed in version 2.4)
13+
114
Version 2.1.0 (2018-02-17)
215
=====
316

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
include *.txt
2-
recursive-include doc *.rst
2+
recursive-include doc *.rst

README.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
python-can
22
==========
33

4-
|release| |docs| |build|
4+
|release| |docs| |build_travis| |build_appveyor|
55

66
.. |release| image:: https://img.shields.io/pypi/v/python-can.svg
77
:target: https://pypi.python.org/pypi/python-can/
8-
:alt: Latest Version
8+
:alt: Latest Version on PyPi
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 Status
12+
:alt: Documentation build Status
1313

14-
.. |build| image:: https://travis-ci.org/hardbyte/python-can.svg?branch=develop
14+
.. |build_travis| image:: https://travis-ci.org/hardbyte/python-can.svg?branch=develop
1515
:target: https://travis-ci.org/hardbyte/python-can/branches
16-
:alt: CI Server for develop branch
16+
:alt: Travis CI Server for develop branch
17+
18+
.. |build_appveyor| image:: https://ci.appveyor.com/api/projects/status/github/hardbyte/python-can?branch=develop&svg=true
19+
:target: https://ci.appveyor.com/project/hardbyte/python-can/history
20+
:alt: AppVeyor CI Server for develop branch
1721

1822

1923
The **C**\ ontroller **A**\ rea **N**\ etwork is a bus standard designed
@@ -26,7 +30,7 @@ Python developers; providing `common abstractions to
2630
different hardware devices`, and a suite of utilities for sending and receiving
2731
messages on a can bus.
2832

29-
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.
3034

3135
You can find more information in the documentation, online at
3236
`python-can.readthedocs.org <https://python-can.readthedocs.org/en/stable/>`__.

can/CAN.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
14
"""
25
This module was once the core of python-can, containing
36
implementations of all the major classes in the library, now
4-
however all functionality has been refactored out. This api
5-
is left intact for version 2.0 to aide with migration.
7+
however all functionality has been refactored out. This API
8+
is left intact for version 2.0 to 2.3 to aide with migration.
9+
10+
WARNING:
11+
This module is deprecated an will get removed in version 2.4.
12+
Please use `import can` instead.
613
"""
14+
715
from __future__ import absolute_import
816

917
from can.message import Message
@@ -14,4 +22,11 @@
1422
import logging
1523

1624
log = logging.getLogger('can')
17-
log.info("Loading python-can via the old CAN api")
25+
26+
# See #267
27+
# Version 2.0 - 2.1: Log a Debug message
28+
# Version 2.2: Log a Warning
29+
# Version 2.3: Log an Error
30+
# Version 2.4: Remove the module
31+
log.warning('Loading python-can via the old "CAN" API is deprecated since v2.0 an will get removed in v2.4. '
32+
'Please use `import can` instead.')

can/__init__.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
14
"""
2-
can is an object-orient Controller Area Network interface module.
5+
``can`` is an object-orient Controller Area Network (CAN) interface module.
36
"""
7+
48
from __future__ import absolute_import
59

610
import logging
711

8-
__version__ = "2.1.0"
12+
__version__ = "2.2.0"
913

1014
log = logging.getLogger('can')
1115

1216
rc = dict()
1317

1418

1519
class CanError(IOError):
20+
"""Indicates an error with the CAN network.
21+
22+
"""
1623
pass
1724

18-
from can.listener import Listener, BufferedReader, RedirectReader
25+
from .listener import Listener, BufferedReader, RedirectReader
1926

20-
from can.io import Logger, Printer, LogReader
21-
from can.io import ASCWriter, ASCReader
22-
from can.io import BLFReader, BLFWriter
23-
from can.io import CanutilsLogReader, CanutilsLogWriter
24-
from can.io import CSVWriter
25-
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
2633

27-
from can.util import set_logging_level
34+
from .util import set_logging_level
2835

29-
from can.message import Message
30-
from can.bus import BusABC
31-
from can.notifier import Notifier
32-
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
3341
from . import interface
34-
from .interface import Bus
42+
from .interface import Bus, detect_available_configs
3543

3644
from can.broadcastmanager import send_periodic, \
3745
CyclicSendTaskABC, \

can/broadcastmanager.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
24
"""
35
Exposes several methods for transmitting cyclic messages.
4-
20/09/13
6+
7+
The main entry point to these classes should be through
8+
:meth:`can.BusABC.send_periodic`.
59
"""
610

7-
import can
811
import abc
912
import logging
10-
import sched
13+
1114
import threading
1215
import time
1316

17+
1418
log = logging.getLogger('can.bcm')
15-
log.debug("Loading base broadcast manager functionality")
1619

1720

1821
class CyclicTask(object):
@@ -38,6 +41,7 @@ def __init__(self, message, period):
3841
"""
3942
self.message = message
4043
self.can_id = message.arbitration_id
44+
self.arbitration_id = message.arbitration_id
4145
self.period = period
4246
super(CyclicSendTaskABC, self).__init__()
4347

@@ -72,7 +76,7 @@ def modify_data(self, message):
7276
"""Update the contents of this periodically sent message without altering
7377
the timing.
7478
75-
:param message: The :class:`~can.Message` with new :attr:`Message.data`.
79+
:param message: The :class:`~can.Message` with new :attr:`can.Message.data`.
7680
"""
7781
self.message = message
7882

@@ -130,9 +134,13 @@ def _run(self):
130134
time.sleep(max(0.0, delay))
131135

132136

133-
def send_periodic(bus, message, period):
134-
"""
135-
Send a message every `period` seconds on the given channel.
137+
def send_periodic(bus, message, period, *args, **kwargs):
138+
"""Send a message every `period` seconds on the given channel.
136139
140+
:param bus: The :class:`can.BusABC` to transmit to.
141+
:param message: The :class:`can.Message` instance to periodically send
142+
:return: A started task instance
137143
"""
138-
return can.interface.CyclicSendTask(bus, message, period)
144+
log.warning("The function `can.send_periodic` is deprecated and will " +
145+
"be removed in version 2.3. Please use `can.Bus.send_periodic` instead.")
146+
return bus.send_periodic(message, period, *args, **kwargs)

0 commit comments

Comments
 (0)