Index: sources/update/VSwUpdate.cpp =================================================================== diff -u -r20b370a54d2737831b307a0de82aec9e06e2b772 -r054cc58969b2aacd15b12ff798887b73d339a302 --- sources/update/VSwUpdate.cpp (.../VSwUpdate.cpp) (revision 20b370a54d2737831b307a0de82aec9e06e2b772) +++ sources/update/VSwUpdate.cpp (.../VSwUpdate.cpp) (revision 054cc58969b2aacd15b12ff798887b73d339a302) @@ -29,8 +29,8 @@ #include #include #include +#include "crc.h" - // Enables (1) or disables (!1) reboot to allow for better testing. // Default is to reboot when this is finished. #ifndef REBOOT_ENABLED @@ -426,30 +426,33 @@ * \param isHD It is for HD not DG. */ void VSWUpdate::sendAppCommand(uint16 cmd, bool isHD) { - uint8 msg[8]; - // Zero it. - memset(msg, 0, 8); + QByteArray msg; + msg.append(ePayload_Sync); // 0xA5 - // Sync byte. - msg[0] = 0xA5; - // 2 bytes sequence #. uint16_t seqNo = _MessageDispatcher.getSequenceNumber(); + msg.append((uint8)(seqNo >> 8)); + msg.append((uint8)(seqNo & 0xFF)); - msg[1] = (uint8)(seqNo >> 8); - msg[2] = (uint8)(seqNo & 0xFF); - // 2 byte msgID. - msg[2] = (uint8)((cmd >> 8) & 0xFF); - msg[3] = (uint8)(cmd & 0xFF); + msg.append((uint8)((cmd >> 8) & 0xFF)); + msg.append((uint8)(cmd & 0xFF)); - // 1 byte payload length, msg[4] = 0, already done. + // 1 byte payload size = 0. + msg.append((uint8)0); + // 1 byte app protocol CRC. + msg.append(crc8(msg.mid(1))); + + // Pad 2 bytes zero. + msg.append((uint8)0); + msg.append((uint8)0); + // Send it. // eChlid_UI_HD = 0x100, ///< UI => HD [Out] // eChlid_UI_DG = 0x110, ///< UI => DG [Out] - _CanInterface.sendSWUpdateMsg(isHD ? eChlid_UI_HD : eChlid_UI_DG, msg, 8); + _CanInterface.sendSWUpdateMsg(isHD ? eChlid_UI_HD : eChlid_UI_DG, (uint8_t *)msg.data(), 8); } /*!