Can someone explain why “&len” is used in “CAN.readMsgBuf(&len, buf);”?
I am using the github CANBUS library for the seed studio (v2) CAN shield:
https://github.com/Seeed-Studio/CAN_BUS_Shield/blob/master/README.md
I know that “&” is a C++ pointer but I cannot wrap my head around why it is being used in this context.
void loop()
{
unsigned char len = 0;
unsigned char buf[8];
if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming
{
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
unsigned long canId = CAN.getCanId();
Serial.println("-----------------------------");
Serial.print(“Get data from ID: 0x”);
Serial.println(canId, HEX);
for(int i = 0; i<len; i++) // print the data
{
Serial.print(buf*, HEX);*
- Serial.print("\t");*
- }*
- Serial.println();*
- }*
}