Commit 43f7d967 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Check if other program reading from ObsDAQ

parent a946e602
......@@ -114,9 +114,24 @@ driver_obs_obsdaq::driver_obs_obsdaq(std::string port, int baud,
case 1:
break;
default:
find_baud();
stop();
set_baud(baud);
// Check if sthg is arriving
int n=0; int N=10; char buf[11];
while (receive_raw(buf, 10, 0.2) == -1 && n<N){
send("$M");
n++;
}
if (n<N){
throw std::invalid_argument
("OTHER PROGRAM MAY BE READING FROM ObsDAQ! ABORTING.");
}
if (find_baud()==0){
stop();
// Probably obsolete as set in find_baud
set_baud(baud);
} else {
throw std::invalid_argument
("No ObsDAQ FOUND! ABORTING.");
}
break;
}
......@@ -1574,11 +1589,13 @@ int driver_obs_obsdaq::set_baud(int baud) {
***************************************************************************/
int driver_obs_obsdaq::find_baud() {
int ret;
// Try to find serial port
Driver_Obs_Serial::find_baud(this,
ret=Driver_Obs_Serial::find_baud(this,
static_cast<int (Driver_Obs_Serial::*)(int)>(&driver_obs_obsdaq::check_baud));
return (0);
return(ret);
}
......
......@@ -62,6 +62,7 @@ int main(int argc, char* argv[]) {
buffer_obs_pipe buf(5);
// Initialize new OBSDAQ device
std::cout << "OBSDAQ Initializing. Please wait!" << std::endl;
driver_obs_obsdaq obsdaq = driver_obs_obsdaq(par.get_str("PORT_VEC"),
par.get_int("BAUD_VEC"), &buf, &cal, par.get_int("ADDRESS"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment