Skip to content
Snippets Groups Projects
Commit 0f279ac5 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

Using new Device::isFunctional() to check for device errors in the DeviceModule

parent b4f9dddb
No related branches found
No related tags found
No related merge requests found
......@@ -347,10 +347,16 @@ namespace ChimeraTK {
errorLock.unlock(); // we must not hold the error lock when not having the testable mode mutex
std::cout << "giving up testable mode lock, sleeping..." << std::endl;
owner->testableModeUnlock("Wait for recovery");
usleep(500000);
do{
usleep(500000);
boost::this_thread::interruption_point();
}while(!device.isFunctional());
owner->testableModeLock("Try recovery");
std::cout << "go back the testable mode lock" << std::endl;
errorLock.lock();
std::cout << "got the error lock"<< std::endl;
// FIXME: we have to wait here until the device reports that it is functional again.
// Otherwise we spam the error reporting with 2 Hz.
......
......@@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(testInitialisationException) {
CHECK_EQUAL_TIMEOUT(test.readScalar<std::string>(ctk::RegisterPath("/Devices") / deviceCDD / "message"), exceptionMessage, 3000);
// Now fix the initialisation error and check that the device comes up.
throwInInitialisation = false;
//throwInInitialisation = false;
// Wait until the device is OK again
CHECK_EQUAL_TIMEOUT(test.readScalar<int32_t>(ctk::RegisterPath("/Devices") / deviceCDD / "status"), 0, 3000);
CHECK_EQUAL_TIMEOUT(test.readScalar<std::string>(ctk::RegisterPath("/Devices") / deviceCDD / "message"), "", 3000);
......
......@@ -303,6 +303,7 @@ BOOST_AUTO_TEST_CASE(testExceptionHandlingOpen) {
}
BOOST_AUTO_TEST_CASE(testConstants){
std::cout << "testConstants" << std::endl;
// Constants are registered to the device to be written when opening/recovering
// Attention: This test does not test that errors when writing to constants are displayed correctly. It only checks that witing when opeing and recovering works.
TestApplication app;
......@@ -327,6 +328,8 @@ BOOST_AUTO_TEST_CASE(testConstants){
auto pleaseWriteToMe = test.getScalar<int32_t>("/PleaseWriteToMe");
pleaseWriteToMe = 42;
std::cout << "here goes nothing " << std::endl;
sleep(1);
pleaseWriteToMe.write();
test.stepApplication();
......
......@@ -17,6 +17,9 @@ class ExceptionDummy : public ChimeraTK::DummyBackend {
throw(ChimeraTK::runtime_error("DummyException: This is a test"));
}
ChimeraTK::DummyBackend::open();
if (throwExceptionRead ||throwExceptionWrite){
throw(ChimeraTK::runtime_error("DummyException: open throws because of device error when already open."));
}
}
void read(uint8_t bar, uint32_t address, int32_t* data, size_t sizeInBytes) override {
......@@ -33,6 +36,10 @@ class ExceptionDummy : public ChimeraTK::DummyBackend {
ChimeraTK::DummyBackend::write(bar, address, data, sizeInBytes);
}
bool isFunctional() const override{
return (_opened && !throwExceptionOpen && !throwExceptionRead && !throwExceptionWrite);
}
class BackendRegisterer {
public:
BackendRegisterer();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment