Skip to content

Commit 426c22c

Browse files
Atabeyzariiii9003
Atabey
authored andcommitted
parametrise pcan auto reset
1 parent c4f0789 commit 426c22c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

can/interfaces/pcan/pcan.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ def __init__(
206206
In the range (1..16).
207207
Ignored if not using CAN-FD.
208208
209+
:param bool auto_reset:
210+
Enable automatic recovery in bus off scenario.
211+
Resetting the driver takes ~500ms during which
212+
it will not be responsive.
209213
"""
210214
self.m_objPCANBasic = PCANBasic()
211215

@@ -276,6 +280,14 @@ def __init__(
276280
"Ignoring error. PCAN_ALLOW_ERROR_FRAMES is still unsupported by OSX Library PCANUSB v0.10"
277281
)
278282

283+
if kwargs.get("auto_reset", False):
284+
result = self.m_objPCANBasic.SetValue(
285+
self.m_PcanHandle, PCAN_BUSOFF_AUTORESET, PCAN_PARAMETER_ON
286+
)
287+
288+
if result != PCAN_ERROR_OK:
289+
raise PcanCanInitializationError(self._get_formatted_error(result))
290+
279291
if HAS_EVENTS:
280292
self._recv_event = CreateEvent(None, 0, 0, None)
281293
result = self.m_objPCANBasic.SetValue(

0 commit comments

Comments
 (0)