File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 9
9
10
10
from typing import Optional
11
11
12
+ from packaging import version
13
+
12
14
from ...message import Message
13
15
from ...bus import BusABC , BusState
14
16
from ...util import len2dlc , dlc2len
19
21
PCAN_BITRATES ,
20
22
PCAN_FD_PARAMETER_LIST ,
21
23
PCAN_CHANNEL_NAMES ,
24
+ PCAN_NONEBUS ,
22
25
PCAN_BAUD_500K ,
23
26
PCAN_TYPE_ISA ,
24
27
PCANBasic ,
25
28
PCAN_ERROR_OK ,
26
29
PCAN_ALLOW_ERROR_FRAMES ,
27
30
PCAN_PARAMETER_ON ,
28
31
PCAN_RECEIVE_EVENT ,
32
+ PCAN_API_VERSION ,
29
33
PCAN_DEVICE_NUMBER ,
30
34
PCAN_ERROR_QRCVEMPTY ,
31
35
PCAN_ERROR_BUSLIGHT ,
58
62
# Set up logging
59
63
log = logging .getLogger ("can.pcan" )
60
64
65
+ MIN_PCAN_API_VERSION = version .parse ("4.2.0" )
66
+
61
67
62
68
try :
63
69
# use the "uptime" library if available
@@ -206,6 +212,19 @@ def __init__(
206
212
self .m_objPCANBasic = PCANBasic ()
207
213
self .m_PcanHandle = channel
208
214
215
+ error , value = self .m_objPCANBasic .GetValue (PCAN_NONEBUS , PCAN_API_VERSION )
216
+ if error != PCAN_ERROR_OK :
217
+ raise CanInitializationError (
218
+ F"Failed to read pcan basic api version"
219
+ )
220
+
221
+ apv = version .parse (value .decode ('ascii' ))
222
+ if apv < MIN_PCAN_API_VERSION :
223
+ raise CanInitializationError (
224
+ F"Minimum version of pcan api is { MIN_PCAN_API_VERSION } ."
225
+ F" Installed version is { apv } . Consider upgrade of pcan basic package"
226
+ )
227
+
209
228
if state is BusState .ACTIVE or state is BusState .PASSIVE :
210
229
self .state = state
211
230
else :
Original file line number Diff line number Diff line change 90
90
"typing_extensions>=3.10.0.0" ,
91
91
'pywin32;platform_system=="Windows" and platform_python_implementation=="CPython"' ,
92
92
'msgpack~=1.0.0;platform_system!="Windows"' ,
93
+ "packaging" ,
93
94
],
94
95
extras_require = extras_require ,
95
96
)
You can’t perform that action at this time.
0 commit comments