CAN Bus Transmit & Receive
Initialises the CAN bus at 125 kbps, prints every received frame from the
can.listen() callback, and transmits a test frame once per second with
can.tx().
can.init(125, false, false); // data rate (kbps), canFD, auto retransmission
can.listen(function(msg){ // CAN rx handler; msg = {id:164242, data:"hello from canbus"}
print(string(msg));
});
while(run()){
waitMS(1000);
can.tx(
12, // id
"Test Payload", // payload
false, // extended id
false, // canFD
false // remote frame (RTR)
);
}