Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Oct 3, 2024
1 parent b8d636b commit 90a6887
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
4 changes: 0 additions & 4 deletions tests/TestFPGA.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ class TestFPGA : public LSST::cRIO::FPGA, public LSST::cRIO::PrintILC {
uint16_t getTxCommand(uint8_t bus) override { return FPGAAddress::MODBUS_A_TX; }
uint16_t getRxCommand(uint8_t bus) override { return FPGAAddress::MODBUS_A_RX; }
uint32_t getIrq(uint8_t bus) override { return 1; }
void writeMPUFIFO(LSST::cRIO::MPU& mpu, const std::vector<uint8_t>& data, uint32_t timeout) override {}
std::vector<uint8_t> readMPUFIFO(LSST::cRIO::MPU&) override {
return std::vector<uint8_t>({0xff, 0x0fe});
}
void writeCommandFIFO(uint16_t* data, size_t length, uint32_t timeout) override;
void writeRequestFIFO(uint16_t* data, size_t length, uint32_t timeout) override;
void readU16ResponseFIFO(uint16_t* data, size_t length, uint32_t timeout) override;
Expand Down
2 changes: 0 additions & 2 deletions tests/test_CSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class TestFPGA : public FPGA {
uint16_t getTxCommand(uint8_t) override { return 0; }
uint16_t getRxCommand(uint8_t) override { return 0; }
uint32_t getIrq(uint8_t) override { return 0; }
void writeMPUFIFO(MPU& mpu, const std::vector<uint8_t>& data, uint32_t timeout) override {}
std::vector<uint8_t> readMPUFIFO(MPU&) override { return std::vector<uint8_t>({0x04, 0x05}); }
void writeCommandFIFO(uint16_t*, size_t, uint32_t) override {}
void writeRequestFIFO(uint16_t*, size_t, uint32_t) override {}
void readU16ResponseFIFO(uint16_t*, size_t, uint32_t) override {}
Expand Down
3 changes: 0 additions & 3 deletions tests/test_FirmwareLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ class TestFPGA : public FPGA {
uint16_t getRxCommand(uint8_t bus) override { return bus + 14; }
uint32_t getIrq(uint8_t bus) override { return 1; }

void writeMPUFIFO(MPU& mpu, const std::vector<uint8_t>& data, uint32_t timeout) override {}
std::vector<uint8_t> readMPUFIFO(MPU& mpu) override { return std::vector<uint8_t>({0x01, 0x02}); }

void writeCommandFIFO(uint16_t* data, size_t length, uint32_t timeout) override;
void writeRequestFIFO(uint16_t* data, size_t length, uint32_t timeout) override {}
void readU16ResponseFIFO(uint16_t* data, size_t length, uint32_t timeout) override;
Expand Down
18 changes: 9 additions & 9 deletions tests/test_MPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ using namespace LSST::cRIO;

class TestMPU : public MPU {
public:
TestMPU(uint8_t bus, uint8_t mpu_address) : MPU(bus, mpu_address) {}
TestMPU(uint8_t mpu_address) : MPU(mpu_address) {}
};

TEST_CASE("Test MPU read input status", "[MPU]") {
TestMPU mpu(1, 0x11);
TestMPU mpu(0x11);
mpu.readInputStatus(0x00C4, 0x0016, 108);

CHECK(mpu.size() == 1);
Expand Down Expand Up @@ -90,7 +90,7 @@ TEST_CASE("Test MPU read input status", "[MPU]") {
}

TEST_CASE("Test MPU read holding registers", "[MPU]") {
TestMPU mpu(1, 12);
TestMPU mpu(12);
mpu.readHoldingRegisters(3, 10, 101);

CHECK(mpu.size() == 1);
Expand Down Expand Up @@ -132,7 +132,7 @@ TEST_CASE("Test MPU read holding registers", "[MPU]") {
}

TEST_CASE("Test MPU reading multiple registers - failed response", "[MPU]") {
TestMPU mpu(1, 12);
TestMPU mpu(12);
mpu.readHoldingRegisters(3, 10, 101);

CHECK(mpu.size() == 1);
Expand Down Expand Up @@ -195,7 +195,7 @@ TEST_CASE("Test MPU reading multiple registers - failed response", "[MPU]") {
}

TEST_CASE("Test MPU reading multiple registers - successful response", "[MPU]") {
TestMPU mpu(1, 12);
TestMPU mpu(12);
mpu.readHoldingRegisters(3, 10, 101);

auto commands = mpu[0].buffer;
Expand Down Expand Up @@ -287,7 +287,7 @@ TEST_CASE("Test MPU reading multiple registers - successful response", "[MPU]")
}

TEST_CASE("Test MPU preset holding register", "[MPU]") {
TestMPU mpu(5, 0x11);
TestMPU mpu(0x11);

mpu.presetHoldingRegister(0x0001, 0x0003, 102);

Expand All @@ -310,7 +310,7 @@ TEST_CASE("Test MPU preset holding register", "[MPU]") {
}

TEST_CASE("Test MPU preset holding registers", "[MPU]") {
TestMPU mpu(5, 17);
TestMPU mpu(17);

std::vector<uint16_t> regs = {0x0102, 0x0304};
mpu.presetHoldingRegisters(0x1718, regs, 102);
Expand Down Expand Up @@ -339,7 +339,7 @@ TEST_CASE("Test MPU preset holding registers", "[MPU]") {
}

TEST_CASE("Test MPU preset holding registers by simplymodbus.ca", "[MPU]") {
TestMPU mpu(5, 0x11);
TestMPU mpu(0x11);

std::vector<uint16_t> regs = {0x000A, 0x0102};
mpu.presetHoldingRegisters(0x0001, regs, 102);
Expand Down Expand Up @@ -368,7 +368,7 @@ TEST_CASE("Test MPU preset holding registers by simplymodbus.ca", "[MPU]") {
}

TEST_CASE("Test responseLength calculations", "[ResponseLength]") {
TestMPU mpu(5, 0x11);
TestMPU mpu(0x11);

CHECK(mpu.responseLength({0x11, 0x83}) == 5);

Expand Down

0 comments on commit 90a6887

Please sign in to comment.