Skip to content

Commit

Permalink
ICOc: Fix CAN buffer overflow error
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed Jul 6, 2021
1 parent b259658 commit 108b7a6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mytoolit/old/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from time import time, sleep

from can.interfaces.pcan.basic import (PCAN_BAUD_1M, PCAN_BUSOFF_AUTORESET,
PCAN_ERROR_OK, PCAN_ERROR_QOVERRUN,
PCAN_ERROR_OK, PCAN_ERROR_QRCVEMPTY,
PCAN_PARAMETER_ON, PCAN_USBBUS1,
PCANBasic)
from semantic_version import Version
Expand Down Expand Up @@ -1263,7 +1263,7 @@ def ReadMessage(self):
self.tCanReadWriteMutex.acquire()
status, message, timestamp = self.pcan.Read(self.m_PcanHandle)
self.tCanReadWriteMutex.release()
if status == PCAN_ERROR_OK:
while status == PCAN_ERROR_OK:
peakCanTimeStamp = (timestamp.millis_overflow * 2**32 +
timestamp.millis +
timestamp.micros / 1000)
Expand All @@ -1273,9 +1273,12 @@ def ReadMessage(self):
"PeakCanTime": peakCanTimeStamp
})
getLogger('can').debug(f"{Message(message)}")
elif status == PCAN_ERROR_QOVERRUN:
self.Logger.Error("RxOverRun")
print("RxOverRun")
self.tCanReadWriteMutex.acquire()
status, message, timestamp = self.pcan.Read(
self.m_PcanHandle)
self.tCanReadWriteMutex.release()
if status != PCAN_ERROR_QRCVEMPTY:
self.Logger.Error(f"Unexpected Status: {status}")
self.RunReadThread = False
except KeyboardInterrupt:
self.RunReadThread = False
Expand Down

0 comments on commit 108b7a6

Please sign in to comment.