writing pgn hexdecimal .i want to write pgn as hexdecimal in canking .by using canwrite method but it is writing as 00000 instead of 1F801
Loading
writing pgn hexdecimal .i want to write pgn as hexdecimal in canking .by using canwrite method but it is writing as 00000 instead of 1F801
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jithu ThomasPosted Jan 18, 2024, 1:00 PM
Please try this,
# Assuming you have a can object, for example using python-can library
import can
# PGN in hexadecimal format (1F801)
pgn_hex = 0x1F801
# Convert PGN to bytes
pgn_bytes = pgn_hex.to_bytes(3, byteorder='big')
# Create a CAN message with the PGN as the identifier
can_message = can.Message(arbitration_id=pgn_hex, data=pgn_bytes, extended_id=True)
# Now, you can use your CAN write method to send the message
# For example, if you are using python-can library:
# bus.send(can_message)
if it is usefull please accept the answer.