FlexCAN_T4.h

Status
Not open for further replies.

Tinbum

Member
I have had a setup on an Arduino mega but am now putting it on a Teensy 4.1 and require a little bit of help with the code. I have a number of different serial numbers (login) that I need to send in individual messages. This is part of the old code;

Code:
unsigned char login[][8] = {{0x13, 0x22, 0x72, 0x10, 0x10, 0x68, 0x00, 0x00},    //The serial numbers are unique for each PS and must be set for your units
  {0x12, 0x22, 0x71, 0x16, 0x13, 0x74, 0x00, 0x00},
  {0x10, 0x42, 0x71, 0x11, 0x15, 0x36, 0x00, 0x00},
  {0x10, 0x47, 0x71, 0x12, 0x04, 0x13, 0x00, 0x00},
  {0x11, 0x34, 0x71, 0x12, 0x31, 0x61, 0x00, 0x00},    //3kw
  {0x11, 0x34, 0x71, 0x12, 0x35, 0x79, 0x00, 0x00},    //3kw
  {0x11, 0x34, 0x71, 0x12, 0x33, 0x55, 0x00, 0x00}     //3kw
};

and this is how it was sent

Code:
for (byte i = 0; i < numChargers; i++)
  {
[B]CAN2.sendMsgBuf(0x05004804, 1, len, login[i]);[/B]

   delay (50);
  }

How do I rewrite the line in bold to include the login?

Code:
for (byte i = 0; i < numChargers; i++)
  {
    txmsg3.flags.extended = 1;
    txmsg3.id = 0x05004804;

    //txmsg3.buf[8] = login[i]; ????????????

    can3.write( txmsg3);
    delay (50);
  }
 
Solved

Code:
txmsg3logon.flags.extended = 1;
    txmsg3logon.id = 0x05004804;
    sprintf(txmsg3logon.buf, login[i]);    

    can3.write( txmsg3logon);
    delay (50);
 
Status
Not open for further replies.
Back
Top