Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation errors in the SoapySDR module and tests #399

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions SoapyLMS7/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ double SoapyLMS7::getGain(const int direction, const size_t channel) const
TRXDir dir = direction == SOAPY_SDR_RX ? TRXDir::Rx : TRXDir::Tx;

double gain = 0;
int returnValue = sdrDevice->GetGain(0, dir, channel, eGainTypes::UNKNOWN, gain);
if (returnValue != 0)
OpStatus returnValue = sdrDevice->GetGain(0, dir, channel, eGainTypes::UNKNOWN, gain);
if (returnValue != OpStatus::SUCCESS)
{
throw std::runtime_error(
"SoapyLMS7::getGain(" + std::string{ dirName } + ", " + std::to_string(channel) + ") - failed to get gain");
Expand Down Expand Up @@ -327,8 +327,8 @@ double SoapyLMS7::getGain(const int direction, const size_t channel, const std::
eGainTypes gainType = STRING_TO_GAIN_TYPES.at(name);

double gain = 0;
int returnValue = sdrDevice->GetGain(0, dir, channel, gainType, gain);
if (returnValue != 0)
OpStatus returnValue = sdrDevice->GetGain(0, dir, channel, gainType, gain);
if (returnValue != OpStatus::SUCCESS)
{
throw std::runtime_error(
"SoapyLMS7::getGain(" + std::string{ dirName } + ", " + std::to_string(channel) + ") - failed to get gain");
Expand Down Expand Up @@ -1127,8 +1127,8 @@ std::vector<std::string> SoapyLMS7::listGPIOBanks(void) const

void SoapyLMS7::writeGPIO(const std::string&, const unsigned value)
{
int r = sdrDevice->GPIOWrite(reinterpret_cast<const uint8_t*>(&value), sizeof(value));
if (r != 0)
OpStatus r = sdrDevice->GPIOWrite(reinterpret_cast<const uint8_t*>(&value), sizeof(value));
if (r != OpStatus::SUCCESS)
{
throw std::runtime_error("SoapyLMS7::writeGPIO() " + std::string(GetLastErrorMessage()));
}
Expand All @@ -1137,8 +1137,8 @@ void SoapyLMS7::writeGPIO(const std::string&, const unsigned value)
unsigned SoapyLMS7::readGPIO(const std::string&) const
{
unsigned buffer(0);
int r = sdrDevice->GPIORead(reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer));
if (r != 0)
OpStatus r = sdrDevice->GPIORead(reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer));
if (r != OpStatus::SUCCESS)
{
throw std::runtime_error("SoapyLMS7::readGPIO() " + std::string(GetLastErrorMessage()));
}
Expand All @@ -1147,8 +1147,8 @@ unsigned SoapyLMS7::readGPIO(const std::string&) const

void SoapyLMS7::writeGPIODir(const std::string&, const unsigned dir)
{
int r = sdrDevice->GPIODirWrite(reinterpret_cast<const uint8_t*>(&dir), sizeof(dir));
if (r != 0)
OpStatus r = sdrDevice->GPIODirWrite(reinterpret_cast<const uint8_t*>(&dir), sizeof(dir));
if (r != OpStatus::SUCCESS)
{
throw std::runtime_error("SoapyLMS7::writeGPIODir() " + std::string(GetLastErrorMessage()));
}
Expand All @@ -1157,8 +1157,8 @@ void SoapyLMS7::writeGPIODir(const std::string&, const unsigned dir)
unsigned SoapyLMS7::readGPIODir(const std::string&) const
{
unsigned buffer(0);
int r = sdrDevice->GPIODirRead(reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer));
if (r != 0)
OpStatus r = sdrDevice->GPIODirRead(reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer));
if (r != OpStatus::SUCCESS)
{
throw std::runtime_error("SoapyLMS7::readGPIODir() " + std::string(GetLastErrorMessage()));
}
Expand Down
2 changes: 1 addition & 1 deletion SoapyLMS7/Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ SoapySDR::Stream* SoapyLMS7::setupStream(

// Create the stream
auto returnValue = sdrDevice->StreamSetup(config, 0);
if (returnValue != 0)
if (returnValue != OpStatus::SUCCESS)
{
throw std::runtime_error("SoapyLMS7::setupStream() failed: " + std::string(GetLastErrorMessage()));
}
Expand Down
24 changes: 13 additions & 11 deletions src/tests/include/limesuite/CommsMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ namespace lime::testing {
class CommsMock : public IComms
{
public:
MOCK_METHOD(int, SPI, (const uint32_t* MOSI, uint32_t* MISO, uint32_t count), (override));
MOCK_METHOD(int, SPI, (uint32_t spiBusAddress, const uint32_t* MOSI, uint32_t* MISO, uint32_t count), (override));
MOCK_METHOD(int, GPIODirRead, (uint8_t * buffer, const size_t bufLength), (override));
MOCK_METHOD(int, GPIORead, (uint8_t * buffer, const size_t bufLength), (override));
MOCK_METHOD(int, GPIODirWrite, (const uint8_t* buffer, const size_t bufLength), (override));
MOCK_METHOD(int, GPIOWrite, (const uint8_t* buffer, const size_t bufLength), (override));
MOCK_METHOD(int, CustomParameterWrite, (const std::vector<CustomParameterIO>& parameters), (override));
MOCK_METHOD(int, CustomParameterRead, (std::vector<CustomParameterIO> & parameters), (override));
MOCK_METHOD(
int, ProgramWrite, (const char* data, size_t length, int prog_mode, int target, ProgressCallback callback), (override));
MOCK_METHOD(int, ResetDevice, (int chipSelect), (override));
MOCK_METHOD(OpStatus, SPI, (const uint32_t* MOSI, uint32_t* MISO, uint32_t count), (override));
MOCK_METHOD(OpStatus, SPI, (uint32_t spiBusAddress, const uint32_t* MOSI, uint32_t* MISO, uint32_t count), (override));
MOCK_METHOD(OpStatus, GPIODirRead, (uint8_t * buffer, const size_t bufLength), (override));
MOCK_METHOD(OpStatus, GPIORead, (uint8_t * buffer, const size_t bufLength), (override));
MOCK_METHOD(OpStatus, GPIODirWrite, (const uint8_t* buffer, const size_t bufLength), (override));
MOCK_METHOD(OpStatus, GPIOWrite, (const uint8_t* buffer, const size_t bufLength), (override));
MOCK_METHOD(OpStatus, CustomParameterWrite, (const std::vector<CustomParameterIO>& parameters), (override));
MOCK_METHOD(OpStatus, CustomParameterRead, (std::vector<CustomParameterIO> & parameters), (override));
MOCK_METHOD(OpStatus,
ProgramWrite,
(const char* data, size_t length, int prog_mode, int target, ProgressCallback callback),
(override));
MOCK_METHOD(OpStatus, ResetDevice, (int chipSelect), (override));
};

} // namespace lime::testing
Expand Down
24 changes: 12 additions & 12 deletions src/tests/protocols/LMS64CProtocol/CustomParameterReadTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ TEST(LMS64CProtocol, CustomParameterReadTestEmptyDoesNothing)
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(0);

std::vector<CustomParameterIO> parameters;
int returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, CustomParameterReadTestOneParameter)
Expand Down Expand Up @@ -87,9 +87,9 @@ TEST(LMS64CProtocol, CustomParameterReadTestOneParameter)
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

std::vector<CustomParameterIO> parameters{ { 16, 0, "" } };
int returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
EXPECT_EQ(parameters[0].value, static_cast<uint16_t>(value));
EXPECT_EQ(parameters[0].units, "");
}
Expand Down Expand Up @@ -130,9 +130,9 @@ TEST(LMS64CProtocol, CustomParameterReadTestSixteenParameters)

EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(2);

int returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, CustomParameterReadCorrectPrefix)
Expand Down Expand Up @@ -161,9 +161,9 @@ TEST(LMS64CProtocol, CustomParameterReadCorrectPrefix)
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

std::vector<CustomParameterIO> parameters{ { 16, 0, "" } };
int returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
EXPECT_EQ(parameters[0].value, value);
EXPECT_EQ(parameters[0].units, "kA");
}
Expand Down Expand Up @@ -194,9 +194,9 @@ TEST(LMS64CProtocol, CustomParameterReadTemperatureCorrection)
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

std::vector<CustomParameterIO> parameters{ { 16, 0, "" } };
int returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
EXPECT_EQ(parameters[0].value, value / 10);
EXPECT_EQ(parameters[0].units, "mC");
}
Expand Down Expand Up @@ -227,9 +227,9 @@ TEST(LMS64CProtocol, CustomParameterReadUnknownUnits)
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

std::vector<CustomParameterIO> parameters{ { 16, 0, "" } };
int returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterRead(mockPort, parameters, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
EXPECT_EQ(parameters[0].value, value);
EXPECT_EQ(parameters[0].units, "u unknown");
}
Expand Down
20 changes: 10 additions & 10 deletions src/tests/protocols/LMS64CProtocol/CustomParameterWriteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ TEST(LMS64CProtocol, CustomParameterWriteTestEmptyDoesNothing)
EXPECT_CALL(mockPort, Write(_, PACKET_SIZE, _)).Times(0);
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(0);

int returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, {}, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, {}, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, CustomParameterWriteTestOneParameter)
Expand All @@ -79,9 +79,9 @@ TEST(LMS64CProtocol, CustomParameterWriteTestOneParameter)
.Times(1);
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

int returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, { { 16, 127.0, "C" } }, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, { { 16, 127.0, "C" } }, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, CustomParameterWriteTestSixteenParameters)
Expand Down Expand Up @@ -120,9 +120,9 @@ TEST(LMS64CProtocol, CustomParameterWriteTestSixteenParameters)

EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(2);

int returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, parameters, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, parameters, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, CustomParameterWriteTestLowValue)
Expand All @@ -147,9 +147,9 @@ TEST(LMS64CProtocol, CustomParameterWriteTestLowValue)
.Times(1);
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

int returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, { { 9, 0.00127, "W" } }, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, { { 9, 0.00127, "W" } }, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, CustomParameterWriteTestHighValue)
Expand All @@ -174,9 +174,9 @@ TEST(LMS64CProtocol, CustomParameterWriteTestHighValue)
.Times(1);
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

int returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, { { 4, 131268, "A" } }, subdevice);
OpStatus returnValue = LMS64CProtocol::CustomParameterWrite(mockPort, { { 4, 131268, "A" } }, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, CustomParameterWriteNotFullyWritten)
Expand Down
4 changes: 2 additions & 2 deletions src/tests/protocols/LMS64CProtocol/DeviceResetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ TEST(LMS64CProtocol, DeviceResetTestCorrectCommand)
.Times(1);
EXPECT_CALL(mockPort, Read(_, PACKET_SIZE, _)).Times(1);

int returnValue = LMS64CProtocol::DeviceReset(mockPort, socIndex, subdevice);
OpStatus returnValue = LMS64CProtocol::DeviceReset(mockPort, socIndex, subdevice);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, DeviceResetTestNotFullyWritten)
Expand Down
48 changes: 24 additions & 24 deletions src/tests/protocols/LMS64CProtocol/FPGA_SPITest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ TEST(LMS64CProtocol, FPGASPIEmptyTest)
EXPECT_CALL(mockPort, Write(_, sizeof(LMS64CPacket), _)).Times(0);
EXPECT_CALL(mockPort, Read(_, sizeof(LMS64CPacket), _)).Times(0);

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, nullptr, nullptr, 0);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, nullptr, nullptr, 0);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, FPGASPIOneCountTestValueRead)
Expand All @@ -63,9 +63,9 @@ TEST(LMS64CProtocol, FPGASPIOneCountTestValueRead)

uint32_t mosi = 1U;
uint32_t miso = 2U;
int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, FPGASPIOneCountTestValueWrite)
Expand All @@ -84,9 +84,9 @@ TEST(LMS64CProtocol, FPGASPIOneCountTestValueWrite)

uint32_t mosi = 1U;
SetWriteBit(mosi);
int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, nullptr, 1);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, nullptr, 1);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, FPGASPIWriteReadReadWrite)
Expand Down Expand Up @@ -118,9 +118,9 @@ TEST(LMS64CProtocol, FPGASPIWriteReadReadWrite)
SetWriteBit(mosi[3]);

std::vector<uint32_t> miso{ 1U, 2U, 3U, 4U };
int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 4);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 4);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, FPGASPIReadWriteReadReadWrite)
Expand Down Expand Up @@ -155,9 +155,9 @@ TEST(LMS64CProtocol, FPGASPIReadWriteReadReadWrite)
SetWriteBit(mosi[4]);

std::vector<uint32_t> miso{ 1U, 2U, 3U, 4U, 5U };
int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 5);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 5);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, FPGASPISixteenWrites)
Expand Down Expand Up @@ -188,9 +188,9 @@ TEST(LMS64CProtocol, FPGASPISixteenWrites)
std::vector<uint32_t> mosis(16, mosi);
std::vector<uint32_t> misos(16, miso);

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosis.data(), misos.data(), 16);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosis.data(), misos.data(), 16);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, FPGASPISixteenReads)
Expand Down Expand Up @@ -220,9 +220,9 @@ TEST(LMS64CProtocol, FPGASPISixteenReads)
std::vector<uint32_t> mosis(16, mosi);
std::vector<uint32_t> misos(16, miso);

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosis.data(), misos.data(), 16);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosis.data(), misos.data(), 16);

EXPECT_EQ(returnValue, 0);
EXPECT_EQ(returnValue, OpStatus::SUCCESS);
}

TEST(LMS64CProtocol, FPGASPINotFullyWritten)
Expand All @@ -237,9 +237,9 @@ TEST(LMS64CProtocol, FPGASPINotFullyWritten)
uint32_t mosi = 1U;
uint32_t miso = 2U;

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);

EXPECT_EQ(returnValue, -1);
EXPECT_EQ(returnValue, OpStatus::IO_FAILURE);
}

TEST(LMS64CProtocol, FPGASPINotFullyRead)
Expand All @@ -260,9 +260,9 @@ TEST(LMS64CProtocol, FPGASPINotFullyRead)
uint32_t mosi = 1U;
uint32_t miso = 2U;

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);

EXPECT_EQ(returnValue, -1);
EXPECT_EQ(returnValue, OpStatus::IO_FAILURE);
}

TEST(LMS64CProtocol, FPGASPIWrongStatus)
Expand All @@ -283,9 +283,9 @@ TEST(LMS64CProtocol, FPGASPIWrongStatus)
uint32_t mosi = 1U;
uint32_t miso = 2U;

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, &mosi, &miso, 1);

EXPECT_EQ(returnValue, -1);
EXPECT_EQ(returnValue, OpStatus::IO_FAILURE);
}

TEST(LMS64CProtocol, FPGASPINotFullyWrittenOnSecondCall)
Expand All @@ -306,9 +306,9 @@ TEST(LMS64CProtocol, FPGASPINotFullyWrittenOnSecondCall)

std::vector<uint32_t> miso{ 1U, 2U };

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 2);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 2);

EXPECT_EQ(returnValue, -1);
EXPECT_EQ(returnValue, OpStatus::IO_FAILURE);
}

TEST(LMS64CProtocol, FPGASPINotFullyReadOnSecondCall)
Expand All @@ -329,7 +329,7 @@ TEST(LMS64CProtocol, FPGASPINotFullyReadOnSecondCall)

std::vector<uint32_t> miso{ 1U, 2U };

int returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 2);
OpStatus returnValue = LMS64CProtocol::FPGA_SPI(mockPort, mosi.data(), miso.data(), 2);

EXPECT_EQ(returnValue, -1);
EXPECT_EQ(returnValue, OpStatus::IO_FAILURE);
}
Loading
Loading