From dc84f4f1668a7c53dfe684ce6beac0bcd559eaec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonny=20Sv=C3=A4rd?= Date: Thu, 14 Jan 2021 19:54:54 +0100 Subject: Improve mailbox msg handling for MessageProcess Send/verify 32b message magic Add version response support In case an error occurs with the messaging, send an error response and effectively reset/empty the queue. Add support for error response Fix a couple of bugs where mailbox interrupts were sent even when a previous error occured. Change-Id: I6a1fdefd0d6eb68c9b22123c156ff820ce9c0399 --- .../message_process/include/message_process.hpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'applications/message_process/include') diff --git a/applications/message_process/include/message_process.hpp b/applications/message_process/include/message_process.hpp index 96da30e..62788b8 100644 --- a/applications/message_process/include/message_process.hpp +++ b/applications/message_process/include/message_process.hpp @@ -53,28 +53,18 @@ public: bool empty() const; size_t available() const; size_t capacity() const; + void reset(); bool read(uint8_t *dst, uint32_t length); bool write(const Vec *vec, size_t length); bool write(const uint32_t type, const void *src = nullptr, uint32_t length = 0); - bool skip(uint32_t length); - - template - bool read(T &dst) { - return read(reinterpret_cast(&dst), sizeof(dst)); - } - template - bool readOrSkip(T &dst, uint32_t expectedLength) { - if (expectedLength == sizeof(dst)) { - return read(reinterpret_cast(&dst), sizeof(dst)); - } else { - return skip(expectedLength); - } + bool write(const uint32_t type, const T &src) { + return write(type, reinterpret_cast(&src), sizeof(src)); } template - bool write(const uint32_t type, const T &src) { - return write(type, reinterpret_cast(&src), sizeof(src)); + bool read(T &dst) { + return read(reinterpret_cast(&dst), sizeof(dst)); } private: @@ -96,6 +86,8 @@ public: void run(); bool handleMessage(); void sendPong(); + void sndErrorRspAndResetQueue(ethosu_core_msg_err_type type, const char *message); + void sendVersionRsp(); void sendInferenceRsp(uint64_t userArg, std::vector &ofm, bool failed, -- cgit v1.2.1