Commit 740da9fe authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Allow to read single datum for ObsDAQ

parent 87b8349b
......@@ -179,18 +179,21 @@ int driver_obs_obsdaq::get(data_obs_vector *data) {
// Stop free-run mode (just in case).
stop();
// Synchronize channels
send("#PP10000500");
// Channel synchronization
checked_send("#PP10000500", "", 0, 1);
usleep(200e3);
send("#PP00000000");
int res = sleep(5);
std::cerr << "PROBLEM WIH SLEEP: " << res << std::endl;
checked_send("#PP00000000", "", 0, 1);
usleep(2e6);
// Flush
usleep(1e6);
flush();
// Ask for latest values.
send("#A");
// Wait for answer
if (receive(buf, sizeof(buf), 1, &recv_time) >= 0) {
if (receive(buf, sizeof(buf), 0, &recv_time) >= 0) {
// Parse data from answer
if (parse_data_ascii(data, buf) >= 0) {
......@@ -448,7 +451,7 @@ int driver_obs_obsdaq::calibrate(int repeat, std::string mode,
// Get temperature
get(&data);
double T = data.get_supp(1);
std::cout << "T: " << std::endl;
std::cout << "OBSDAQ temperature: " << T << std::endl;
// Iterate over all three channels
for (int i = 0; i < 3; i++) {
......@@ -1069,6 +1072,9 @@ int driver_obs_obsdaq::parse_data_ascii(data_obs_vector *data, char *buf) {
std::vector<double> n;
unsigned long int n32, num;
// Flag for mode: 1 -> free-run; 2 -> single data request; 0: undefined
char mode = 0;
// Set data to missing
data->set_values_MD();
n.assign(data->get_N(), data->get_MD());
......@@ -1079,10 +1085,16 @@ int driver_obs_obsdaq::parse_data_ascii(data_obs_vector *data, char *buf) {
//
/////////////////////////////////////////////////////////////////////////
//std::cerr << "Received ASCII: " << buf << " / " << strlen(buf) << std::endl;
std::cerr << "Received ASCII: "
<< buf << " / " << strlen(buf) << std::endl;
// CHeck if ASCII free-run format
if (strncmp(buf, "*", 1) != 0) {
// Check if ASCII free-run format
if (strncmp(buf, "*", 1) == 0) {
mode = 1;
} else if (strncmp(buf, ">", 1) == 0) {
mode = 2;
} else {
std::cerr << "WARNING: INVALID DATA FORMAT" << std::endl;
return (-1);
}
......@@ -1104,7 +1116,9 @@ int driver_obs_obsdaq::parse_data_ascii(data_obs_vector *data, char *buf) {
}
// Skip t:
pos = pos + 2;
if (mode == 1){
pos = pos + 2;
}
// TODO: Use all auxiliary channels
// ObsDaq Voltage and Temperature
......@@ -1146,8 +1160,8 @@ int driver_obs_obsdaq::parse_data_ascii(data_obs_vector *data, char *buf) {
n[4]=n[4]*0.000575+1.0;
*/
// Save the data
data->set_data(n);
// Save the data
data->set_all(n);
return (0);
......
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