PCAN did not receive all messages while vector is normal
Describe the bug
I created a bus as below:
if bustype1 != "None":
if bustype1 == "pcan":
channel1 = 'PCAN_USBBUS' + str(int(channel1))
else:
channel1 = str(int(channel1) - 1)
self.bus1 = can.ThreadSafeBus(bustype=bustype1, app_name=None, channel=channel1, bitrate=bitrate1, receive_own_messages=True, name="BUS1")
if bustype2 != "None":
if bustype2 == "pcan":
channel2 = 'PCAN_USBBUS' + str(int(channel2))
else:
channel2 = str(int(channel2) - 1)
self.bus2 = can.ThreadSafeBus(bustype=bustype2, app_name=None, channel=channel2, bitrate=bitrate2, receive_own_messages=True, name="BUS2")
And get messages like that:
class GetMessages:
def __init__(self, bustype1, bustype2, channel1, channel2, bitrate1, bitrate2):
self.bustype1 = bustype1
self.bustype2 = bustype2
self.channel1 = channel1
self.channel2 = channel2
self.bitrate1 = bitrate1
self.bitrate2 = bitrate2
async def get_msg(self):
reader = can.AsyncBufferedReader()
listeners: List[MessageRecipient] = [
reader, # AsyncBufferedReader() listener
]
loop = asyncio.get_running_loop()
if self.bustype1 != 'None' and self.bustype2 != 'None':
notifier = can.Notifier([GLOBAL_DICT["bus1"], GLOBAL_DICT["bus2"]], listeners, loop=loop)
elif self.bustype1 != 'None' and self.bustype2 == 'None':
notifier = can.Notifier([GLOBAL_DICT["bus1"]], listeners, loop=loop)
else:
notifier = can.Notifier([GLOBAL_DICT["bus2"]], listeners, loop=loop)
async for msg in reader:
await asyncio.sleep(0)
msg_id = msg.arbitration_id
if msg_id not in MSGS:
row = len(MSGS) + 1
MSGS[msg_id] = {'count': 1, 'msg': msg, 'row': row, 'dt': 0}
else:
MSGS[msg_id]['row'] = MSGS[msg_id]['row']
MSGS[msg_id]['msg'] = msg
MSGS[msg_id]['count'] += 1
MSGS[msg_id]['dt'] = msg.timestamp - MSGS[msg_id]['msg'].timestamp
print(len(MSGS))
notifier.stop()
Firstly, I used Vector VN1630A. I tried to print the length of messages in the bus. In the beginning , when I startup my code, the length is 25, it's the same as the trace in the CANalyzer. And then, I send some messages, and the length changed to bigger but it's consistent with CANalyzer.
Secondly, I used PCAN 002021. I tried to print the length of messages in the bus. In the beginning , when I startup my code, the length is 25, it's the same as the trace in the CANalyzer. And then, I send some messages, but the length not changed while the length of trace in CANalyzer changed to the right value.
To Reproduce
See the code above
Expected behavior
PCAN and Vector should behave the same
Additional context
OS and version: Win10 Python version: 3.7.4 python-can version: 4.0.0 python-can interface/s (if applicable):
I'd appreciate it if you could look into my confuse. Thks in advance!
I think this issue is consistent with #1222.