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