Skip to content

Commit

Permalink
Merge pull request #344 from hardbyte/release-2.2.0
Browse files Browse the repository at this point in the history
Merge develop into master for release 2.2.0
  • Loading branch information
hardbyte committed Jul 3, 2018
2 parents 338d211 + 49eb730 commit 0b10255
Show file tree
Hide file tree
Showing 104 changed files with 3,920 additions and 2,294 deletions.
31 changes: 31 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
environment:
matrix:

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

- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python36"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python34-x64"
- PYTHON: "C:\\Python35-x64"
- PYTHON: "C:\\Python36-x64"

# Python 3.3 has reached EOL

install:
# Prepend Python installation to PATH
- set PATH=%PYTHON_INSTALL%;%PATH%

# Prepend Python scripts to PATH (e.g. py.test)
- set PATH=%PYTHON_INSTALL%\\Scripts;%PATH%

# We need to install the python-can library itself
- "python -m pip install .[test]"

build: off

test_script:
- "pytest -v --timeout=300"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ nosetests.xml
coverage.xml
*,cover
.hypothesis/
test.*

# Translations
*.mo
Expand Down
22 changes: 14 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ language: python
python:
# CPython:
- "2.7"
- "3.3"
# Python 3.3 has reached EOL and pytest fails there
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev" # TODO: change to "3.7" once it gets released
- "3.7-dev" # TODO: change to "3.7" once it is supported by travis-ci
- "nightly"
# PyPy:
- "pypy"
- "pypy3"
- "pypy3.5"

os:
- linux # Linux is officially supported and we test the library under
Expand All @@ -37,14 +37,20 @@ matrix:
- os: osx
python: "nightly"

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

# we do not allow dev builds to fail, since these builds are considered stable enough

install:
- travis_retry pip install .
- travis_retry pip install -r requirements.txt
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash test/open_vcan.sh ; fi
- travis_retry pip install .[test]
- travis_retry pip install sphinx

script:
- py.test -v
- pytest -v --timeout=300
# Build Docs with Sphinx
#
# -a Write all files
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then python -m sphinx -an doc build; fi
13 changes: 13 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@

Version 2.2.0 (2018-06-30)
=====

* Fallback message filtering implemented in Python for interfaces that don't offer better accelerated mechanism.
* SocketCAN interfaces have been merged (Now use `socketcan` instead of either `socketcan_native` and `socketcan_ctypes`),
this is now completely transparent for the library user.
* automatic detection of available configs/channels in supported interfaces.
* Added synchronized (thread-safe) Bus variant.
* context manager support for the Bus class.
* Dropped support for Python 3.3 (officially reached end-of-life in Sept. 2017)
* Deprecated the old `CAN` module, please use the newer `can` entry point (will be removed in version 2.4)

Version 2.1.0 (2018-02-17)
=====

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include *.txt
recursive-include doc *.rst
recursive-include doc *.rst
16 changes: 10 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
python-can
==========

|release| |docs| |build|
|release| |docs| |build_travis| |build_appveyor|

.. |release| image:: https://img.shields.io/pypi/v/python-can.svg
:target: https://pypi.python.org/pypi/python-can/
:alt: Latest Version
:alt: Latest Version on PyPi

.. |docs| image:: https://readthedocs.org/projects/python-can/badge/?version=stable
:target: https://python-can.readthedocs.io/en/stable/
:alt: Documentation Status
:alt: Documentation build Status

.. |build| image:: https://travis-ci.org/hardbyte/python-can.svg?branch=develop
.. |build_travis| image:: https://travis-ci.org/hardbyte/python-can.svg?branch=develop
:target: https://travis-ci.org/hardbyte/python-can/branches
:alt: CI Server for develop branch
:alt: Travis CI Server for develop branch

.. |build_appveyor| image:: https://ci.appveyor.com/api/projects/status/github/hardbyte/python-can?branch=develop&svg=true
:target: https://ci.appveyor.com/project/hardbyte/python-can/history
:alt: AppVeyor CI Server for develop branch


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

The library supports Python 2.7, Python 3.3+ as well as PyPy and runs on Mac, Linux and Windows.
The library supports Python 2.7, Python 3.4+ as well as PyPy 2 & 3 and runs on Mac, Linux and Windows.

You can find more information in the documentation, online at
`python-can.readthedocs.org <https://python-can.readthedocs.org/en/stable/>`__.
Expand Down
21 changes: 18 additions & 3 deletions can/CAN.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/usr/bin/env python
# coding: utf-8

"""
This module was once the core of python-can, containing
implementations of all the major classes in the library, now
however all functionality has been refactored out. This api
is left intact for version 2.0 to aide with migration.
however all functionality has been refactored out. This API
is left intact for version 2.0 to 2.3 to aide with migration.
WARNING:
This module is deprecated an will get removed in version 2.4.
Please use `import can` instead.
"""

from __future__ import absolute_import

from can.message import Message
Expand All @@ -14,4 +22,11 @@
import logging

log = logging.getLogger('can')
log.info("Loading python-can via the old CAN api")

# See #267
# Version 2.0 - 2.1: Log a Debug message
# Version 2.2: Log a Warning
# Version 2.3: Log an Error
# Version 2.4: Remove the module
log.warning('Loading python-can via the old "CAN" API is deprecated since v2.0 an will get removed in v2.4. '
'Please use `import can` instead.')
38 changes: 23 additions & 15 deletions can/__init__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
#!/usr/bin/env python
# coding: utf-8

"""
can is an object-orient Controller Area Network interface module.
``can`` is an object-orient Controller Area Network (CAN) interface module.
"""

from __future__ import absolute_import

import logging

__version__ = "2.1.0"
__version__ = "2.2.0"

log = logging.getLogger('can')

rc = dict()


class CanError(IOError):
"""Indicates an error with the CAN network.
"""
pass

from can.listener import Listener, BufferedReader, RedirectReader
from .listener import Listener, BufferedReader, RedirectReader

from can.io import Logger, Printer, LogReader
from can.io import ASCWriter, ASCReader
from can.io import BLFReader, BLFWriter
from can.io import CanutilsLogReader, CanutilsLogWriter
from can.io import CSVWriter
from can.io import SqliteWriter, SqliteReader
from .io import Logger, Printer, LogReader, MessageSync
from .io import ASCWriter, ASCReader
from .io import BLFReader, BLFWriter
from .io import CanutilsLogReader, CanutilsLogWriter
from .io import CSVWriter, CSVReader
from .io import SqliteWriter, SqliteReader

from can.util import set_logging_level
from .util import set_logging_level

from can.message import Message
from can.bus import BusABC
from can.notifier import Notifier
from can.interfaces import VALID_INTERFACES
from .message import Message
from .bus import BusABC
from .thread_safe_bus import ThreadSafeBus
from .notifier import Notifier
from .interfaces import VALID_INTERFACES
from . import interface
from .interface import Bus
from .interface import Bus, detect_available_configs

from can.broadcastmanager import send_periodic, \
CyclicSendTaskABC, \
Expand Down
28 changes: 18 additions & 10 deletions can/broadcastmanager.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# coding: utf-8

"""
Exposes several methods for transmitting cyclic messages.
20/09/13
The main entry point to these classes should be through
:meth:`can.BusABC.send_periodic`.
"""

import can
import abc
import logging
import sched

import threading
import time


log = logging.getLogger('can.bcm')
log.debug("Loading base broadcast manager functionality")


class CyclicTask(object):
Expand All @@ -38,6 +41,7 @@ def __init__(self, message, period):
"""
self.message = message
self.can_id = message.arbitration_id
self.arbitration_id = message.arbitration_id
self.period = period
super(CyclicSendTaskABC, self).__init__()

Expand Down Expand Up @@ -72,7 +76,7 @@ def modify_data(self, message):
"""Update the contents of this periodically sent message without altering
the timing.
:param message: The :class:`~can.Message` with new :attr:`Message.data`.
:param message: The :class:`~can.Message` with new :attr:`can.Message.data`.
"""
self.message = message

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


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

0 comments on commit 0b10255

Please sign in to comment.