Sending Binary code CAN BUS

Hi guys.

I am trying to send the number 2 in binary (00000010) over CAN BUS in the form of [8,N,1].

I have done the examples of sending info over the CAN BUS everything worked. But bow according to a Chinese screen I have lying around, if I send the binary value of 2 the display has to change to floor 2.

I have tried the following code but dont think it is sending binary??

// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>

void setup()
{
SPI.setClockDivider(SPI_CLOCK_DIV4);

Serial.begin(115200);
// init can bus, baudrate: 500k
if (CAN.begin(CAN_20KBPS) == CAN_OK) Serial.print(“can init ok!!\r\n”);
else Serial.print(“Can init fail!!\r\n”);
}

unsigned char stmp[8] = {00000010}; // Also tried unsigned char stmp[8] = {0, 0, 0, 0, 0, 0, 1, 0};
void loop()
{
// send data: id = 0x00, standrad flame, data len = 8, stmp: data buf
CAN.sendMsgBuf(0x01, 0, 8, stmp);
delay(40); // send data per 100ms
}

/*********************************************************************************************************
END FILE
*********************************************************************************************************/

Does anyone know what I am doing wrong I have also tried other codes but no luck.

Ps I see the crystal on the display is a 4mhz where the one on the canbus and arduino is 16mz, is this a problem??

I also have no idea what the baudrate of the display and or controller is. I do however have access to a working elevator so I’ve been trying to sniff the Can bus but also no luck??

Do you guys have any advice?

I have tried the following code but dont think it is sending binary??

You are correct. It is NOT. It is sending a stream of characters.

Do you guys have any advice?

Yes, but I'm going to refrain.

The sendMsgBuf() method is called with a value of 8 for a reason. It means that the message buffer contains 8 bytes. Your message, if you are correct in thinking that you only need to send the VALUE 2, contains ONE byte.

unsigned char stmp[1] = { 2 };

CAN.sendMsgBuf(0x01, 0, 1, stmp);

The compiler will take care of converting 2 to 0b00000010 for you. You can use whatever representation of the value that makes sense to you - 2, 0b00000010, 0x02, 0x0002, 02, etc.

Thanks for the reply.

I have tried the code in your reply, but unfortunately the display still does not respond to anything I throw at it.

I am lost now, I have tried everything all the baud rates possible every code I could find but nothing seems to be working.

But I appreciate the help tho.