diff options
author | Don Gagne <don@thegagnes.com> | 2015-05-03 19:26:54 -0700 |
---|---|---|
committer | Don Gagne <don@thegagnes.com> | 2015-05-03 19:26:54 -0700 |
commit | 46da294ffb6839d3a368036e74ce2b71ba9d863e (patch) | |
tree | 6aa4c69bc8bcab4e0ebaa35892978648ce958268 /src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h | |
parent | 0b5e6bdf9755cf530bf425b0b77db2c5374a279c (diff) | |
download | px4-firmware-46da294ffb6839d3a368036e74ce2b71ba9d863e.tar.gz px4-firmware-46da294ffb6839d3a368036e74ce2b71ba9d863e.tar.bz2 px4-firmware-46da294ffb6839d3a368036e74ce2b71ba9d863e.zip |
New bust mode ftp file download
Diffstat (limited to 'src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h')
-rw-r--r-- | src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h b/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h index 2696192cc..14c9369b0 100644 --- a/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h +++ b/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h @@ -48,7 +48,18 @@ public: virtual bool run_tests(void); - static void receive_message(const mavlink_message_t *msg, MavlinkFtpTest* ftpTest); + static void receive_message_handler_generic(const mavlink_file_transfer_protocol_t* ftp_req, void *worker_data); + + /// Worker data for stream handler + struct BurstInfo { + MavlinkFtpTest* ftp_test_class; + int burst_state; + bool single_packet_file; + uint32_t file_size; + uint8_t* file_bytes; + }; + + static void receive_message_handler_burst(const mavlink_file_transfer_protocol_t* ftp_req, void *worker_data); static const uint8_t serverSystemId = 50; ///< System ID for server static const uint8_t serverComponentId = 1; ///< Component ID for server @@ -75,31 +86,45 @@ private: bool _terminate_badsession_test(void); bool _read_test(void); bool _read_badsession_test(void); + bool _burst_test(void); bool _removedirectory_test(void); bool _createdirectory_test(void); bool _removefile_test(void); - void _receive_message(const mavlink_message_t *msg); - void _setup_ftp_msg(MavlinkFTP::PayloadHeader *payload_header, uint8_t size, const uint8_t *data, mavlink_message_t *msg); - bool _decode_message(const mavlink_message_t *msg, mavlink_file_transfer_protocol_t *ftp_msg, MavlinkFTP::PayloadHeader **payload); + void _receive_message_handler_generic(const mavlink_file_transfer_protocol_t* ftp_req); + void _setup_ftp_msg(const MavlinkFTP::PayloadHeader *payload_header, uint8_t size, const uint8_t *data, mavlink_message_t *msg); + bool _decode_message(const mavlink_file_transfer_protocol_t *ftp_msg, const MavlinkFTP::PayloadHeader **payload); bool _send_receive_msg(MavlinkFTP::PayloadHeader *payload_header, uint8_t size, const uint8_t *data, - mavlink_file_transfer_protocol_t *ftp_msg_reply, - MavlinkFTP::PayloadHeader **payload_reply); + const MavlinkFTP::PayloadHeader **payload_reply); void _cleanup_microsd(void); - MavlinkFTP *_ftp_server; - - mavlink_message_t _reply_msg; - - uint16_t _lastOutgoingSeqNumber; - - struct ReadTestCase { + /// A single download test case + struct DownloadTestCase { const char *file; const uint16_t length; + bool singlePacketRead; + bool exactlyFillPacket; + }; + + /// The set of test cases for download testing + static const DownloadTestCase _rgDownloadTestCases[]; + + /// States for stream download handler + enum { + burst_state_first_ack, + burst_state_last_ack, + burst_state_nak_eof, + burst_state_complete }; - static const ReadTestCase _rgReadTestCases[]; + + bool _receive_message_handler_burst(const mavlink_file_transfer_protocol_t* ftp_req, BurstInfo* burst_info); + + MavlinkFTP* _ftp_server; + uint16_t _expected_seq_number; + + mavlink_file_transfer_protocol_t _reply_msg; static const char _unittest_microsd_dir[]; static const char _unittest_microsd_file[]; |