I need to send more values data on a frame "vehicle speed and fuel level, i used code from example , since it send only 4 value in the first frame i tried to add one value in the code memcpy(); , how to edit the code to send more value in the frame
A frame is 8 bytes so you either need to add another frame to accommodate the values, or alternatively if the values you have are only 8 bit then alter the above.
Below is sending two frames
void SendCANFramesToSerial() {
byte buf[8];
// build & send CAN frames to RealDash.
// a CAN frame payload is always 8 bytes containing data in a manner
// described by the RealDash custom channel description XML file
// all multibyte values are handled as little endian by default.
// endianess of the values can be specified in XML file if it is required to use big endian values
// build 1st CAN frame, ESP32 digital pins and analog values
//MyDebug();
memcpy(buf + 0, &digitalPins, 2);
memcpy(buf + 2, &analogPin, 2);
memcpy(buf + 4, &empty, 2);
memcpy(buf + 6, &empty, 2);
// write first CAN frame to serial
SendCANFrameToSerial(1900, buf);
If you transfer this in dual byte format you would need to use unit=βbitβ in the corresponding xml file to extract this digital value.
In my example I am transferring four digital inputs as &digitalPins corresponding to different inputs on the ESP32 I am using, then using xml to separate them again on the android device.