From fa2abd01ca9dadcb4ccc98fd0f350473b1f47a1d Mon Sep 17 00:00:00 2001 From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr> Date: Fri, 15 Jul 2016 13:34:38 +0000 Subject: [PATCH] No more retry done if no response received from the hardware, instead an exception is thrown --- src/TangoSerialLink.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/TangoSerialLink.cpp b/src/TangoSerialLink.cpp index d5bfcc1..fb7e2b3 100644 --- a/src/TangoSerialLink.cpp +++ b/src/TangoSerialLink.cpp @@ -268,17 +268,25 @@ std::string TangoSerialLink::write_read (std::string command_to_send, size_t nbC //- sleep a little bit to let the adapter(RS232/485) to switch mode omni_thread::sleep(0, 100000000); //100 milliseconds - //- wait till characters are available in the input buffer (max 30 retries !) - size_t nbRetries = 0; + //- No more retry! (for test purpose) //- wait till characters are available in the input buffer (max 3 retries !) + //size_t nbRetries = 0; Tango::DevLong nbCharReceived = 0; dd_out = this->_serial_proxy->command_inout("DevSerGetNChar"); - dd_out >> nbCharReceived; - while ( !nbCharReceived && nbRetries < 50 ) + dd_out >> nbCharReceived; + //- if no response throw ! + if ( !nbCharReceived ) { - dd_out = this->_serial_proxy->command_inout("DevSerGetNChar"); - dd_out >> nbCharReceived; - nbRetries++; -//std::cout << "TangoSerialLink::write_read -> nbRetries = " << nbRetries << " & nbCharReceived = " << nbCharReceived << std::endl; +// dd_out = this->_serial_proxy->command_inout("DevSerGetNChar"); +// dd_out >> nbCharReceived; +// nbRetries++; +//std::cout << "TangoSerialLink::write_read -> nbRetries = " << nbRetries << " & nbCharReceived = " << nbCharReceived << std::endl; + std::string desc(""); + desc = "No response received from the hardware for command : " + command_to_send; + Tango::Except::throw_exception ( + "COMMUNICATION_ERROR", + desc, + "TangoSerialLink::write_read"); + } //std::cout << "END WHILE -> nbRetries = " << nbRetries << " & nbCharReceived = " << nbCharReceived << std::endl; -- GitLab