简体   繁体   中英

Python CAN isotp socket is not receiving data but the candump is received

I am trying to communicate Pican3+Raspberry Pi 4(Device 1) with canoe in my laptop(Device 2). I am using python can isotp module in raspberry pi. I am able to send data from my code in raspberry pi to canoe, but not able to receive the data send from Canoe to raspberryPi to the isotp.socket I created in my python code. But the data is received in the raspberry pi end, verified with candump. Below is the code used.

import isotp 
s = isotp.socket()
s.bind("can0", isotp.Address(rxid=0x701, txid=0x708))
s.send(b'a')
while True:
    da = s.recv()
    if da is not None:
        print('here')
        print(da)

The message sent from canoe has message ID 701 and standard can frame. In my understanding the socket is bind to receive the message with ID 701 from can0 channel. Am I missing anything? Screenshot of the message composed in canoe and the candump from raspberry is attached, please have a look.

Screenshot of canoe in my laptop

Screenshot of candump in raspberry pi 4

There is no issue in the code and it is working fine. The issue was on the other end where I was trying to send the CAN frame from Canoe in my laptop to the PICAN. The frame was not created as per the ISO TP format, because of that the iso tp layer in raspberry pi linux could not process it. Once I formulated the CAN frame as per isotp the socket created as in the code receive and processed data. For more information on ISO TP protocol check https://www.emotive.de/wiki/index.php?title=ISOTP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM