From 941981066c0d4acf9ec93f405cc2f029d4b9c073 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 29 May 2015 23:56:41 +0300 Subject: [PATCH] CRC64 removed, file messages refactored --- dsdl/uavcan/protocol/file/215.GetInfo.uavcan | 3 +-- dsdl/uavcan/protocol/file/218.Read.uavcan | 2 +- dsdl/uavcan/protocol/file/219.Write.uavcan | 4 ++-- libuavcan/include/uavcan/protocol/file_server.hpp | 13 ++++--------- libuavcan/test/protocol/file_server.cpp | 10 ++-------- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/dsdl/uavcan/protocol/file/215.GetInfo.uavcan b/dsdl/uavcan/protocol/file/215.GetInfo.uavcan index d26d085ac0..f018a2a835 100644 --- a/dsdl/uavcan/protocol/file/215.GetInfo.uavcan +++ b/dsdl/uavcan/protocol/file/215.GetInfo.uavcan @@ -11,7 +11,6 @@ Path path --- -uint64 crc64 # Undefined for directories -uint32 size # Undefined for directories +uint40 size # Undefined for directories Error error EntryType entry_type diff --git a/dsdl/uavcan/protocol/file/218.Read.uavcan b/dsdl/uavcan/protocol/file/218.Read.uavcan index b120a86301..ebc1c6d4a1 100644 --- a/dsdl/uavcan/protocol/file/218.Read.uavcan +++ b/dsdl/uavcan/protocol/file/218.Read.uavcan @@ -12,7 +12,7 @@ # will be returned, and data array will be empty. # -uint32 offset +uint40 offset Path path --- diff --git a/dsdl/uavcan/protocol/file/219.Write.uavcan b/dsdl/uavcan/protocol/file/219.Write.uavcan index 1cbec0666d..a661803863 100644 --- a/dsdl/uavcan/protocol/file/219.Write.uavcan +++ b/dsdl/uavcan/protocol/file/219.Write.uavcan @@ -15,9 +15,9 @@ # example by means of creating a staging area for uncompleted writes (like FTP servers do). # -uint32 offset +uint40 offset Path path -uint8[<=200] data +uint8[<=192] data --- diff --git a/libuavcan/include/uavcan/protocol/file_server.hpp b/libuavcan/include/uavcan/protocol/file_server.hpp index 1e5fed04a2..f1ca877cd8 100644 --- a/libuavcan/include/uavcan/protocol/file_server.hpp +++ b/libuavcan/include/uavcan/protocol/file_server.hpp @@ -30,11 +30,6 @@ public: typedef protocol::file::EntryType EntryType; typedef protocol::file::Error Error; - /** - * Use this class to compute CRC64 for uavcan.protocol.file.GetInfo. - */ - typedef DataTypeSignatureCRC FileCRC; - /** * All read operations must return this number of bytes, unless end of file is reached. */ @@ -51,7 +46,7 @@ public: * Implementation of this method is required. * On success the method must return zero. */ - virtual int16_t getInfo(const Path& path, uint64_t& out_crc64, uint32_t& out_size, EntryType& out_type) = 0; + virtual int16_t getInfo(const Path& path, uint64_t& out_size, EntryType& out_type) = 0; /** * Backend for uavcan.protocol.file.Read. @@ -60,7 +55,7 @@ public: * if the end of file is reached. * On success the method must return zero. */ - virtual int16_t read(const Path& path, const uint32_t offset, uint8_t* out_buffer, uint16_t& inout_size) = 0; + virtual int16_t read(const Path& path, const uint64_t offset, uint8_t* out_buffer, uint16_t& inout_size) = 0; // Methods below are optional. @@ -69,7 +64,7 @@ public: * Implementation of this method is NOT required; by default it returns uavcan.protocol.file.Error.NOT_IMPLEMENTED. * On success the method must return zero. */ - virtual int16_t write(const Path& path, const uint32_t offset, const uint8_t* buffer, const uint16_t size) + virtual int16_t write(const Path& path, const uint64_t offset, const uint8_t* buffer, const uint16_t size) { (void)path; (void)offset; @@ -129,7 +124,7 @@ class BasicFileServer void handleGetInfo(const protocol::file::GetInfo::Request& req, protocol::file::GetInfo::Response& resp) { - resp.error.value = backend_.getInfo(req.path.path, resp.crc64, resp.size, resp.entry_type); + resp.error.value = backend_.getInfo(req.path.path, resp.size, resp.entry_type); } void handleRead(const protocol::file::Read::Request& req, protocol::file::Read::Response& resp) diff --git a/libuavcan/test/protocol/file_server.cpp b/libuavcan/test/protocol/file_server.cpp index f3591e79e3..be970b4d04 100644 --- a/libuavcan/test/protocol/file_server.cpp +++ b/libuavcan/test/protocol/file_server.cpp @@ -13,15 +13,10 @@ public: static const std::string file_name; static const std::string file_data; - virtual int16_t getInfo(const Path& path, uint64_t& out_crc64, uint32_t& out_size, EntryType& out_type) + virtual int16_t getInfo(const Path& path, uint64_t& out_size, EntryType& out_type) { if (path == file_name) { - { - FileCRC crc; - crc.add(reinterpret_cast(file_data.c_str()), unsigned(file_data.length())); - out_crc64 = crc.get(); - } out_size = uint16_t(file_data.length()); out_type.flags |= EntryType::FLAG_FILE; out_type.flags |= EntryType::FLAG_READABLE; @@ -33,7 +28,7 @@ public: } } - virtual int16_t read(const Path& path, const uint32_t offset, uint8_t* out_buffer, uint16_t& inout_size) + virtual int16_t read(const Path& path, const uint64_t offset, uint8_t* out_buffer, uint16_t& inout_size) { if (path == file_name) { @@ -90,7 +85,6 @@ TEST(BasicFileServer, Basic) ASSERT_TRUE(get_info.collector.result.get()); ASSERT_TRUE(get_info.collector.result->isSuccessful()); - ASSERT_EQ(0x62EC59E3F1A4F00A, get_info.collector.result->getResponse().crc64); ASSERT_EQ(0, get_info.collector.result->getResponse().error.value); ASSERT_EQ(9, get_info.collector.result->getResponse().size); ASSERT_EQ(EntryType::FLAG_FILE | EntryType::FLAG_READABLE,