From b072599679e295403622298e956eb72c0895f567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 18 Sep 2017 12:34:34 +0200 Subject: [PATCH] mavlink_ftp: fix alignment issue --- src/modules/mavlink/mavlink_ftp.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/mavlink/mavlink_ftp.h b/src/modules/mavlink/mavlink_ftp.h index 5d4cb94643..a3b7c5d7be 100644 --- a/src/modules/mavlink/mavlink_ftp.h +++ b/src/modules/mavlink/mavlink_ftp.h @@ -71,9 +71,10 @@ public: /// @param worker_data Data to pass to worker void set_unittest_worker(ReceiveMessageFunc_t rcvMsgFunc, void *worker_data); - /// @brief This is the payload which is in mavlink_file_transfer_protocol_t.payload. We pad the structure ourselves to - /// 32 bit alignment to avoid usage of any pack pragmas. - struct PayloadHeader { + /// @brief This is the payload which is in mavlink_file_transfer_protocol_t.payload. + /// This needs to be packed, because it's typecasted from mavlink_file_transfer_protocol_t.payload, which starts + /// at a 3 byte offset, causing an unaligned access to seq_number and offset + struct __attribute__((__packed__)) PayloadHeader { uint16_t seq_number; ///< sequence number for message uint8_t session; ///< Session id for read and write commands uint8_t opcode; ///< Command opcode