Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions can/interfaces/ixxat/canlib_vcinpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def _recv_internal(self, timeout):
self._starttickoffset = self._message.dwTime
elif self._message.uMsgInfo.Bits.type == constants.CAN_MSGTYPE_ERROR:
if self._message.uMsgInfo.Bytes.bFlags & constants.CAN_MSGFLAGS_OVR:
log.warning("CAN error: data overrun")
raise VCIDataOverrunError("Data overrun occurred")
else:
log.warning(
CAN_ERROR_MESSAGES.get(
Expand Down Expand Up @@ -735,19 +735,17 @@ def _recv_internal(self, timeout):
error_byte_1 = status.dwStatus & 0x0F
error_byte_2 = status.dwStatus & 0xF0
if error_byte_1 > constants.CAN_STATUS_TXPEND:
# CAN_STATUS_OVRRUN = 0x02 # data overrun occurred
# CAN_STATUS_ERRLIM = 0x04 # error warning limit exceeded
# CAN_STATUS_BUSOFF = 0x08 # bus off status
if error_byte_1 & constants.CAN_STATUS_OVRRUN:
raise VCIError("Data overrun occurred")
# check CAN_STATUS_BUSOFF first because it is more severe than the other ones
if error_byte_1 & constants.CAN_STATUS_BUSOFF:
raise VCIBusOffError("Bus off status")
elif error_byte_1 & constants.CAN_STATUS_ERRLIM:
raise VCIError("Error warning limit exceeded")
elif error_byte_1 & constants.CAN_STATUS_BUSOFF:
raise VCIError("Bus off status")
raise VCIErrorLimitExceededError("Error warning limit exceeded")
# Not checking CAN_STATUS_OVRRUN here because it is handled above and would be
# raised every time as the flag is never cleared until a reset.
elif error_byte_2 > constants.CAN_STATUS_ININIT:
# CAN_STATUS_BUSCERR = 0x20 # bus coupling error
if error_byte_2 & constants.CAN_STATUS_BUSCERR:
raise VCIError("Bus coupling error")
raise VCIBusCouplingError("Bus coupling error")

if not data_received:
# Timed out / can message type is not DATA
Expand Down
2 changes: 1 addition & 1 deletion can/interfaces/ixxat/canlib_vcinpl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ def _recv_internal(self, timeout):
):
log.info(_format_can_status(self._message.abData[0]))
if self._message.abData[0] & constants.CAN_STATUS_BUSOFF:
raise VCIBusOffError()
raise VCIBusOffError("Controller is in BUSOFF state")

elif (
self._message.uMsgInfo.Bits.type
Expand Down
22 changes: 20 additions & 2 deletions can/interfaces/ixxat/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
)

__all__ = [
"VCIBusCouplingError",
"VCIBusOffError",
"VCIDataOverrunError",
"VCIDeviceNotFoundError",
"VCIError",
"VCIErrorLimitExceededError",
"VCIRxQueueEmptyError",
"VCITimeout",
]
Expand All @@ -36,8 +39,23 @@ def __init__(self):


class VCIBusOffError(VCIError):
def __init__(self):
super().__init__("Controller is in BUSOFF state")
"""Controller is in BUSOFF state"""
pass


class VCIErrorLimitExceededError(VCIError):
"""overrun of error counter occurred"""
pass


class VCIDataOverrunError(VCIError):
"""data overrun in receive buffer occurred"""
pass


class VCIBusCouplingError(VCIError):
"""Bus coupling error occurred"""
pass


class VCIDeviceNotFoundError(CanInitializationError):
Expand Down
Loading