Skip to content

Commit ae260cd

Browse files
committed
Move check of api version to separate method
1 parent 0f80d25 commit ae260cd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

can/interfaces/pcan/pcan.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,7 @@ def __init__(
212212
self.m_objPCANBasic = PCANBasic()
213213
self.m_PcanHandle = channel
214214

215-
apv = self.get_api_version()
216-
if apv < MIN_PCAN_API_VERSION:
217-
raise CanInitializationError(
218-
f"Minimum version of pcan api is {MIN_PCAN_API_VERSION}."
219-
f" Installed version is {apv}. Consider upgrade of pcan basic package"
220-
)
215+
self.check_api_version()
221216

222217
if state is BusState.ACTIVE or state is BusState.PASSIVE:
223218
self.state = state
@@ -324,6 +319,14 @@ def get_api_version(self):
324319

325320
return version.parse(value.decode("ascii"))
326321

322+
def check_api_version(self):
323+
apv = self.get_api_version()
324+
if apv < MIN_PCAN_API_VERSION:
325+
raise CanInitializationError(
326+
f"Minimum version of pcan api is {MIN_PCAN_API_VERSION}."
327+
f" Installed version is {apv}. Consider upgrade of pcan basic package"
328+
)
329+
327330
def status(self):
328331
"""
329332
Query the PCAN bus status.

0 commit comments

Comments
 (0)