Skip to content
Snippets Groups Projects
Commit 97a68838 authored by Jean Coquet's avatar Jean Coquet
Browse files

some candidate to crash correction

parent c4ec11f4
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
</parent>
<groupId>fr.soleil.device</groupId>
<artifactId>GpibPrologix-${aol}-${mode}</artifactId>
<version>1.1.7</version>
<version>1.1.8-SNAPSHOT</version>
<packaging>nar</packaging>
<name>GpibPrologix</name>
<description>GpibPrologix device</description>
......
static const char *RcsId = "$Id: GpibPrologix.cpp,v 1.18 2012-04-04 13:50:50 jean_coquet Exp $";
static const char *RcsId = "$Id: GpibPrologix.cpp,v 1.19 2012-08-21 08:08:04 jean_coquet Exp $";
//+=============================================================================
//
// file : GpibPrologix.cpp
......@@ -13,10 +13,10 @@ static const char *RcsId = "$Id: GpibPrologix.cpp,v 1.18 2012-04-04 13:50:50 jea
//
// $Author: jean_coquet $
//
// $Revision: 1.18 $
// $Revision: 1.19 $
//
// $Revision: 1.18 $
// $Date: 2012-04-04 13:50:50 $
// $Revision: 1.19 $
// $Date: 2012-08-21 08:08:04 $
//
// SVN only:
// $HeadURL: $
......@@ -24,6 +24,10 @@ static const char *RcsId = "$Id: GpibPrologix.cpp,v 1.18 2012-04-04 13:50:50 jea
// CVS only:
// $Source: /users/chaize/newsvn/cvsroot/Communication/GpibPrologix/src/GpibPrologix.cpp,v $
// $Log: not supported by cvs2svn $
// Revision 1.18 2012/04/04 13:50:50 jean_coquet
// correctif plantage sur commande erronee
// release_1_1_7
//
// Revision 1.17 2012/03/22 15:16:09 jean_coquet
// bug correction (crash when trying to Init the device and GPIB client does not respond)
// some code cleaning
......@@ -239,6 +243,14 @@ namespace GpibPrologix_ns
//--------------------------------------------
this->init_device_done = false;
this->properties_missing = false;
this->status_str.reserve (4096);
this->start_date.reserve (256);
this->com_last_error.reserve (4096);
this->error_init_msg.reserve (4096);
this->info.reserve (4096);
this->read_cmd.reserve (4096);
this->sock = 0;
this->com_state = Tango::UNKNOWN;
this->read_cmd = "++read eoi\n";
......@@ -590,11 +602,6 @@ namespace GpibPrologix_ns
++consecutive_com_error_counter;
}
}
//- displays the last cmds in fault
if (failed_cmds.size () > 10)
failed_cmds.pop_front ();
}
//+------------------------------------------------------------------
/**
......@@ -658,7 +665,10 @@ namespace GpibPrologix_ns
+ std::string (exc.errors[0].desc)
+ "]";
//- try to keep track of failed cmds
{
yat::AutoMutex <yat::Mutex> guard (this->m_lock);
failed_cmds.push_back (this->com_last_error);
}
ERROR_STREAM << "GpibPrologix::" << this->com_last_error << std::endl;
throw (exc);
......@@ -674,7 +684,10 @@ namespace GpibPrologix_ns
+ "] + yat::SocketException caught : ["
+ se.errors[0].desc
+ "]";
{
yat::AutoMutex <yat::Mutex> guard (this->m_lock);
failed_cmds.push_back (this->com_last_error);
}
ERROR_STREAM << "GpibPrologix::" << com_last_error << std::endl;
Tango::Except::throw_exception(static_cast<const char*>("COMMUNICATION_FAILED"),
static_cast<const char*>(se.errors[0].desc.c_str ()),
......@@ -688,7 +701,10 @@ namespace GpibPrologix_ns
this->com_last_error = "write : communication failed cmd sent : ["
+ std::string (argin)
+ "] (...) exception caught";
{
yat::AutoMutex <yat::Mutex> guard (this->m_lock);
failed_cmds.push_back (this->com_last_error);
}
ERROR_STREAM << "GpibPrologix::" << com_last_error << std::endl;
Tango::Except::throw_exception(static_cast<const char*>("COMMUNICATION_FAILED"),
static_cast<const char*>("Unknown (...) Exception caught"),
......@@ -746,11 +762,14 @@ namespace GpibPrologix_ns
+ "] + Tango::DevFailed caught : ["
+ std::string (exc.errors[0].desc)
+ "]";
{
yat::AutoMutex <yat::Mutex> guard (this->m_lock);
failed_cmds.push_back (this->com_last_error);
}
ERROR_STREAM << "GpibPrologix::" << this->com_last_error << std::endl;
Tango::Except::re_throw_exception(exc,
static_cast<const char*>("COMMUNICATION_FAILED"),
static_cast<const char*>("read() caught Devfailed trying to get HW response" ),
static_cast<const char*>(this->com_last_error.c_str ()),
static_cast<const char*>("GpibPrologix::read"));
}
catch (const yat::SocketException & se)
......@@ -763,11 +782,14 @@ namespace GpibPrologix_ns
+ "] + yat::SocketException caught : ["
+ se.errors[0].desc
+ "]";
{
yat::AutoMutex <yat::Mutex> guard (this->m_lock);
failed_cmds.push_back (this->com_last_error);
}
ERROR_STREAM << "GpibPrologix::" << com_last_error << std::endl;
Tango::Except::throw_exception((const char*)"COMMUNICATION_FAILED",
se.errors[0].desc.c_str (),
static_cast<const char*>(this->com_last_error.c_str ()),
(const char*)"GpibPrologix::read");
}
catch (...)
......@@ -856,7 +878,7 @@ namespace GpibPrologix_ns
(const char*)"GpibPrologix::write_read");
}
Tango::DevString resp;
Tango::DevString resp = "<NO RESPONSE>";
try
......@@ -1302,10 +1324,20 @@ namespace GpibPrologix_ns
status_str += s.str ();
status_str += info;
for (size_t i = 0; i < failed_cmds.size (); i++)
status_str += "\n" + failed_cmds [i];
{
yat::AutoMutex <yat::Mutex> guard (this->m_lock);
while(failed_cmds.size () > 10)
{
INFO_STREAM << "GpibPrologix::dev_status(): removing old error" << failed_cmds.front () << endl;
failed_cmds.pop_front ();
}
deque <std::string>::iterator it;
for (it = failed_cmds.begin (); it != failed_cmds.end (); ++it)
status_str += "\n" + *it;
set_status(status_str.c_str ());
return status_str.c_str ();
}
}
......
......@@ -8,8 +8,8 @@
//
// $Author: jean_coquet $
//
// $Revision: 1.6 $
// $Date: 2012-03-22 15:16:09 $
// $Revision: 1.7 $
// $Date: 2012-08-21 08:08:04 $
//
// SVN only:
// $HeadURL: $
......@@ -17,6 +17,11 @@
// CVS only:
// $Source: /users/chaize/newsvn/cvsroot/Communication/GpibPrologix/src/GpibPrologix.h,v $
// $Log: not supported by cvs2svn $
// Revision 1.6 2012/03/22 15:16:09 jean_coquet
// bug correction (crash when trying to Init the device and GPIB client does not respond)
// some code cleaning
// State and Status enhanced
//
// Revision 1.5 2011/10/20 14:32:24 jean_coquet
// added list (limited to 50 newest) of commands which failed and drived to disconnect TCP/IP to understand the reason why so much disconnections with Power Supply AMI420
//
......@@ -83,7 +88,7 @@
/**
* @author $Author: jean_coquet $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
// Add your own constant definitions here.
......@@ -353,6 +358,8 @@ protected :
//-----------------------------------------
yat::ClientSocket* sock;
yat::Mutex m_lock;
/**
* Disconnect from the current socket
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment