diff --git a/doc/version-history.rst b/doc/version-history.rst index 9664264..23c3c91 100644 --- a/doc/version-history.rst +++ b/doc/version-history.rst @@ -4,7 +4,7 @@ Version History v1.12.0 ------- -* simplified MPU commonication +* simplified MPU communication v1.11.1 ------- diff --git a/include/cRIO/MPUTelemetry.h b/include/cRIO/MPUTelemetry.h index 5373287..87c415d 100644 --- a/include/cRIO/MPUTelemetry.h +++ b/include/cRIO/MPUTelemetry.h @@ -38,41 +38,12 @@ class MPUTelemetry { * * @param data[45] data as received from FPGA */ - MPUTelemetry(uint8_t* data); - uint32_t writeBytes; /// Number of bytes written - uint32_t readBytes; /// Number of bytes read - uint16_t readTimedout; /// read timedout counter + MPUTelemetry(const uint8_t* data); - friend std::ostream& operator<<(std::ostream& os, const MPUTelemetry& tel); + uint64_t writeBytes; /// Number of bytes written + uint64_t readBytes; /// Number of bytes read - /** - * Updates MPU telemetry SAL message structure. - * - * @tparam message class with telemetry filed. Shall be SAL declared class - * @param msg message to check and update - * - * @return true if message shall be send, false if updates are minor and it should not be send - */ - template - bool sendUpdates(message* msg) { - return false; - - /** - if (msg->readBytes != readBytes || msg->writeTimedout != writeTimedout || - msg->instructionPointerOnError != instructionPointerOnError || msg->errorCode != errorCode) { - send = true; - } - msg->instructionPointer = instructionPointer; - msg->outputCounter = outputCounter; - msg->inputCounter = inputCounter; - msg->outputTimeouts = outputTimeouts; - msg->inputTimeouts = inputTimeouts; - msg->instructionPointerOnError = instructionPointerOnError; - msg->writeTimeout = writeTimeout; - msg->readTimeout = readTimeout; - msg->errorCode = errorCode; - return send; */ - } + friend std::ostream& operator<<(std::ostream& os, const MPUTelemetry& tel); }; } // namespace cRIO diff --git a/src/LSST/cRIO/MPUTelemetry.cpp b/src/LSST/cRIO/MPUTelemetry.cpp index 0cbd4fc..8f21343 100644 --- a/src/LSST/cRIO/MPUTelemetry.cpp +++ b/src/LSST/cRIO/MPUTelemetry.cpp @@ -31,16 +31,14 @@ namespace LSST { namespace cRIO { -MPUTelemetry::MPUTelemetry(uint8_t *data) { - writeBytes = be32toh(*(reinterpret_cast(data + 0))); - readBytes = be32toh(*(reinterpret_cast(data + 4))); - readTimedout = be16toh(*(reinterpret_cast(data + 8))); +MPUTelemetry::MPUTelemetry(const uint8_t *data) { + writeBytes = be64toh(*(reinterpret_cast(data + 0))); + readBytes = be64toh(*(reinterpret_cast(data + 8))); } std::ostream &operator<<(std::ostream &os, const MPUTelemetry &tel) { os << std::setw(20) << "Write bytes: " << tel.writeBytes << std::endl - << std::setw(20) << "Read bytes: " << tel.readBytes << std::endl - << std::setw(20) << "Read timedout: " << tel.readTimedout << std::endl; + << std::setw(20) << "Read bytes: " << tel.readBytes << std::endl; return os; } diff --git a/tests/test_MPUTelemetry.cpp b/tests/test_MPUTelemetry.cpp index 5d29c2f..b6e4348 100644 --- a/tests/test_MPUTelemetry.cpp +++ b/tests/test_MPUTelemetry.cpp @@ -29,31 +29,13 @@ using namespace LSST::cRIO; uint8_t data[16] = { - 0x01, 0x02, 0x03, 0x04, // write bytes - 0x05, 0x06, 0x07, 0x08, // read HW bytes + 0x01, 0x02, 0x03, 0x04, 0x10, 0x20, 0x30, 0x40, // write bytes + 0x05, 0x06, 0x07, 0x08, 0x50, 0x60, 0x70, 0x80 // read HW bytes }; TEST_CASE("Test MPU telemetry class", "[MPUTelemetry]") { MPUTelemetry mpuTel(data); - REQUIRE(mpuTel.writeBytes == 0x01020304); -} - -struct testMsg_t { - uint32_t writeBytes; // Written bytes -}; - -TEST_CASE("Test MPU sending", "[MPUTelemetry]") { - MPUTelemetry mpuTel(data); - - struct testMsg_t testMsg; - memset(&testMsg, '0', sizeof(testMsg)); - - // TODO add test once telemetry will be again reporetd through SAL - - // REQUIRE(mpuTel.sendUpdates(&testMsg) == true); - // REQUIRE(mpuTel.sendUpdates(&testMsg) == false); - - // REQUIRE(mpuTel.sendUpdates(&testMsg) == true); - // REQUIRE(mpuTel.sendUpdates(&testMsg) == false); + CHECK(mpuTel.writeBytes == 0x0102030410203040); + CHECK(mpuTel.readBytes == 0x0506070850607080); }