Skip to content

Commit

Permalink
Merge pull request #629
Browse files Browse the repository at this point in the history
Release v3.3.0
  • Loading branch information
hardbyte authored Jun 27, 2019
2 parents d5dd7fe + a0f0ea7 commit 07d1a18
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ jobs:
- stage: deploy
name: "PyPi Deployment"
python: "3.7"
before_install:
- travis_retry pip install -U wheel setuptools
deploy:
provider: pypi
user: hardbyte
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Version 3.2.0
Version 3.3.0
====

* Adding CAN FD 64 frame support to blf reader
* Updates to installation instructions
* Clean up bits generator in PCAN interface #588
* Minor fix to use latest tools when building wheels on travis.

Version 3.2.0
====

Major features
--------------
Expand Down
2 changes: 1 addition & 1 deletion can/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import logging

__version__ = "3.2.0"
__version__ = "3.3.0"

log = logging.getLogger('can')

Expand Down
14 changes: 10 additions & 4 deletions can/interfaces/pcan/pcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,17 @@ def _get_formatted_error(self, error):
"""

def bits(n):
"""TODO: document"""
"""
Iterate over all the set bits in `n`, returning the masked bits at
the set indices
"""
while n:
b = n & (~n+1)
yield b
n ^= b
# Create a mask to mask the lowest set bit in n
mask = (~n + 1)
masked_value = n & mask
yield masked_value
# Toggle the lowest set bit
n ^= masked_value

stsReturn = self.m_objPCANBasic.GetErrorText(error, 0)
if stsReturn[0] != PCAN_ERROR_OK:
Expand Down
39 changes: 39 additions & 0 deletions can/io/blf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class BLFParseError(Exception):
# valid data bytes, data
CAN_FD_MSG_STRUCT = struct.Struct("<HBBLLBBB5x64s")

# channel, dlc, valid payload length of data, tx count, arbitration id,
# frame length, flags, bit rate used in arbitration phase,
# bit rate used in data phase, time offset of brs field,
# time offset of crc delimiter field, bit count, direction,
# offset if extDataOffset is used, crc
CAN_FD_MSG_64_STRUCT = struct.Struct("<BBBBLLLLLLLHBBL")

# channel, length, flags, ecc, position, dlc, frame length, id, flags ext, data
CAN_ERROR_EXT_STRUCT = struct.Struct("<HHLBBBxLLH2x8s")

Expand All @@ -81,6 +88,7 @@ class BLFParseError(Exception):
CAN_MESSAGE2 = 86
GLOBAL_MARKER = 96
CAN_FD_MESSAGE = 100
CAN_FD_MESSAGE_64 = 101

NO_COMPRESSION = 0
ZLIB_DEFLATE = 2
Expand All @@ -91,6 +99,12 @@ class BLFParseError(Exception):
BRS = 0x2
ESI = 0x4

# CAN FD 64 Flags
REMOTE_FLAG_64 = 0x0010
EDL_64 = 0x1000
BRS_64 = 0x2000
ESI_64 = 0x4000

TIME_TEN_MICS = 0x00000001
TIME_ONE_NANS = 0x00000002

Expand Down Expand Up @@ -236,6 +250,29 @@ def __iter__(self):
data=can_data[:length],
channel=channel - 1)
yield msg
elif obj_type == CAN_FD_MESSAGE_64:
(
channel, dlc, _, _, can_id, _, fd_flags
) = CAN_FD_MSG_64_STRUCT.unpack_from(data, pos)[:7]
length = dlc2len(dlc)
can_data = struct.unpack_from(
"<{}s".format(length),
data,
pos + CAN_FD_MSG_64_STRUCT.size
)[0]
msg = Message(
timestamp=timestamp,
arbitration_id=can_id & 0x1FFFFFFF,
is_extended_id=bool(can_id & CAN_MSG_EXT),
is_remote_frame=bool(fd_flags & REMOTE_FLAG_64),
is_fd=bool(fd_flags & EDL_64),
bitrate_switch=bool(fd_flags & BRS_64),
error_state_indicator=bool(fd_flags & ESI_64),
dlc=length,
data=can_data[:length],
channel=channel - 1
)
yield msg
elif obj_type == CAN_ERROR_EXT:
(channel, _, _, _, _, dlc, _, can_id, _,
can_data) = CAN_ERROR_EXT_STRUCT.unpack_from(data, pos)
Expand All @@ -247,6 +284,8 @@ def __iter__(self):
data=can_data[:dlc],
channel=channel - 1)
yield msg
# else:
# LOG.warning("Unknown object type (%d)", obj_type)

pos = next_pos

Expand Down
9 changes: 6 additions & 3 deletions doc/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ The modules in ``python-can`` are:
+---------------------------------+------------------------------------------------------+


Creating a new Release
----------------------
Process for creating a new Release
----------------------------------

Note many of these steps are carried out by the CI system on creating a tag in git.

- Release from the ``master`` branch.
- Update the library version in ``__init__.py`` using `semantic versioning <http://semver.org>`__.
Expand All @@ -84,8 +86,9 @@ Creating a new Release
- For larger changes update ``doc/history.rst``.
- Sanity check that documentation has stayed inline with code.
- Create a temporary virtual environment. Run ``python setup.py install`` and ``python setup.py test``.
- Ensure the ``setuptools`` and ``wheel`` tools are up to date: ``pip install -U setuptools wheel``.
- Create and upload the distribution: ``python setup.py sdist bdist_wheel``.
- Sign the packages with gpg ``gpg --detach-sign -a dist/python_can-X.Y.Z-py3-none-any.whl``.
- [Optionally] Sign the packages with gpg ``gpg --detach-sign -a dist/python_can-X.Y.Z-py3-none-any.whl``.
- Upload with twine ``twine upload dist/python-can-X.Y.Z*``.
- In a new virtual env check that the package can be installed with pip: ``pip install python-can==X.Y.Z``.
- Create a new tag in the repository.
Expand Down
4 changes: 2 additions & 2 deletions doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ available, the times are returned as number of seconds from system
startup. To install the uptime library, run ``pip install uptime``.

This library can take advantage of the `Python for Windows Extensions
<https://sourceforge.net/projects/pywin32>`__ library if installed.
<https://github.com/mhammond/pywin32>`__ library if installed.
It will be used to get notified of new messages instead of
the CPU intensive polling that will otherwise have be used.

Expand Down Expand Up @@ -83,7 +83,7 @@ Installing python-can in development mode
-----------------------------------------

A "development" install of this package allows you to make changes locally
or pull updates from the Mercurial repository and use them without having to
or pull updates from the Git repository and use them without having to
reinstall. Download or clone the source repository then:

::
Expand Down

0 comments on commit 07d1a18

Please sign in to comment.