-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devel #3
base: master
Are you sure you want to change the base?
Devel #3
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,7 @@ void Camera::connect(const char *host,int port) | |
AutoMutex aLock(m_cond.mutex()); | ||
_initVariable(); | ||
_connect(host,port); | ||
_checkcmd(); | ||
} | ||
|
||
void Camera::_connect(const char *host,int port) | ||
|
@@ -277,6 +278,7 @@ void Camera::_connect(const char *host,int port) | |
//----------------------------------------------------- | ||
void Camera::_resync() | ||
{ | ||
DEB_MEMBER_FUNCT(); | ||
if(m_has_cmd_setenergy) | ||
send("setenergy"); | ||
else | ||
|
@@ -296,6 +298,41 @@ void Camera::_resync() | |
send("version"); | ||
} | ||
|
||
//----------------------------------------------------- | ||
// | ||
//----------------------------------------------------- | ||
void Camera::_checkcmd() | ||
{ | ||
DEB_MEMBER_FUNCT(); | ||
char messages[16384]; | ||
int aMessageSize = recv(m_socket,messages,sizeof(messages),0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will conflicts with the recv in the thread of Camera::_run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Camera::_checkcmd is called in Camera::connect and it has a lock that prevents from communication conflicts. Camera::_checkcmd justs reads the answers received from Camera::_resync calls. PD1: In fact, it may be worth to move _resync from Camera::_connect to Camera::connect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, It's more clear for me now... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I've look a bit more deeper and I think it's safer to let the Camera::_run method do the socket reading because the _checkcmd may "eat" some other reply. SEB |
||
if(aMessageSize > 0) | ||
{ | ||
std::string strMessages(messages,aMessageSize ); | ||
std::vector<std::string> msg_vector; | ||
_split(strMessages,SPLIT_SEPARATOR,msg_vector); | ||
for(std::vector<std::string>::iterator msg_iterator = msg_vector.begin(); | ||
msg_iterator != msg_vector.end();++msg_iterator) | ||
{ | ||
std::string &msg = *msg_iterator; | ||
if(msg.find("Unrecognized command: setenergy") != | ||
std::string::npos) | ||
{ | ||
DEB_TRACE() <<"-- no setenergy command"; | ||
m_has_cmd_setenergy = false; | ||
} | ||
if(msg.find("Unrecognized command: setroi") != std::string::npos | ||
or | ||
msg.find("Invalid command: SetROI") != std::string::npos | ||
) | ||
{ | ||
DEB_TRACE() <<"-- no setroi command"; | ||
m_has_cmd_roi = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
//----------------------------------------------------- | ||
// | ||
//----------------------------------------------------- | ||
|
@@ -574,12 +611,17 @@ void Camera::_run() | |
m_state = Camera::STANDBY; | ||
m_nb_acquired_images = m_nimages; | ||
} | ||
else if(m_state == Camera::STANDBY) | ||
{ | ||
// The acquisition was aborted | ||
DEB_TRACE() << "-- Ignore ERROR"; | ||
} | ||
else | ||
{ | ||
DEB_TRACE() << "-- ERROR"; | ||
m_state = Camera::ERROR; | ||
msg = msg.substr(2); | ||
m_error_message = msg.substr(msg.find(" ")); | ||
DEB_TRACE() << "-- ERROR"; | ||
m_state = Camera::ERROR; | ||
msg = msg.substr(2); | ||
m_error_message = msg.substr(msg.find(" ")); | ||
} | ||
} | ||
else if(msg.substr(0,2) == "1 ") | ||
|
@@ -599,8 +641,13 @@ void Camera::_run() | |
DEB_TRACE() << "Can't retrieved camserver version"; | ||
} | ||
else if(msg.find("Unrecognized command: setroi") != | ||
std::string::npos) | ||
std::string::npos | ||
or | ||
msg.find("Invalid command: SetROI") != | ||
std::string::npos | ||
) | ||
{ | ||
DEB_TRACE() << "Does not have setroi cmd"; | ||
m_has_cmd_roi = false; | ||
_resync(); | ||
} | ||
|
@@ -1063,7 +1110,7 @@ void Camera::stopAcquisition() | |
if(m_state == Camera::RUNNING) | ||
{ | ||
m_state = Camera::KILL_ACQUISITION; | ||
send("k"); | ||
send("camcmd k"); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The available commands were already checked in Camera::_run, so why you need this extra function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commands availability has to be checked when the camera is constructed.
Otherwise other objects may get wrong capabilities.
I use the first communications with the hardware to do the check, this is in connect method which has a lock to avoid conflicts with Camera::_run.
I guess that once it is checked on camera construction it is not needed on Camera::_run method.
In my case, 1M pilatus3 does not have setroi command. If this is discovered after creating the Interface Lima thinks that hardware roi exists and crashes.