Problem sending CAN messages.
Posted: Wed 12. Jan 2022, 08:58
Hello,
I'm making a python script which sends a CAN message through a PCAN-USB(IPEH-002021). The problem is when i want to send a float type data i receive the following error <unsupported operand type(s) for >>: 'float' and 'int'>
This is my code:
Is there anay way for it to accept float data and not just integer data ?
Thank you in advance.
I'm making a python script which sends a CAN message through a PCAN-USB(IPEH-002021). The problem is when i want to send a float type data i receive the following error <unsupported operand type(s) for >>: 'float' and 'int'>
This is my code:
Code: Select all
connect1 = PCANBasic()
# Initialize connection
res = connect1.Initialize(PCAN_USBBUS1,
PCAN_BAUD_500K,
TPCANType(0),0,0)
msg = TPCANMsg()
msg.ID = 0xW8
msg.MSGTYPE = PCAN_MESSAGE_STANDARD
msg.LEN = 8
msg.DATA[0] = (12.4>> 24) & 0xff
msg.DATA[1] = (12.4 >> 16) & 0xff
msg.DATA[2] = (12.4 >> 8) & 0xff
msg.DATA[3] = (12.4) & 0xff
msg.DATA[4] = (35.4 >> 24) & 0xff
msg.DATA[5] = (35.4 >> 16) & 0xff
msg.DATA[6] = (35.4 >> 8) & 0xff
msg.DATA[7] = (35.4) & 0xff
result = connect1.Write(PCAN_USBBUS1,msg)
if result != PCAN_ERROR_OK:
# An error occurred, get a text describing the error and show it
#
result = connect1.GetErrorText(result,0x00)
print(result)
else:
print("VP_POSITION : Message sent successfully")
res = connect1.Uninitialize(PCAN_USBBUS1)
Thank you in advance.