hardbyte / hardbyte/python-can

Introducing the python-can package fails to communicate(CANFD)

Open
#1,454 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.6k
Forks
697
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

### To Reproduce
1:The hardware part is the USB-CANFD professional version of Zhiming Electronics, and the picture is as follows,The lower computer is the company's own chip, and the test is available.
![image](https://user-images.githubusercontent.com/66081513/204987780-fc223001-15f9-445c-9271-7d0d267dffb4.png)

2:Configure the bus part and the message part according to the official documentation of python-can,The configuration code is as follows:(Arbitration field is 1000K, data field is 2000k)
```python3
import can
bus = can.interface.Bus(bustype='serial',
channel='COM6',
#baudrate=1000000,
#operation_mode='normal',
bitrate = 1000000,
data_bitrate=2000000,
fd=True )
def send_msg():
filters = [{"can_id": 0x100, "can_mask": 0xFFFF, "extended": False}]
msg = can.Message(timestamp=0.2, arbitration_id=0x100, is_extended_id=False, is_remote_frame=False,
is_error_frame=False, dlc=5, data=[0x00, 0x01, 0x00, 0x01, 0x03], is_fd=True, is_rx=True,
bitrate_switch=True, error_state_indicator=False, check=False)
bus.send(msg)
print(f"Message sent on {bus.channel_info}")
print (msg.data)
print(bus.state)
def receive_all():
print('Waiting for RX CAN messages ...')
for msg in bus:
#msg = bus.recv(timeout=1)
print(msg)
# try:
# while True:
# msg = bus.recv(1)
# if msg is not None:
# print(msg)
# except KeyboardInterrupt:
# print("done")
# bus = can.interface.Bus()
# while True:
#with Bus() as bus:
if __name__ == "__main__":
send_msg()
receive_all()
```
3:The result after running is as follows:
![image](https://user-images.githubusercontent.com/66081513/204986870-71d1138a-c097-4bdb-92c3-ee733c31b320.png)

It only shows the success of the bus serial port call and the message sending status and data, and in order to return the data of the lower computer, we guess that it may not be sent out.
4:After consulting the python-can document, we found that his interface has serial and Chinese CAN-USB interface (mfg. Robotell etc.)

### Expected behavior
It is expected that the corresponding data will be sent as shown in the figure below, and the lower computer will return the corresponding message:
![image](https://user-images.githubusercontent.com/66081513/204984938-928f2bb3-2271-4b94-93a5-c3ec3e8d5feb.png)

### Additional context

OS and version:Win10
Python version:3.7.9
python-can version:4.0.0
python-can interface/s (if applicable):

I don't know where the bug problem occurred, please let the management staff know, thank you very much
Traceback and logs

```import can
bus = can.interface.Bus(bustype='serial',
channel='COM6',
baudrate=1000000,
#operation_mode='normal',
#bitrate = 1000000,
data_bitrate=2000000,
fd=True )
def send_msg():
filters = [{"can_id": 0x100, "can_mask": 0xFFFF, "extended": False}]
msg = can.Message(timestamp=0.2, arbitration_id=0x100, is_extended_id=False, is_remote_frame=False,
is_error_frame=False, dlc=5, data=[0x00, 0x01, 0x00, 0x01, 0x03], is_fd=True, is_rx=True,
bitrate_switch=True, error_state_indicator=False, check=False)
bus.send(msg)
print(f"Message sent on {bus.channel_info}")
print (msg.data)
print(bus.state)
def receive_all():
print('Waiting for RX CAN messages ...')
for msg in bus:
#msg = bus.recv(timeout=1)
print(msg)
# try:
# while True:
# msg = bus.recv(1)
# if msg is not None:
# print(msg)
# except KeyboardInterrupt:
# print("done")
# bus = can.interface.Bus()
# while True:
#with Bus() as bus:
if __name__ == "__main__":
send_msg()
receive_all()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.