Commit 935e7a20 authored by Tobias Bjerg's avatar Tobias Bjerg
Browse files

Merge branch 'rasp3_DTU' of gitext.gfz-potsdam.de:mors/GeomagLogger into rasp3_DTU

parents 4e984fd6 bec7dd2d
......@@ -103,31 +103,19 @@ driver_obs_obsdaq::driver_obs_obsdaq(std::string port, int baud,
sprintf(addr_str, "%02X", addr);
RS485_addrstr = std::string(addr_str);
/* In development
// Check if requested baud rate is already set
if ( check_baud(baud) != 1){
// Check for baud rate with the right address.
// Stop any running measurement when doing so.
find_baud();
// Set baud rate
set_baud(baud);
// Set the ObsDAQ baud rate
*/
// Stop the measurement
//TODO Reactivate later, baud rate needs to be set when calling stop() !
//stop();
if ( check_baud(baud) != 1){
// Check if given baud rate is correct
// Find correct baudrate if necessary
switch (check_baud(baud)) {
case 2:
stop();
break;
case 1:
break;
default:
find_baud();
stop();
set_baud(baud);
} else {
stop();
break;
}
// Initialize
......@@ -689,6 +677,7 @@ int driver_obs_obsdaq::checked_send(const char* cmd, const char* reply,
}
return (-1);
}
strbuf=std::string(buf);
// Construct expected answer
......@@ -700,7 +689,7 @@ int driver_obs_obsdaq::checked_send(const char* cmd, const char* reply,
if (verbose) {
std::cerr << "Wrong address received." << " Expected: "
<< expected.substr(1, 2) << " Received: " << &buf[1]
<< std::endl;
<<std::endl;
}
return (-2);
}
......@@ -710,7 +699,7 @@ int driver_obs_obsdaq::checked_send(const char* cmd, const char* reply,
if (verbose) {
std::cerr << "Wrong answer received." << " Expected: "
<< expected.substr(3, digits) << " Received: "
<< strbuf.substr(3, digits) << std::endl;
<< strbuf.substr(3, digits) << " | " << strbuf.c_str() << std::endl;
}
return (-3);
}
......@@ -1277,13 +1266,14 @@ int driver_obs_obsdaq::check_baud(int baud){
return (-1);
}
////////////////////////////////////////////////////////////////////////
//
// Check for response
//
////////////////////////////////////////////////////////////////////////
send("$M");
//send("$M");
// Check for expected response
if (checked_send("$M","<ObsDaq",7,0.2,0) != 0) {
// No response, but freerun mode might be running, so check for data
......@@ -1293,10 +1283,16 @@ int driver_obs_obsdaq::check_baud(int baud){
}
fprintf(stderr,"N: %d\n",n);
if (n<2) {
fprintf(stderr,"----- CHECK BAUD FAILED -----\n");
return(-1);
} else {
fprintf(stderr,"----- CHECK BAUD DONE -----\n");
return(2);
}
}
fprintf(stderr,"----- CHECK BAUD DONE -----\n");
return(1);
......
......@@ -242,6 +242,8 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
//
if (read(fd, &c, 1) > 0) {
//fprintf(stderr, "Received: %d %c \n",c,c);
// A correct termination character has arrived
if (c == term[n]) {
n++;
......
Markdown is supported
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