aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Gagne <don@thegagnes.com>2014-08-27 21:39:55 -0700
committerDon Gagne <don@thegagnes.com>2014-08-27 21:39:55 -0700
commitfce0a3b728f0aca12f9afb678f36cacde865e976 (patch)
tree96fca14783ce702765fb542c002690c1a7523947
parent0eea110f6fb4e95238a496f3a71b1cb6741625f7 (diff)
downloadpx4-firmware-fce0a3b728f0aca12f9afb678f36cacde865e976.tar.gz
px4-firmware-fce0a3b728f0aca12f9afb678f36cacde865e976.tar.bz2
px4-firmware-fce0a3b728f0aca12f9afb678f36cacde865e976.zip
Gave up on using bitfields
-rw-r--r--src/modules/mavlink/mavlink_ftp.cpp6
-rw-r--r--src/modules/mavlink/mavlink_ftp.h17
2 files changed, 15 insertions, 8 deletions
diff --git a/src/modules/mavlink/mavlink_ftp.cpp b/src/modules/mavlink/mavlink_ftp.cpp
index f4a7bc101..5b65dc369 100644
--- a/src/modules/mavlink/mavlink_ftp.cpp
+++ b/src/modules/mavlink/mavlink_ftp.cpp
@@ -122,6 +122,9 @@ MavlinkFTP::_worker(Request *req)
// check request CRC to make sure this is one of ours
messageCRC = hdr->crc32;
hdr->crc32 = 0;
+ hdr->padding[0] = 0;
+ hdr->padding[1] = 0;
+ hdr->padding[2] = 0;
if (crc32(req->rawData(), req->dataSize()) != messageCRC) {
errorCode = kErrNoRequest;
goto out;
@@ -203,6 +206,9 @@ MavlinkFTP::_reply(Request *req)
// message is assumed to be already constructed in the request buffer, so generate the CRC
hdr->crc32 = 0;
+ hdr->padding[0] = 0;
+ hdr->padding[1] = 0;
+ hdr->padding[2] = 0;
hdr->crc32 = crc32(req->rawData(), req->dataSize());
// then pack and send the reply back to the request source
diff --git a/src/modules/mavlink/mavlink_ftp.h b/src/modules/mavlink/mavlink_ftp.h
index cf9ea0c07..1dd8f102e 100644
--- a/src/modules/mavlink/mavlink_ftp.h
+++ b/src/modules/mavlink/mavlink_ftp.h
@@ -71,16 +71,17 @@ private:
static MavlinkFTP *_server;
- /// @brief This structure is sent in the payload portion of the file transfer protocol mavlink message.
- /// This structure is layed out such that it should not require any special compiler packing to not consume extra space.
+ /// @brief Trying to pack structures across differing compilers is questionable for Clients, so we pad the
+ /// structure ourselves to 32 bit alignment which should get us what we want.
struct RequestHeader
{
- uint16_t seqNumber; ///< sequence number for message
- unsigned int session:4; ///< Session id for read and write commands
- unsigned int opcode:4; ///< Command opcode
- uint8_t size; ///< Size of data
- uint32_t crc32; ///< CRC for entire Request structure, with crc32 set to 0
- uint32_t offset; ///< Offsets for List and Read commands
+ uint16_t seqNumber; ///< sequence number for message
+ uint8_t session; ///< Session id for read and write commands
+ uint8_t opcode; ///< Command opcode
+ uint8_t size; ///< Size of data
+ uint8_t padding[3];
+ uint32_t crc32; ///< CRC for entire Request structure, with crc32 and padding set to 0
+ uint32_t offset; ///< Offsets for List and Read commands
uint8_t data[];
};