From 7afd328da13129ca7fed8b1b3e8477425231e537 Mon Sep 17 00:00:00 2001
From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr>
Date: Wed, 18 Mar 2009 10:25:29 +0000
Subject: [PATCH] xavier : - Novelec part updated and tested ! - +no more
 compilation warnings

---
 include/NovelecProtocol.h         |  4 +--
 include/TangoGpibLink.h           |  2 --
 src/AbstractElectrometerClass.cpp | 21 ++++++++----
 src/KeithleyDDCProtocol.cpp       | 13 ++-----
 src/Keithley_485.cpp              |  1 -
 src/Keithley_486.cpp              |  1 -
 src/Keithley_487.cpp              |  1 -
 src/Keithley_617.cpp              |  3 +-
 src/Keithley_6485.cpp             |  1 -
 src/Keithley_6487.cpp             |  1 -
 src/Keithley_6512.cpp             |  1 -
 src/Keithley_6514.cpp             |  1 -
 src/Keithley_6517.cpp             |  2 --
 src/Makefile.linux                |  8 +++--
 src/NovelecProtocol.cpp           | 32 +++++++++---------
 src/Novelec_MCCE2.cpp             |  4 +--
 src/TangoGpibLink.cpp             | 56 +++++++++++--------------------
 src/TangoSerialLink.cpp           | 24 ++++++++-----
 18 files changed, 79 insertions(+), 97 deletions(-)

diff --git a/include/NovelecProtocol.h b/include/NovelecProtocol.h
index 7ebd93f..1d4c12c 100644
--- a/include/NovelecProtocol.h
+++ b/include/NovelecProtocol.h
@@ -100,8 +100,8 @@ public:
 protected :
 	short _devAdd;								//- novelec active channel address
 	short _novType;								//- novelec type number (1 to 5)
-	short _rangeParameterNum;					//-	command number for the range 
-	std::string _function;						//- the novelec mode
+	short _rangeParameterNum;			//-	command number for the range 
+	std::string _function;				//- the novelec mode
 	
 	//- check if the cmd is understood
 	void check_command	(std::string resp_to_check);
diff --git a/include/TangoGpibLink.h b/include/TangoGpibLink.h
index 1384f0e..9ca083d 100644
--- a/include/TangoGpibLink.h
+++ b/include/TangoGpibLink.h
@@ -99,8 +99,6 @@ private :
 	void create_gpib_proxy(void) throw (Tango::DevFailed);
   
 	Tango::DeviceProxyHelper* _gpib_proxy;
-
-	bool _is_gpib_proxy_created;
 	
 	std::string response;
 
diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp
index 960ed64..fd00e50 100644
--- a/src/AbstractElectrometerClass.cpp
+++ b/src/AbstractElectrometerClass.cpp
@@ -11,9 +11,14 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.16 $
+// $Revision: 1.17 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.16  2009/03/10 10:28:52  xavela
+// xavier:
+// range values ordered
+// set_range added
+//
 // Revision 1.15  2009/01/19 12:00:25  xavela
 // xavier :
 // - MCCE2 (Novelec part) : methods to change the active channel to communicate with.
@@ -109,13 +114,15 @@
 // AbstractElectrometerClass::AbstractElectrometerClass
 // ============================================================================
 AbstractElectrometerClass::AbstractElectrometerClass (std::string comLink_device_name)
-:	_device_proxy_name(comLink_device_name),
+:	electrometerState(UNKNOWN),
 	_range(0),
 	_rangeStr("NOT INITIALISED"),
 	_mode("NOT INITIALISED"),
+	_device_proxy_name(comLink_device_name),
+	_electrometerProtocol(0),
 	_size(-1),
-	_trigMod(-1),
-	electrometerState(UNKNOWN)
+	_trigMod(-1)
+	
 {
 //	std::cout << "AbstractElectrometerClass::AbstractElectrometerClass <-" << std::endl;
 
@@ -228,7 +235,7 @@ void AbstractElectrometerClass::abort (void)
 // ============================================================================
 // AbstractElectrometerClass::set_knplc
 // ============================================================================
-void AbstractElectrometerClass::set_knplc (float nplcValueStr) 
+void AbstractElectrometerClass::set_knplc (float) 
 {
 	throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", 
 											"This Electrometer does not support this command.",
@@ -256,7 +263,7 @@ void AbstractElectrometerClass::set_triggerMode (short)
 // ============================================================================
 // AbstractElectrometerClass::set_triggercount
 // ============================================================================
-void AbstractElectrometerClass::set_triggercount (short trigCountStr) 
+void AbstractElectrometerClass::set_triggercount (short ) 
 {
 	throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", 
 											"This Electrometer does not support this command.",
@@ -473,7 +480,7 @@ std::string AbstractElectrometerClass::electrometer_status (void)
 // ============================================================================
 // AbstractElectrometerClass::set_buffer_size
 // ============================================================================
-void AbstractElectrometerClass::set_buffer_size (short size) 
+void AbstractElectrometerClass::set_buffer_size (short ) 
 {
   // force read of range on instrument to update _range variable
 	throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", 
diff --git a/src/KeithleyDDCProtocol.cpp b/src/KeithleyDDCProtocol.cpp
index 2091849..43204a0 100644
--- a/src/KeithleyDDCProtocol.cpp
+++ b/src/KeithleyDDCProtocol.cpp
@@ -340,28 +340,23 @@ std::string dataStr("");
 std::vector<double> argout;
 std::string::size_type posBeg;
 std::string::size_type posEnd;
-short numberOfData = 0;
+
 	//- 
 	posBeg = 0;
 	posEnd = datalist.find(',', posBeg);
-//-DEBUG std::cout << "\t*****::buildDataList -> argin :\n$" << datalist << "$" << std::endl;
+
   //- there is just one value
   if(posEnd == std::string::npos)
   {
 		  argout.push_back( XString<double>::convertFromString(datalist) );
-//-DEBUG std::cout << "\t*****::buildDataList -> JUST ONE DATA :$" << datalist << "$" << std::endl;
   }
   else
   {
-//	  int i = 0;
-    //std::string tmp = get_triggercount();
-//    numberOfData =  XString<short>::convertFromString(get_triggercount());
-
     for(; posEnd != std::string::npos; )
     {
 		  dataStr = datalist.substr(posBeg,posEnd);
 		  argout.push_back( XString<double>::convertFromString(dataStr) );
-//-DEBUG std::cout << "\t*****::buildDataList -> FULL OF DATA : " << i << " -> $" << argout[i] << "$" << std::endl;
+
       posBeg = posEnd+1;
 		  posEnd = datalist.find(',', posBeg);
 
@@ -372,10 +367,8 @@ short numberOfData = 0;
    		  argout.push_back( XString<double>::convertFromString(dataStr) );
         break;
       }
-
     }
   }
-
 	return argout;
 }
 
diff --git a/src/Keithley_485.cpp b/src/Keithley_485.cpp
index bb34279..6d53f39 100644
--- a/src/Keithley_485.cpp
+++ b/src/Keithley_485.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 485;
 
 // ============================================================================
 // DEPENDENCIES
diff --git a/src/Keithley_486.cpp b/src/Keithley_486.cpp
index da5dea6..f7a6831 100644
--- a/src/Keithley_486.cpp
+++ b/src/Keithley_486.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 486;
 
 // ============================================================================
 // DEPENDENCIES
diff --git a/src/Keithley_487.cpp b/src/Keithley_487.cpp
index 483d2fe..7e7f1fd 100644
--- a/src/Keithley_487.cpp
+++ b/src/Keithley_487.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 487;
 
 // ============================================================================
 // DEPENDENCIES
diff --git a/src/Keithley_617.cpp b/src/Keithley_617.cpp
index 2d91a26..8ee8b25 100644
--- a/src/Keithley_617.cpp
+++ b/src/Keithley_617.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 617;
 
 // ============================================================================
 // DEPENDENCIES
@@ -136,7 +135,7 @@ std::string Keithley_617::get_ElectroMeterRange (void)
 // ============================================================================
 // Keithley_617::set_buffer_size()
 // ============================================================================
-void Keithley_617::set_buffer_size (short cmd) 
+void Keithley_617::set_buffer_size (short ) 
 {
 
 		throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", 
diff --git a/src/Keithley_6485.cpp b/src/Keithley_6485.cpp
index a8ced38..6c4331d 100644
--- a/src/Keithley_6485.cpp
+++ b/src/Keithley_6485.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 6485;
 
 // ============================================================================
 // DEPENDENCIES
diff --git a/src/Keithley_6487.cpp b/src/Keithley_6487.cpp
index 656f226..b9ee2b9 100644
--- a/src/Keithley_6487.cpp
+++ b/src/Keithley_6487.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 6487;
 
 // ============================================================================
 // DEPENDENCIES
diff --git a/src/Keithley_6512.cpp b/src/Keithley_6512.cpp
index 8ae2737..8307f0d 100644
--- a/src/Keithley_6512.cpp
+++ b/src/Keithley_6512.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 6512;
 
 // ============================================================================
 // DEPENDENCIES
diff --git a/src/Keithley_6514.cpp b/src/Keithley_6514.cpp
index fd17f29..19dc4b7 100644
--- a/src/Keithley_6514.cpp
+++ b/src/Keithley_6514.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 6514;
 
 // ============================================================================
 // DEPENDENCIES
diff --git a/src/Keithley_6517.cpp b/src/Keithley_6517.cpp
index b5ea7d4..3e012c5 100644
--- a/src/Keithley_6517.cpp
+++ b/src/Keithley_6517.cpp
@@ -10,7 +10,6 @@
 //    X. Elattaoui
 //
 // ============================================================================
-static long KEITHLEY_MODEL = 6517;
 
 // ============================================================================
 // DEPENDENCIES
@@ -403,7 +402,6 @@ std::stringstream cmd_to_send;
 
   if(numPLC <= 0 || numPLC > 10.0)
 	{
-//    std::cout << "Keithley_6517::set_knplc -> " << numPLC << std::endl;
 		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
 												"Invalid number of PLC.\n Please enter a value in the range 0.01 to 10.0.",
 												"Keithley_6517::set_knplc( ).");
diff --git a/src/Makefile.linux b/src/Makefile.linux
index ac62104..cdcb730 100644
--- a/src/Makefile.linux
+++ b/src/Makefile.linux
@@ -6,9 +6,13 @@
 #
 # $Author: xavela $
 #
-# $Revision: 1.5 $
+# $Revision: 1.6 $
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.5  2008/04/16 08:40:32  xavela
+# xavier :
+# lib compiled on Linux platform
+#
 # Revision 1.4  2008/02/15 10:17:57  xavela
 # xavier :
 # - command abort added for SCPI Keithleys
@@ -52,7 +56,7 @@
 #		 of a library with no Tango dependencies)
 #
 OUTPUT_TYPE = STATIC_LIB
-#RELEASE_TYPE = DEBUG
+RELEASE_TYPE = RELEASE
 #=============================================================================
 # OUTPUT_DIR  is the directory which contains the build result.
 # if not set, the standard location is :
diff --git a/src/NovelecProtocol.cpp b/src/NovelecProtocol.cpp
index 9d29ac3..ddd3898 100644
--- a/src/NovelecProtocol.cpp
+++ b/src/NovelecProtocol.cpp
@@ -33,7 +33,7 @@ static const short	RANGE_CMD_NUM		= 8;
 static const short	RESPONSE_LGTH_CMD_NUM = 17;
 static const short	CLEAR_ERRORS_CMD_NUM  = 18;
 //- the specific new line character
-static const char	END_OF_LINE[] = {13, 10, 0};
+static const string	END_OF_LINE = "\r\n";
 //- modes allowed
 static const std::string mode_str[]		= {"ERR : UNKNOWN MODE","ZERO V/F","OFFSET","LEAKAGE","TEST","MEASURE"};
 static const std::string range_str[5][8]= {	{"1e-11AcC","3e-11AcC","1e-10AcC","3e-10AcC", "OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE"},
@@ -52,13 +52,14 @@ static const std::string gain_str[]		= {"1","10","100"};
 NovelecProtocol::NovelecProtocol (std::string& serial_device_name, short devAddress, short novelecType)
 :	ElectrometerProtocol(),
 	_devAdd(devAddress),
-	_novType(novelecType),
-	_is_measure_mode_on(false)
+	_novType(novelecType)
 {
 
 	_communication_link = new TangoSerialLink (serial_device_name);
 	_rangeParameterNum	= _novType + 2;
-
+	_function = "Not updated";
+	_is_measure_mode_on = false;
+	_is_explicite_resp_enabled = false;
 }
 
 // ============================================================================
@@ -69,24 +70,21 @@ void NovelecProtocol::init_MCCE2_for_communication(void)
 std::stringstream explicite_resp;
 std::string tmp("no data");
 
-	std::cout << "NovelecProtocol::init_MCCE2_for_communication(void) -> ENTERING ... ADDRESS = " << this->_devAdd << std::endl;
 	//- CMD to enable PROG cmds
 	this->switch_MCCE2_OFF();  //- this command is now called in the MCCE2 device !
-	std::cout << "NovelecProtocol::switch_MCCE2_OFF() -> DONE !!!" << std::endl;
 
 	//- Clear error registers
 	this->clear_registers();
-	std::cout << "NovelecProtocol::clear_registers() -> DONE !!!" << std::endl;
 
 	//- send cmd to have an explicite response :
 	explicite_resp << _devAdd << " PROG " << RESPONSE_LGTH_CMD_NUM << " 1" << END_OF_LINE << std::endl;
 	tmp = _communication_link->write_read(explicite_resp.str());
+
 	//- check only the command response
 	check_command(tmp);
+	
 	//- if no error
 	_is_explicite_resp_enabled = true;
-	std::cout << "NovelecProtocol::init_MCCE2_for_communication(void) -> DONE !!!" << std::endl;
-
 }
 
 // ============================================================================
@@ -121,14 +119,14 @@ std::string tmp("no data");
 // ============================================================================
 void NovelecProtocol::switch_MCCE2_OFF (void) 
 {
-std::stringstream toto;
+std::stringstream cmd_to_send;
 std::string tmp("no data");
 
-std::cout << "NovelecProtocol::switch_MCCE2_OFF : _devAdd" << _devAdd << endl;
 	//- send cmd to have a explicite response :
-	toto << _devAdd << " MEASURE 0 " << END_OF_LINE << std::ends;
-std::cout << "\n\n NovelecProtocol::switch_MCCE2_OFF -> CMD = [" << toto.str() << "]" << std::endl;
-	tmp = _communication_link->write_read(toto.str());
+	cmd_to_send << _devAdd << " MEASURE 0 " << END_OF_LINE << std::endl;
+
+	tmp = _communication_link->write_read(cmd_to_send.str());
+
 	//- check only the command response
 	check_command(tmp);
 
@@ -147,6 +145,7 @@ std::string tmp("no data");
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << MODE_CMD_NUM << END_OF_LINE << std::endl;
 	tmp = _communication_link->write_read(cmd_to_send.str());
+
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, MODE_CMD_NUM);
 
@@ -364,11 +363,12 @@ std::string NovelecProtocol::get_frequency (void)
 {
 std::stringstream cmd_to_send;
 std::string argout("no data");
-std::string tmp("no data");
+std::string tmp("");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << FREQUENCY_CMD_NUM << END_OF_LINE << std::endl;
 	tmp = _communication_link->write_read(cmd_to_send.str());
+	
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, FREQUENCY_CMD_NUM);
 
@@ -637,6 +637,7 @@ std::string cmd_sentStr;
 				*/
 				//- extract char
 				response = response.substr(18,1);
+				
 				//- check what is this char a 'space' or 'letter'
 				if(response.find(" ") != std::string::npos)
 					_is_explicite_resp_enabled = false;
@@ -657,6 +658,5 @@ std::string cmd_sentStr;
 													"Invalid string received from Novelec device.",
 													"NovelecProtocol::check_and_extract_data( ).");
 
-
 	return data;
 }
diff --git a/src/Novelec_MCCE2.cpp b/src/Novelec_MCCE2.cpp
index 482a575..e180960 100644
--- a/src/Novelec_MCCE2.cpp
+++ b/src/Novelec_MCCE2.cpp
@@ -27,8 +27,8 @@
 // ============================================================================
 Novelec_MCCE2::Novelec_MCCE2 (std::string& comLink_device_name, short address, short novTypeNumber)
 :	AbstractElectrometerClass(comLink_device_name),
-	_MCCE2electroTypeNumber(novTypeNumber),
-	_rangeLimit(0)
+	_rangeLimit(0),
+	_MCCE2electroTypeNumber(novTypeNumber)
 {
 	//std::cout << "Novelec_MCCE2::Novelec_MCCE2 <-" << std::endl;
 
diff --git a/src/TangoGpibLink.cpp b/src/TangoGpibLink.cpp
index e4041f7..6e87b93 100644
--- a/src/TangoGpibLink.cpp
+++ b/src/TangoGpibLink.cpp
@@ -24,8 +24,7 @@
 // ============================================================================
 TangoGpibLink::TangoGpibLink (std::string& gpib_device_name) 
 :	CommunicationLink(gpib_device_name),
-_gpib_proxy (0),
-_is_gpib_proxy_created (false)
+_gpib_proxy (0)
 {
 	std::cout << "TangoGpibLink::TangoGpibLink <-" << std::endl;
 	
@@ -41,11 +40,10 @@ TangoGpibLink::~TangoGpibLink (void)
 {
 	std::cout << "TangoGpibLink::~TangoGpibLink <-" << std::endl;
 	
-	if(_is_gpib_proxy_created)
+	if(_gpib_proxy)
 	{
 		delete _gpib_proxy;
 		_gpib_proxy = 0;
-		_is_gpib_proxy_created = false;
 	}
 	
 	std::cout << "TangoGpibLink::~TangoGpibLink ->" << std::endl;
@@ -63,19 +61,16 @@ void TangoGpibLink::create_gpib_proxy (void)  throw (Tango::DevFailed)
 	{
 		//- try
 		this->_gpib_proxy = new Tango::DeviceProxyHelper(_communication_Device_name);
-		_is_gpib_proxy_created = true;
 	}
 	catch(Tango::DevFailed& df )
 	{
 		description = "Unable to create proxy on : " + _communication_Device_name;
-		_is_gpib_proxy_created = false;
 		
 		Tango::Except::re_throw_exception (df,
 			(const char*)"COMMUNICATION_ERROR",
 			description.c_str(),
 			(const char*)"TangoGpibLink::create_gpib_proxy");
-	}
-	
+	}	
 }
 
 
@@ -86,7 +81,7 @@ void TangoGpibLink::write (std::string command_to_send)  throw (Tango::DevFailed
 {
   std::string description("");
 	
-	if(!_is_gpib_proxy_created)
+	if(!_gpib_proxy)
 		create_gpib_proxy();
 	
 	try
@@ -113,7 +108,7 @@ void TangoGpibLink::write (std::string command_to_send)  throw (Tango::DevFailed
 std::string TangoGpibLink::read (void) throw (Tango::DevFailed)
 {
 	
-	if(!_is_gpib_proxy_created)
+	if(!_gpib_proxy)
 		create_gpib_proxy();
 	
 	try
@@ -130,7 +125,6 @@ std::string TangoGpibLink::read (void) throw (Tango::DevFailed)
 	}
 	
 	return this->response ;
-
 }
 
 // ============================================================================
@@ -140,15 +134,13 @@ std::string TangoGpibLink::write_read (std::string command_to_send) throw (Tango
 {
   std::string description("");
 	
-	if(!_is_gpib_proxy_created)
+	if(!_gpib_proxy)
 		create_gpib_proxy();
 	
 	try
 	{
 		//- try
-		this->_gpib_proxy->command_inout("WriteRead",  command_to_send, response);
-		return this->response;
-		
+		this->_gpib_proxy->command_inout("WriteRead",  command_to_send, response);		
 	}
 	catch(Tango::DevFailed& df )
 	{
@@ -157,10 +149,9 @@ std::string TangoGpibLink::write_read (std::string command_to_send) throw (Tango
 		Tango::Except::re_throw_exception (df,
 			(const char*)"COMMUNICATION_ERROR",
 			description.c_str(),
-			(const char*)"TangoGpibLink::write_read");
-		
+			(const char*)"TangoGpibLink::write_read");		
 	}
-	
+	return this->response;
 }
 
 // ============================================================================
@@ -171,15 +162,13 @@ bool TangoGpibLink::SRQLineState (void) throw (Tango::DevFailed)
   std::string description("");
   bool result = false;
 	
-	if(!_is_gpib_proxy_created)
+	if(!_gpib_proxy)
 		create_gpib_proxy();
 	
 	try
 	{
 		//- try
-		this->_gpib_proxy->command_out("IsSRQLineUP",  result);
-		return result;
-		
+		this->_gpib_proxy->command_out("IsSRQLineUP",  result);	
 	}
 	catch(Tango::DevFailed& df )
 	{
@@ -191,7 +180,8 @@ bool TangoGpibLink::SRQLineState (void) throw (Tango::DevFailed)
 			(const char*)"TangoGpibLink::SRQLineState");
 		
 	}
-	
+
+	return result;
 }
 
 // ============================================================================
@@ -202,15 +192,13 @@ short TangoGpibLink::readStatusByteRegister (void) throw (Tango::DevFailed)
   std::string description("");
   short result = -1;
 	
-	if(!_is_gpib_proxy_created)
+	if(!_gpib_proxy)
 		create_gpib_proxy();
 	
 	try
 	{
 		//- try
 		this->_gpib_proxy->read_attribute("statusByteRegister",  result);
-		return result;
-		
 	}
 	catch(Tango::DevFailed& df )
 	{
@@ -221,8 +209,8 @@ short TangoGpibLink::readStatusByteRegister (void) throw (Tango::DevFailed)
 			description.c_str(),
 			(const char*)"TangoGpibLink::readStatusByteRegister");
 		
-	}
-	
+	}	
+	return result;
 }
 
 // ============================================================================
@@ -232,7 +220,7 @@ void TangoGpibLink::clear (void) throw (Tango::DevFailed)
 {
   std::string description("");
 	
-	if(!_is_gpib_proxy_created)
+	if(!_gpib_proxy)
 		create_gpib_proxy();
 	
 	try
@@ -247,10 +235,8 @@ void TangoGpibLink::clear (void) throw (Tango::DevFailed)
 		Tango::Except::re_throw_exception (df,
 			(const char*)"COMMUNICATION_ERROR",
 			description.c_str(),
-			(const char*)"TangoGpibLink::clear");
-		
-	}
-	
+			(const char*)"TangoGpibLink::clear");		
+	}	
 }
 
 // ============================================================================
@@ -260,7 +246,7 @@ void TangoGpibLink::trigger (void) throw (Tango::DevFailed)
 {
   std::string description("");
 	
-	if(!_is_gpib_proxy_created)
+	if(!_gpib_proxy)
 		create_gpib_proxy();
 	
 	try
@@ -276,8 +262,6 @@ void TangoGpibLink::trigger (void) throw (Tango::DevFailed)
 			(const char*)"COMMUNICATION_ERROR",
 			description.c_str(),
 			(const char*)"TangoGpibLink::clear");
-		
 	}
-	
 }
 
diff --git a/src/TangoSerialLink.cpp b/src/TangoSerialLink.cpp
index 472505b..c745657 100644
--- a/src/TangoSerialLink.cpp
+++ b/src/TangoSerialLink.cpp
@@ -44,7 +44,7 @@ TangoSerialLink::~TangoSerialLink (void)
 {
 	//std::cout << "TangoSerialLink::~TangoSerialLink <-" << std::endl;
 
-	if(_is_serial_proxy_created)
+	if(_serial_proxy)
 	{
 		delete _serial_proxy;
 		_serial_proxy = 0;
@@ -66,13 +66,14 @@ void TangoSerialLink::create_serial_proxy (void)  throw (Tango::DevFailed)
 	{
 		//- try
 		this->_serial_proxy = new Tango::DeviceProxyHelper(_communication_Device_name);
+		(*_serial_proxy)->ping();
 		_is_serial_proxy_created = true;
 	}
 	catch(Tango::DevFailed& df )
 	{
 		description = "Unable to create proxy on : " + _communication_Device_name;
 		_is_serial_proxy_created = false;
-
+		this->_serial_proxy = 0;
 		Tango::Except::re_throw_exception (df,
 										(const char*)"COMMUNICATION_ERROR",
 										description.c_str(),
@@ -88,7 +89,7 @@ void TangoSerialLink::write (std::string command_to_send)  throw (Tango::DevFail
 {
   std::string description("");
 
-	if(!_is_serial_proxy_created)
+	if(!_serial_proxy)
 		create_serial_proxy();
 
 	try
@@ -115,7 +116,7 @@ void TangoSerialLink::write (std::string command_to_send)  throw (Tango::DevFail
 std::string TangoSerialLink::read (void) throw (Tango::DevFailed)
 {
 
-	if(!_is_serial_proxy_created)
+	if(!_serial_proxy)
 		create_serial_proxy();
 
 	try
@@ -140,17 +141,22 @@ std::string TangoSerialLink::read (void) throw (Tango::DevFailed)
 // ============================================================================
 std::string TangoSerialLink::write_read (std::string command_to_send) throw (Tango::DevFailed)
 {
+	if(!_serial_proxy)
+		create_serial_proxy();
+
 	std::string respTmp("");
-	
-//	long nb_char_written = 0;
+	long flush_in_out = 2;
+
+	//- Flush buffers ( In & Out = 2 )
+	_serial_proxy->command_in("DevSerFlush", flush_in_out);
 
 	omni_thread::sleep(0, 200000000); //200 milliseconds
 	write(command_to_send);
+
 	//- sleep a little bit to let the adapter(RS232/485) to switch mode
 	omni_thread::sleep(0, 100000000); //100 milliseconds
+	
 	// now read response from HW 
-	respTmp = this->read();
-
-	return respTmp;
+	return this->read();
 }
 
-- 
GitLab