autowp / arduino-mcp2515

Arduino MCP2515 CAN interface library
MIT License
782 stars 274 forks source link

Send a negative value MCP2515 #111

Open verygoodguy opened 3 months ago

verygoodguy commented 3 months ago

Hi, I'm using the struct struct can_frame { canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ __u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */ __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8))); }; to send data to mi CAN bus network. Everything is ok but there is a semantic mistake when I try to send negative values.

Checking the struct it's a __u8 so it make sense the data I'm sending is not ok for the library. But how can I handle this situation? Can anybody help me, please?

Best

Gradar66 commented 1 month ago

Hi,

I'm using the struct

`struct can_frame {

canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */

__u8    can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */

__u8    data[CAN_MAX_DLEN] __attribute__((aligned(8)));

};` to send data to mi CAN bus network. Everything is ok but there is a semantic mistake when I try to send negative values.

Checking the struct it's a __u8 so it make sense the data I'm sending is not ok for the library. But how can I handle this situation?

Can anybody help me, please?

Best

Hi! Plz give you're code here.

in normal operation of the CAN bus of the car, there should not be such situations when you would need a negative value. describe specifically what you need to do! Let's say a negative number for Mazda is uint8_t 0-50 and this will be 0=-50 degrees Celsius, everything above 50 is 0-205 degrees.