message * multiPG;
pg Msg1 pg1 = {dlc = 13}; // Msg1 is defined in the attached DBC
pg Msg2 pg2 = {dlc = 10}; // Msg2 is defined in the attached DBC
pg Msg3 pg3 = {dlc = 16}; // Msg3 is defined in the attached DBC
pg * pg4 = {dlc = 12}; // Create PG with 8 Bytes of data and 4 bytes assurance data.
// Here a 29 bit CAN FD message is initialized as, multiPG for the source address 0x23,
// destination address 0x45 and prio 5:
J1939InitializeMultiPG(multiPG, 0x5, 0x45, 0x23);
pg1.byte(3) = 0x12; // Init payload of pg1
J1939AddContainedPG(multiPG, pg1); // Add pg1 as a containedPG to the multiPG
pg2.byte(5) = 0x34; // Init payload of pg2
J1939AddContainedPG(multiPG, pg2); // Add pg2 as a containedPG to the multiPG
pg3.byte(7) = 0x56; // Init payload of pg3
J1939AddContainedPG(multiPG, pg3); // Add pg3 as a containedPG to the multiPG
pg4.byte(7) = 0x56; // Init payload of pg4
pg4.tos = 1; // PG with assurance data
pg4.tf = 2; // 32bit safety assurance data
pg4.qword(0) = some8ByteData; // Can be any data up to 8 bytes
pg4.dword(8) = 0x12345678; // Safety data
J1939AddContainedPG(multiPG, pg4); // Add pg4 as a containedPG to the multiPG
output(multiPG);