Skip to content

Commit d2b20ea

Browse files
Merge pull request hardbyte#357 from hardbyte/release-2.2.1
Bugfix release 2.2.1
2 parents 0b10255 + cb74ee4 commit d2b20ea

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

CHANGELOG.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Version 2.2.1 (2018-07-12)
2+
=====
3+
4+
* Fix errors and warnings when importing library on Windows
5+
* Fix Vector backend raising ValueError when hardware is not connected
16

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

can/__init__.py

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

1010
import logging
1111

12-
__version__ = "2.2.0"
12+
__version__ = "2.2.1"
1313

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

can/interface.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
from .util import load_config
2121
from .interfaces import BACKENDS
2222

23-
from can.interfaces.socketcan.socketcan import CyclicSendTask, MultiRateCyclicSendTask
23+
if 'linux' in sys.platform:
24+
# Deprecated and undocumented access to SocketCAN cyclic tasks
25+
# Will be removed in version 3.0
26+
from can.interfaces.socketcan import CyclicSendTask, MultiRateCyclicSendTask
2427

2528
# Required by "detect_available_configs" for argument interpretation
2629
if sys.version_info.major > 2:

can/interfaces/vector/canlib.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# Import Modules
3131
# ==============
32-
from can import BusABC, Message
32+
from can import BusABC, Message, CanError
3333
from can.util import len2dlc, dlc2len
3434
from .exceptions import VectorError
3535

@@ -101,6 +101,14 @@ def __init__(self, channel, can_filters=None, poll_interval=0.01,
101101
LOG.debug('Channel index %d found', channel)
102102
idx = vxlapi.xlGetChannelIndex(hw_type.value, hw_index.value,
103103
hw_channel.value)
104+
if idx < 0:
105+
# Undocumented behavior! See issue #353.
106+
# If hardware is unavailable, this function returns -1.
107+
# Raise an exception as if the driver
108+
# would have signalled XL_ERR_HW_NOT_PRESENT.
109+
raise VectorError(vxlapi.XL_ERR_HW_NOT_PRESENT,
110+
"XL_ERR_HW_NOT_PRESENT",
111+
"xlGetChannelIndex")
104112
mask = 1 << idx
105113
LOG.debug('Channel %d, Type: %d, Mask: 0x%X',
106114
hw_channel.value, hw_type.value, mask)
@@ -177,8 +185,7 @@ def __init__(self, channel, can_filters=None, poll_interval=0.01,
177185

178186
self._is_filtered = False
179187
super(VectorBus, self).__init__(channel=channel, can_filters=can_filters,
180-
poll_interval=0.01, receive_own_messages=False, bitrate=None,
181-
rx_queue_size=256, app_name="CANalyzer", **config)
188+
**config)
182189

183190
def _apply_filters(self, filters):
184191
if filters:

can/interfaces/vector/vxlapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
XL_BUS_TYPE_CAN = 0x00000001
2828

2929
XL_ERR_QUEUE_IS_EMPTY = 10
30+
XL_ERR_HW_NOT_PRESENT = 129
3031

3132
XL_RECEIVE_MSG = 1
3233
XL_CAN_EV_TAG_RX_OK = 1024

0 commit comments

Comments
 (0)