|
29 | 29 |
|
30 | 30 | # Import Modules
|
31 | 31 | # ==============
|
32 |
| -from can import BusABC, Message |
| 32 | +from can import BusABC, Message, CanError |
33 | 33 | from can.util import len2dlc, dlc2len
|
34 | 34 | from .exceptions import VectorError
|
35 | 35 |
|
@@ -101,6 +101,14 @@ def __init__(self, channel, can_filters=None, poll_interval=0.01,
|
101 | 101 | LOG.debug('Channel index %d found', channel)
|
102 | 102 | idx = vxlapi.xlGetChannelIndex(hw_type.value, hw_index.value,
|
103 | 103 | 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") |
104 | 112 | mask = 1 << idx
|
105 | 113 | LOG.debug('Channel %d, Type: %d, Mask: 0x%X',
|
106 | 114 | hw_channel.value, hw_type.value, mask)
|
@@ -177,8 +185,7 @@ def __init__(self, channel, can_filters=None, poll_interval=0.01,
|
177 | 185 |
|
178 | 186 | self._is_filtered = False
|
179 | 187 | 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) |
182 | 189 |
|
183 | 190 | def _apply_filters(self, filters):
|
184 | 191 | if filters:
|
|
0 commit comments