Commit 976309c5 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Set_baud and init almost done

parent c13a34d2
......@@ -61,6 +61,8 @@ int supp_count;
/** Baud rate codes */
const static std::unordered_map<int,std::string> map_baud;
std::unordered_map<int,std::string>::const_iterator it_map_baud;
//
......
......@@ -124,6 +124,8 @@ driver_obs_obsdaq::driver_obs_obsdaq(std::string port, int baud,
find_baud();
stop();
set_baud(baud);
} else {
stop();
}
// Initialize
......@@ -388,12 +390,12 @@ int driver_obs_obsdaq::freerun(double freq) {
int driver_obs_obsdaq::stop() {
// Receive buffer
char buf[100]="";
char stopstr[41]="||||||||||||||||||||||||||||||||||||||||";
// Stop free-run mode
send("|||||||||||||||||||||||||||||||||||||||||");
while (receive_raw(buf, sizeof(buf), 0.2) > 5) {
send("||||||||||||||||||||||||||||||||||||||||||||");
send(stopstr);
while (checked_send("$M","<ObsDaq",7,1,0) != 0) {
send(stopstr);
}
return (0);
......@@ -625,6 +627,7 @@ int driver_obs_obsdaq::checked_send(const char* cmd, const char* reply,
int driver_obs_obsdaq::checked_send(const char* cmd, const char* reply,
int digits, double timeout, std::string* recv, int verbose) {
flush();
/////////////////////////////////////////////////////////////////////////
//
......@@ -921,7 +924,8 @@ int driver_obs_obsdaq::init() {
//
/////////////////////////////////////////////////////////////////////////
stop();
// Should never run, as private method
//stop();
/////////////////////////////////////////////////////////////////////////
//
......@@ -1135,7 +1139,7 @@ int driver_obs_obsdaq::init_run(double freq){
/****************************************************************************
*
* Set the baud rate.
* Set the baud rate (Manual 12.4.5)
*
* Set filter rates.
*
......@@ -1143,18 +1147,18 @@ int driver_obs_obsdaq::init_run(double freq){
int driver_obs_obsdaq::set_baud(int baud) {
std::string cmd;
////////////////////////////////////////////////////////////////////////
//
// Set the baud rate of ObsDAQ
// Set the baud rate of ObsDAQ
//
////////////////////////////////////////////////////////////////////////
cmd = "%" + RS485_addrstr + "00" + "07" + "00";
if (checked_send(cmd.c_str(),"!",1,2) < 0){
return(-1);
}
return (0);
it_map_baud = map_baud.find(baud);
cmd = "%" + RS485_addrstr + "00" + it_map_baud->second + "00";
send(cmd.c_str());
////////////////////////////////////////////////////////////////////////
//
......@@ -1165,6 +1169,17 @@ int driver_obs_obsdaq::set_baud(int baud) {
return (-1);
}
////////////////////////////////////////////////////////////////////////
//
// Check for response
//
////////////////////////////////////////////////////////////////////////
if (checked_send("$M","<ObsDaq",7,0.2,0) != 0){
return(-1);
}
return (0);
}
/****************************************************************************
......@@ -1206,8 +1221,10 @@ int driver_obs_obsdaq::check_baud(int baud){
//
////////////////////////////////////////////////////////////////////////
send("$M");
// Check for expected response
if (checked_send("$M","<ObsDaq",7,1,0) != 0) {
if (checked_send("$M","<ObsDaq",7,0.2,0) != 0) {
// No response, but freerun mode might be running, so check for data
int n=0;
for (int i=0; i<3; i++) {
......
# Baudrate for ObsDAQ
BAUD=19200 #19200
BAUD=9600 #19200
# PORT for ObsDAQ
PORT=/dev/ttyUSB0
# Resistance of variometer
......
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