Skip to content
Snippets Groups Projects
Commit 3152005c authored by ELATTAOUI's avatar ELATTAOUI
Browse files

cmd switch_off called before any parameters modifications and then locked with switch_on.

parent 19f493cd
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@
// DEPENDENCIES
// ============================================================================
#include <tango.h>
#include <DeviceProxyHelper.h>
//#include <DeviceProxyHelper.h>
#include "CommunicationLink.h"
/**
......@@ -98,7 +98,7 @@ private :
*/
void create_gpib_proxy(void) throw (Tango::DevFailed);
Tango::DeviceProxyHelper* _gpib_proxy;
Tango::DeviceProxy* _gpib_proxy;
std::string response;
......
......@@ -18,7 +18,7 @@
// DEPENDENCIES
// ============================================================================
#include <tango.h>
#include <DeviceProxyHelper.h>
//#include <DeviceProxyHelper.h>
#include "CommunicationLink.h"
/**
......@@ -37,15 +37,14 @@ class TangoSerialLink : public CommunicationLink
{
public :
/**
* \brief Initialization.
*/
TangoSerialLink (std::string& serial_device_name);
/**
* \brief Release resources.
*/
virtual ~TangoSerialLink (void);
/**
* \brief One MCCE-2 can manage two differents electrometers
* through only one serial line !
*
*/
static TangoSerialLink* get_instance(std::string& serial_device_name);
static void delete_instance(CommunicationLink*);
/**
* \brief Send command (data) as string to hardware.
......@@ -68,20 +67,29 @@ public :
*/
std::string write_read(std::string cmd) throw (Tango::DevFailed);
/**
* \brief Returns the Gpib SRQ line state : Not used HERR
*
* \throws Tango::DevFailed
private :
/**
* \brief Initialization.
*/
TangoSerialLink (std::string& serial_device_name);
/**
* \brief Release resources.
*/
~TangoSerialLink ();
bool isSRQLineUp(void) throw (Tango::DevFailed);
/**
* \brief Tango Serial Link instance.
*/
private :
/**
static TangoSerialLink* tsl_Instance;
/**
* Creates a proxy on the specified Serial Device.
*/
void create_serial_proxy(void) throw (Tango::DevFailed);
Tango::DeviceProxyHelper* _serial_proxy;
//Tango::DeviceProxyHelper* _serial_proxy;
Tango::DeviceProxy* _serial_proxy;
bool _is_serial_proxy_created;
......
......@@ -8,7 +8,7 @@
</parent>
<groupId>fr.soleil.lib</groupId>
<artifactId>Electrometers-${aol}-${library}-${mode}</artifactId>
<version>2.5.1</version>
<version>2.5.2-SNAPSHOT</version>
<packaging>nar</packaging>
<name>Electrometers library</name>
<description>Electrometers library</description>
......
......@@ -67,7 +67,7 @@ NovelecProtocol::NovelecProtocol (std::string& serial_device_name, unsigned shor
NovelecProtocol::~NovelecProtocol (void)
{
// std::cout << "NovelecProtocol::~NovelecProtocol <-" << std::endl;
TangoSerialLink::delete_instance(_communication_link);
// std::cout << "NovelecProtocol::~NovelecProtocol ->" << std::endl;
}
......@@ -79,7 +79,7 @@ bool NovelecProtocol::build_communicationLink()
if (_commDevName.empty())
return false;
_communication_link = new TangoSerialLink (_commDevName);
_communication_link = TangoSerialLink::get_instance(_commDevName);
if (!_communication_link)
return false;
......@@ -95,19 +95,23 @@ void NovelecProtocol::init_MCCE2_for_communication(void)
std::stringstream explicite_resp;
std::string tmp("no data");
std::cout << "NovelecProtocol::init_MCCE2_for_communication -> _devAdd = " << _devAdd << std::endl;
//- CMD to enable PROG cmds
this->switch_MCCE2_OFF(); //- this command is now called in the MCCE2 device !
std::cout << "NovelecProtocol::init_MCCE2_for_communication -> switch_MCCE2_OFF" << std::endl;
//- Clear error registers
this->clear_registers();
std::cout << "NovelecProtocol::init_MCCE2_for_communication -> clear_registers" << 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());
std::cout << "NovelecProtocol::init_MCCE2_for_communication -> write_read" << std::endl;
//- check only the command response
check_command(tmp);
std::cout << "NovelecProtocol::init_MCCE2_for_communication -> check_command" << std::endl;
//- if no error
_is_explicite_resp_enabled = true;
}
......@@ -158,9 +162,6 @@ std::stringstream cmd_to_send;
std::string argout("no data");
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- 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());
......@@ -171,11 +172,11 @@ std::string tmp("no data");
//- check what is the response mode type
if( _is_explicite_resp_enabled == false )
{
short idx = XString<short>::convertFromString(argout);
_function = mode_str[idx];
short idx = XString<short>::convertFromString(argout);
_function = mode_str[idx];
}
else
_function = argout;
_function = argout;
return _function;
}
......@@ -219,14 +220,19 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 1"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data");
//- allow parameters modification
this->switch_MCCE2_OFF();
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//this->is_allowed();
//- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_OFF();
}
// ============================================================================
......@@ -238,14 +244,18 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 2"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -257,14 +267,19 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 3"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -276,14 +291,19 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 4"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -298,11 +318,15 @@ std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -317,8 +341,10 @@ std::string tmp("no data");
//- send command to Novelec device
cmd_to_send << _devAdd << " READ " << RANGE_CMD_NUM << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
std::cout << "NovelecProtocol::get_range -> range brut : " << tmp << std::endl;
//- check and extract the response
argout = check_and_extract_data(tmp, RANGE_CMD_NUM);
std::cout << "NovelecProtocol::get_range -> range extrait : " << argout << std::endl;
//- check what is the response mode type
short idx = -1;
......@@ -339,15 +365,19 @@ void NovelecProtocol::set_range (std::string value)
std::stringstream cmd_to_send;
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send command to Novelec device
cmd_to_send << _devAdd << " PROG " << _rangeParameterNum << " " << value << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- the novelec device send ACK/NAK response after a received command
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -386,14 +416,20 @@ void NovelecProtocol::set_polarity (std::string newPolarity)
std::stringstream cmd_to_send;
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send command to Novelec device
cmd_to_send << _devAdd << " PROG 2" << " " << newPolarity << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- the novelec device send ACK/NAK response after a received command
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -430,14 +466,20 @@ void NovelecProtocol::set_frequency (std::string newFrequency)
std::stringstream cmd_to_send;
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send command to Novelec device
cmd_to_send << _devAdd << " PROG 9" << " " << newFrequency << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- the novelec device send ACK/NAK response after a received command
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -476,15 +518,19 @@ void NovelecProtocol::set_gain (std::string newGain)
std::stringstream cmd_to_send;
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send command to Novelec device
cmd_to_send << _devAdd << " PROG 8" << " " << newGain << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- the novelec device send ACK/NAK response after a received command
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -548,15 +594,19 @@ void NovelecProtocol::local (void)
std::stringstream cmd_to_send;
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send command
cmd_to_send << _devAdd << " LOCAL" << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- check the response
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......@@ -567,15 +617,19 @@ void NovelecProtocol::remote (void)
std::stringstream cmd_to_send;
std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
// //- check if the MCCE2 is not in MEASURE mode to get/change any settings
//this->is_allowed();
//- allow parameters modification
this->switch_MCCE2_OFF();
//- send command
cmd_to_send << _devAdd << " REMOTE" << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str());
//- check the response
check_command(tmp);
//- lock parameters modification
this->switch_MCCE2_ON();
}
// ============================================================================
......
......@@ -159,7 +159,7 @@ void Novelec_MCCE2::mcce_off (void)
// ============================================================================
std::string Novelec_MCCE2::electrometer_status (void)
{
std::string argout("undefined status");
std::string argout("");
std::string typeStr(" ");
std::string tmp(" ");
short _status = 0;
......@@ -168,47 +168,51 @@ std::string Novelec_MCCE2::electrometer_status (void)
NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol);
if(!_nproto)
throw electrometer::ElectrometerException("BAD_CAST",
"Unable to query the electrmometer status.",
throw electrometer::ElectrometerException("BAD_ALLOC",
"Memory allocation failed to query the electrmometer status.",
"Novelec_MCCE2::electrometer_status( ).");
/***********************************************************************
DISABLED PART TO INCREASE SERIAL PERFORMANCE
//- get Electrometer type :
try
{
tmp = _nproto->get_electrotype();
_type = XString<short>::convertFromString(tmp);
}
catch(...)
{
set_electroState(FAULT);
throw electrometer::ElectrometerException("INTERNAL_ERROR",
"Unable to query the electrmometer type.",
"Novelec_MCCE2::electrometer_status( ).");
}
//try
//{
// tmp = _nproto->get_electrotype();
// _type = XString<short>::convertFromString(tmp);
//}
//catch(...)
//{
// set_electroState(FAULT);
// throw electrometer::ElectrometerException("INTERNAL_ERROR",
// "Unable to query the electrmometer type.",
// "Novelec_MCCE2::electrometer_status( ).");
//}
argout = "\n\nINFOS :\n";
argout += "----------\n";
//argout = "\n\nINFOS :\n";
//argout += "----------\n";
switch(_type)
{
case 1 : typeStr = "Photovoltaque UHS";
break;
case 2 : typeStr = "Photovoltaque HS";
break;
case 3 : typeStr = "Photovoltaque MS";
break;
case 4 : typeStr = "Photoconducteur HS";
break;
case 5 : typeStr = "Photoconducteur MS";
break;
default : set_electroState(FAULT);
argout = "Invalid status string returned !";
return argout;
}
argout += "Novelec type : " + typeStr + "\n";
//switch(_type)
//{
//case 1 : typeStr = "Photovoltaque UHS";
// break;
//case 2 : typeStr = "Photovoltaque HS";
// break;
//case 3 : typeStr = "Photovoltaque MS";
// break;
//case 4 : typeStr = "Photoconducteur HS";
// break;
//case 5 : typeStr = "Photoconducteur MS";
// break;
//default : set_electroState(FAULT);
// argout = "Invalid status string returned !";
// return argout;
//}
//argout += "Novelec type : " + typeStr + "\n";
//- get Electrometer mode :
argout += "Novelec mode : " + _electrometerProtocol->get_mode() + "\n";
////- get Electrometer mode :
//argout += "Novelec mode : " + _electrometerProtocol->get_mode() + "\n";
***********************************************************************/
try
{
......@@ -219,12 +223,15 @@ std::string Novelec_MCCE2::electrometer_status (void)
catch(...)
{
set_electroState(FAULT);
throw electrometer::ElectrometerException("INTERNAL_ERROR",
"Unable to query the electrmometer status.",
"Novelec_MCCE2::electrometer_status( ).");
argout = "Unable to query the electrometer status.";
return argout;
//throw electrometer::ElectrometerException("COMMUNICATION_ERROR",
// "Unable to query the electrmometer status.",
// "Novelec_MCCE2::electrometer_status( ).");
}
argout += "Status detail :\n";
argout += "\nStatus detail :\n";
argout += "------------------------\n";
//- build novelec status
......
......@@ -60,7 +60,7 @@ void TangoGpibLink::create_gpib_proxy (void) throw (Tango::DevFailed)
try
{
//- try
this->_gpib_proxy = new Tango::DeviceProxyHelper(_communication_Device_name);
this->_gpib_proxy = new Tango::DeviceProxy(_communication_Device_name.c_str());
}
catch(Tango::DevFailed& df )
{
......@@ -79,19 +79,50 @@ void TangoGpibLink::create_gpib_proxy (void) throw (Tango::DevFailed)
// ============================================================================
void TangoGpibLink::write (std::string command_to_send) throw (Tango::DevFailed)
{
Tango::DeviceData dd_in;
Tango::DevString cmd = 0;
std::string description("");
if(!_gpib_proxy)
create_gpib_proxy();
try
{
cmd = new char [command_to_send.size() + 1];
strcpy(cmd, command_to_send.c_str());
}
catch(Tango::DevFailed& df )
{
if ( cmd )
delete [] cmd;
description = "Failed to allocate memory for the command to write";
Tango::Except::re_throw_exception (df,
(const char*)"MEMORY_ALLOCATION",
description.c_str(),
(const char*)"TangoGpibLink::write");
}
catch(...)
{
if ( cmd )
delete [] cmd;
Tango::Except::throw_exception (
(const char*)"MEMORY_ALLOCATION",
(const char*)"Not enough memory.",
(const char*)"TangoGpibLink::write");
}
try
{
//- try
this->_gpib_proxy->command_in("Write", command_to_send);
dd_in << cmd;
this->_gpib_proxy->command_inout("Write", dd_in);
if ( cmd )
delete [] cmd;
}
catch(Tango::DevFailed& df )
{
description = "Unable to write command : " + command_to_send;
if ( cmd )
delete [] cmd;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
......@@ -107,6 +138,7 @@ void TangoGpibLink::write (std::string command_to_send) throw (Tango::DevFailed
// ============================================================================
std::string TangoGpibLink::read (void) throw (Tango::DevFailed)
{
Tango::DeviceData dd_out;
if(!_gpib_proxy)
create_gpib_proxy();
......@@ -114,7 +146,8 @@ std::string TangoGpibLink::read (void) throw (Tango::DevFailed)
try
{
//- try
this->_gpib_proxy->command_out("Read", this->response);
dd_out = this->_gpib_proxy->command_inout("Read");
dd_out >> this->response;
}
catch(Tango::DevFailed& df )
{
......@@ -124,7 +157,7 @@ std::string TangoGpibLink::read (void) throw (Tango::DevFailed)
(const char*)"TangoGpibLink::read");
}
return this->response ;
return this->response;
}
// ============================================================================
......@@ -136,16 +169,25 @@ std::string TangoGpibLink::write_read (std::string command_to_send) throw (Tango
if(!_gpib_proxy)
create_gpib_proxy();
Tango::DeviceData dd_in, dd_out;
Tango::DevString argin = 0;
try
{
//- try
this->_gpib_proxy->command_inout("WriteRead", command_to_send, response);
argin = new char [command_to_send.size() + 1];
strcpy(argin, command_to_send.c_str());
dd_in << argin;
dd_out = this->_gpib_proxy->command_inout("WriteRead", dd_in);
dd_out >> this->response;
if ( argin )
delete [] argin;
}
catch(Tango::DevFailed& df )
{
description = "Unable to write command : " + command_to_send + " and read device response.";
if ( argin )
delete [] argin;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.c_str(),
......@@ -161,6 +203,7 @@ bool TangoGpibLink::SRQLineState (void) throw (Tango::DevFailed)
{
std::string description("");
bool result = false;
Tango::DeviceData dd_out;
if(!_gpib_proxy)
create_gpib_proxy();
......@@ -168,7 +211,8 @@ bool TangoGpibLink::SRQLineState (void) throw (Tango::DevFailed)
try
{
//- try
this->_gpib_proxy->command_out("IsSRQLineUP", result);
dd_out = this->_gpib_proxy->command_inout("IsSRQLineUP");
dd_out >> result;
}
catch(Tango::DevFailed& df )
{
......@@ -191,6 +235,8 @@ short TangoGpibLink::readStatusByteRegister (void) throw (Tango::DevFailed)
{
std::string description("");
short result = -1;
Tango::DeviceAttribute da_out;
if(!_gpib_proxy)
create_gpib_proxy();
......@@ -198,7 +244,8 @@ short TangoGpibLink::readStatusByteRegister (void) throw (Tango::DevFailed)
try
{
//- try
this->_gpib_proxy->read_attribute("statusByteRegister", result);
da_out = this->_gpib_proxy->read_attribute("statusByteRegister");
da_out >> result;
}
catch(Tango::DevFailed& df )
{
......@@ -226,7 +273,7 @@ void TangoGpibLink::clear (void) throw (Tango::DevFailed)
try
{
//- try
this->_gpib_proxy->command("Clear");
this->_gpib_proxy->command_inout("Clear");
}
catch(Tango::DevFailed& df )
{
......@@ -252,7 +299,7 @@ void TangoGpibLink::trigger (void) throw (Tango::DevFailed)
try
{
//- try
this->_gpib_proxy->command("Trigger");
this->_gpib_proxy->command_inout("Trigger");
}
catch(Tango::DevFailed& df )
{
......
......@@ -21,6 +21,31 @@
//- Read serial data in mode LINE (i.e SerialLine device wait until EOF is received from instrument
static const long MODE_LINE = 2;
//- init of the static instance
TangoSerialLink* TangoSerialLink::tsl_Instance = 0; //- ptr on the TangoSerialLink instance
// ============================================================================
// TangoSerialLink::get_instance
// ============================================================================
TangoSerialLink* TangoSerialLink::get_instance(std::string & serial_dev_name)
{
if( !tsl_Instance )
tsl_Instance = new TangoSerialLink(serial_dev_name);
return tsl_Instance;
}
// ============================================================================
// TangoSerialLink::delete_instance
// ============================================================================
void TangoSerialLink::delete_instance(CommunicationLink* tsl_Instance)
{
if(tsl_Instance)
{
delete tsl_Instance ;
tsl_Instance = 0;
}
}
// ============================================================================
// TangoSerialLink::TangoSerialLink
......@@ -65,8 +90,9 @@ void TangoSerialLink::create_serial_proxy (void) throw (Tango::DevFailed)
try
{
//- try
this->_serial_proxy = new Tango::DeviceProxyHelper(_communication_Device_name);
(*_serial_proxy)->ping();
//this->_serial_proxy = new Tango::DeviceProxyHelper(_communication_Device_name);
this->_serial_proxy = new Tango::DeviceProxy(_communication_Device_name.c_str());
//(*_serial_proxy)->ping();
_is_serial_proxy_created = true;
}
catch(Tango::DevFailed& df )
......@@ -91,11 +117,38 @@ void TangoSerialLink::write (std::string command_to_send) throw (Tango::DevFail
if(!_serial_proxy)
create_serial_proxy();
Tango::DeviceData dd_in;
Tango::DevString argin = 0;
try
{
argin = new char [command_to_send.size() + 1];
strcpy(argin, command_to_send.c_str());
}
catch(Tango::DevFailed& df )
{
description = "Unable to write command : " + command_to_send + + "\nmemory allocation failed.";
Tango::Except::re_throw_exception (df,
(const char*)"ALLOCATION_ERROR",
description.c_str(),
(const char*)"TangoSerialLink::write");
}
catch(...)
{
description = "Unable to write command : " + command_to_send + "\nmemory allocation failed.";
Tango::Except::throw_exception (
(const char*)"ALLOCATION_ERROR",
description.c_str(),
(const char*)"TangoSerialLink::write");
}
try
{
//- try
this->_serial_proxy->command_in("DevSerWriteString", command_to_send.c_str());
dd_in << argin;
this->_serial_proxy->command_inout("DevSerWriteString", dd_in);
}
catch(Tango::DevFailed& df )
{
......@@ -118,12 +171,13 @@ std::string TangoSerialLink::read (void) throw (Tango::DevFailed)
if(!_serial_proxy)
create_serial_proxy();
Tango::DeviceData dd_out;
try
{
//- try in mode LINE
//this->_serial_proxy->command_inout("DevSerReadString", MODE_LINE ,this->response);
this->_serial_proxy->command_out("DevSerReadLine", this->response);
dd_out = this->_serial_proxy->command_inout("DevSerReadLine");
dd_out >> this->response;
}
catch(Tango::DevFailed& df )
{
......@@ -143,12 +197,14 @@ std::string TangoSerialLink::write_read (std::string command_to_send) throw (Tan
{
if(!_serial_proxy)
create_serial_proxy();
Tango::DeviceData dd_in;
std::string respTmp("");
long flush_in_out = 2;
dd_in << flush_in_out;
//- Flush buffers ( In & Out = 2 )
_serial_proxy->command_in("DevSerFlush", flush_in_out);
this->_serial_proxy->command_inout("DevSerFlush", dd_in);
omni_thread::sleep(0, 200000000); //200 milliseconds
write(command_to_send);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment