Skip to content
Open
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
24 changes: 22 additions & 2 deletions can/interfaces/seeedstudio/seeedstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,13 @@ def _recv_internal(self, timeout):

if rx_byte_1 and ord(rx_byte_1) == 0xAA:
try:
rx_byte_2 = ord(self.ser.read())
if self.ser.in_waiting >= 1:
rx_byte_2_opt = self.ser.read()
else:
# Should not get to this line
logger.debug("received 0xAA, then serial stopped")
rx_byte_2_opt = 0x00
rx_byte_2 = ord(rx_byte_2_opt)

time_stamp = time()
if rx_byte_2 == 0x55:
Expand All @@ -286,7 +292,21 @@ def _recv_internal(self, timeout):
arb_id = (struct.unpack("<H", s_3_4))[0]

data = bytearray(self.ser.read(length))
end_packet = ord(self.ser.read())

if self.ser.in_waiting >= 1:
end_packet_opt = self.ser.read()
else:
logger.debug("no end byte?")
# Seems to be a bug in the seeedstudio-dongle, rarely
# the end-byte is missing. Rarely: ~0.1% of the packets?
# The communication works otherwise fine, no bad data
# packets have been observed. Probably the underlying
# usb-driver serves as a good protection.
# No bad packets (corrupted data), despite this one
# end-byte has been observed.
# To ensure no data is lost, we fake an end-byte here.
end_packet_opt = "U"
end_packet = ord(end_packet_opt)
if end_packet == 0x55:
msg = Message(
timestamp=time_stamp,
Expand Down