hardbyte / hardbyte/python-can

PCAN did not receive all messages while vector is normal

オープン
#1,546 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Python
スター
1.6k
フォーク
697
PR マージ指標
30日以内にマージされた PR はありません

説明

### 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!

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。