Skip to content

Commit 07d1a18

Browse files
authored
Merge pull request hardbyte#629
Release v3.3.0
2 parents d5dd7fe + a0f0ea7 commit 07d1a18

File tree

7 files changed

+68
-11
lines changed

7 files changed

+68
-11
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ jobs:
8888
- stage: deploy
8989
name: "PyPi Deployment"
9090
python: "3.7"
91+
before_install:
92+
- travis_retry pip install -U wheel setuptools
9193
deploy:
9294
provider: pypi
9395
user: hardbyte

CHANGELOG.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
Version 3.2.0
1+
Version 3.3.0
22
====
33

4+
* Adding CAN FD 64 frame support to blf reader
5+
* Updates to installation instructions
6+
* Clean up bits generator in PCAN interface #588
7+
* Minor fix to use latest tools when building wheels on travis.
8+
9+
Version 3.2.0
10+
====
411

512
Major features
613
--------------

can/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import logging
1010

11-
__version__ = "3.2.0"
11+
__version__ = "3.3.0"
1212

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

can/interfaces/pcan/pcan.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,17 @@ def _get_formatted_error(self, error):
216216
"""
217217

218218
def bits(n):
219-
"""TODO: document"""
219+
"""
220+
Iterate over all the set bits in `n`, returning the masked bits at
221+
the set indices
222+
"""
220223
while n:
221-
b = n & (~n+1)
222-
yield b
223-
n ^= b
224+
# Create a mask to mask the lowest set bit in n
225+
mask = (~n + 1)
226+
masked_value = n & mask
227+
yield masked_value
228+
# Toggle the lowest set bit
229+
n ^= masked_value
224230

225231
stsReturn = self.m_objPCANBasic.GetErrorText(error, 0)
226232
if stsReturn[0] != PCAN_ERROR_OK:

can/io/blf.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ class BLFParseError(Exception):
6666
# valid data bytes, data
6767
CAN_FD_MSG_STRUCT = struct.Struct("<HBBLLBBB5x64s")
6868

69+
# channel, dlc, valid payload length of data, tx count, arbitration id,
70+
# frame length, flags, bit rate used in arbitration phase,
71+
# bit rate used in data phase, time offset of brs field,
72+
# time offset of crc delimiter field, bit count, direction,
73+
# offset if extDataOffset is used, crc
74+
CAN_FD_MSG_64_STRUCT = struct.Struct("<BBBBLLLLLLLHBBL")
75+
6976
# channel, length, flags, ecc, position, dlc, frame length, id, flags ext, data
7077
CAN_ERROR_EXT_STRUCT = struct.Struct("<HHLBBBxLLH2x8s")
7178

@@ -81,6 +88,7 @@ class BLFParseError(Exception):
8188
CAN_MESSAGE2 = 86
8289
GLOBAL_MARKER = 96
8390
CAN_FD_MESSAGE = 100
91+
CAN_FD_MESSAGE_64 = 101
8492

8593
NO_COMPRESSION = 0
8694
ZLIB_DEFLATE = 2
@@ -91,6 +99,12 @@ class BLFParseError(Exception):
9199
BRS = 0x2
92100
ESI = 0x4
93101

102+
# CAN FD 64 Flags
103+
REMOTE_FLAG_64 = 0x0010
104+
EDL_64 = 0x1000
105+
BRS_64 = 0x2000
106+
ESI_64 = 0x4000
107+
94108
TIME_TEN_MICS = 0x00000001
95109
TIME_ONE_NANS = 0x00000002
96110

@@ -236,6 +250,29 @@ def __iter__(self):
236250
data=can_data[:length],
237251
channel=channel - 1)
238252
yield msg
253+
elif obj_type == CAN_FD_MESSAGE_64:
254+
(
255+
channel, dlc, _, _, can_id, _, fd_flags
256+
) = CAN_FD_MSG_64_STRUCT.unpack_from(data, pos)[:7]
257+
length = dlc2len(dlc)
258+
can_data = struct.unpack_from(
259+
"<{}s".format(length),
260+
data,
261+
pos + CAN_FD_MSG_64_STRUCT.size
262+
)[0]
263+
msg = Message(
264+
timestamp=timestamp,
265+
arbitration_id=can_id & 0x1FFFFFFF,
266+
is_extended_id=bool(can_id & CAN_MSG_EXT),
267+
is_remote_frame=bool(fd_flags & REMOTE_FLAG_64),
268+
is_fd=bool(fd_flags & EDL_64),
269+
bitrate_switch=bool(fd_flags & BRS_64),
270+
error_state_indicator=bool(fd_flags & ESI_64),
271+
dlc=length,
272+
data=can_data[:length],
273+
channel=channel - 1
274+
)
275+
yield msg
239276
elif obj_type == CAN_ERROR_EXT:
240277
(channel, _, _, _, _, dlc, _, can_id, _,
241278
can_data) = CAN_ERROR_EXT_STRUCT.unpack_from(data, pos)
@@ -247,6 +284,8 @@ def __iter__(self):
247284
data=can_data[:dlc],
248285
channel=channel - 1)
249286
yield msg
287+
# else:
288+
# LOG.warning("Unknown object type (%d)", obj_type)
250289

251290
pos = next_pos
252291

doc/development.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ The modules in ``python-can`` are:
7373
+---------------------------------+------------------------------------------------------+
7474

7575

76-
Creating a new Release
77-
----------------------
76+
Process for creating a new Release
77+
----------------------------------
78+
79+
Note many of these steps are carried out by the CI system on creating a tag in git.
7880

7981
- Release from the ``master`` branch.
8082
- Update the library version in ``__init__.py`` using `semantic versioning <http://semver.org>`__.
@@ -84,8 +86,9 @@ Creating a new Release
8486
- For larger changes update ``doc/history.rst``.
8587
- Sanity check that documentation has stayed inline with code.
8688
- Create a temporary virtual environment. Run ``python setup.py install`` and ``python setup.py test``.
89+
- Ensure the ``setuptools`` and ``wheel`` tools are up to date: ``pip install -U setuptools wheel``.
8790
- Create and upload the distribution: ``python setup.py sdist bdist_wheel``.
88-
- Sign the packages with gpg ``gpg --detach-sign -a dist/python_can-X.Y.Z-py3-none-any.whl``.
91+
- [Optionally] Sign the packages with gpg ``gpg --detach-sign -a dist/python_can-X.Y.Z-py3-none-any.whl``.
8992
- Upload with twine ``twine upload dist/python-can-X.Y.Z*``.
9093
- In a new virtual env check that the package can be installed with pip: ``pip install python-can==X.Y.Z``.
9194
- Create a new tag in the repository.

doc/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ available, the times are returned as number of seconds from system
5050
startup. To install the uptime library, run ``pip install uptime``.
5151

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

@@ -83,7 +83,7 @@ Installing python-can in development mode
8383
-----------------------------------------
8484

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

8989
::

0 commit comments

Comments
 (0)