Skip to content

Commit

Permalink
Adjusted telemetry to FPGA changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Sep 19, 2024
1 parent 5168ddd commit af1dde9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 62 deletions.
2 changes: 1 addition & 1 deletion doc/version-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version History

v1.12.0
-------
* simplified MPU commonication
* simplified MPU communication

v1.11.1
-------
Expand Down
37 changes: 4 additions & 33 deletions include/cRIO/MPUTelemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class message>
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
Expand Down
10 changes: 4 additions & 6 deletions src/LSST/cRIO/MPUTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
namespace LSST {
namespace cRIO {

MPUTelemetry::MPUTelemetry(uint8_t *data) {
writeBytes = be32toh(*(reinterpret_cast<uint32_t *>(data + 0)));
readBytes = be32toh(*(reinterpret_cast<uint32_t *>(data + 4)));
readTimedout = be16toh(*(reinterpret_cast<uint16_t *>(data + 8)));
MPUTelemetry::MPUTelemetry(const uint8_t *data) {
writeBytes = be64toh(*(reinterpret_cast<const uint64_t *>(data + 0)));
readBytes = be64toh(*(reinterpret_cast<const uint64_t *>(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;
}

Expand Down
26 changes: 4 additions & 22 deletions tests/test_MPUTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit af1dde9

Please sign in to comment.