8 years, 4 months ago.

can bus Writing data problem. LPC1768

Hello to everyone.. This code write only char. can.write(CANMessage(sinyalg_g, reinterpret_cast<char*>(&signal), sizeof(signal))); but I want to send float data. from the can bus line. for example:

float signal = 1.55; can.write(CANMessage(sinyalg_g, reinterpret_cast<float*>(&signal), sizeof(signal)));

error :( How can I fix

1 Answer

8 years, 4 months ago.

Did you try a simple cast?

float signal = 1.55;
can.write(CANMessage(sinyalg_g, (char *)(&signal), sizeof(signal)));

Accepted Answer

Thank you Andy

posted by nazım jafarov 15 Aug 2016