Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Achim Morschhauser
GeomagLogger
Commits
489caf57
Commit
489caf57
authored
Apr 09, 2021
by
Thomas Edwards
Browse files
Hardcopied over develop branch to raspi_DTU branch
parent
bf88f3d6
Changes
14
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
489caf57
...
...
@@ -26,7 +26,6 @@ usr/src/*
!usr/src/OBSDAQ_Logger.cpp
!usr/src/Serial_Talk.cpp
!usr/src/Stream_Reader.cpp
!usr/src/GSM90_Console.cpp
!usr/par/
/usr/par/*
!usr/par/parameters_default.par
...
...
include/data_obs.hpp
View file @
489caf57
...
...
@@ -149,7 +149,6 @@ public: int set_values_MD();
/** Get a string representation */
public:
virtual
int
string
(
std
::
string
*
string
,
int
precision
);
// public: virtual int string(std::string* string, int precision, bool iaga);
/** Parse a string representation */
public:
virtual
int
parse
(
std
::
string
*
string
);
...
...
include/data_obs_scalar.hpp
View file @
489caf57
...
...
@@ -40,7 +40,7 @@ class data_obs_scalar : public data_obs
/** Set the data */
public:
int
set_data
(
double
value
,
int
quality
);
/** Get the data */
public:
int
get_data
(
double
*
value
,
int
*
quality
);
...
...
@@ -55,9 +55,6 @@ class data_obs_scalar : public data_obs
/** Set single data fields */
public:
int
set_value
(
double
data
);
/** Get string */
public:
int
set_string
(
char
*
raw_buffer
);
/** Get a string representation of the form
"YYYY MM DD HH mm ss mil" where mil: milliseconds*/
public:
virtual
int
string
(
std
::
string
*
string
,
int
precision
);
...
...
src/Filter_Obs.cpp
View file @
489caf57
...
...
@@ -10,10 +10,6 @@
#include
<queue>
#include
<vector>
#include
<iostream>
#include
<iomanip>
#include
<typeinfo>
#include
<typeindex>
// C Headers
#include
<time.h>
...
...
src/data_obs.cpp
View file @
489caf57
...
...
@@ -33,6 +33,7 @@
data_obs
::
data_obs
()
{
year
=
0
;
// TODO: Assign MD, move MD variable to data_obs class
estimated_timing_error
=-
99999
;
}
...
...
@@ -134,9 +135,6 @@ int data_obs::set_time(int year, int mon, int day, int hour, int min, int sec,
********************************************************************************/
int
data_obs
::
set_time
(
struct
timespec
*
time
)
{
// fprintf(stderr,"TIME0: %ld.%.9ld\n", (long)time->tv_sec, time->tv_nsec);
// fprintf(stderr,"TIME1: %lld.%.9ld\n", (long long)time->tv_sec, time->tv_nsec);
// Initialize tm
//TODO Make t a class-variable to avoid repeated allocation
struct
tm
t
=
{
0
};
...
...
@@ -144,7 +142,6 @@ int data_obs::set_time(struct timespec* time) {
// Use gmtime_r for thread-safety
gmtime_r
(
&
time
->
tv_sec
,
&
t
);
// fprintf(stderr,"TIME2: %lld.%.9ld\n", (long long)time->tv_sec, time->tv_nsec);
year
=
t
.
tm_year
+
1900
;
mon
=
t
.
tm_mon
+
1
;
day
=
t
.
tm_mday
;
...
...
@@ -152,9 +149,6 @@ int data_obs::set_time(struct timespec* time) {
min
=
t
.
tm_min
;
sec
=
t
.
tm_sec
;
msec
=
time
->
tv_nsec
;
// fprintf(stderr,"TIME3: %lld.%.9ld\n", sec, msec);
// msec = time->tv_nsec;
return
(
0
);
...
...
@@ -294,12 +288,7 @@ int data_obs::get_time(struct timespec* time) const{
struct
tm
tm
;
tm
.
tm_year
=
year
-
1900
;
tm
.
tm_mon
=
mon
-
1
;
tm
.
tm_mday
=
day
;
tm
.
tm_hour
=
hour
;
tm
.
tm_min
=
min
;
tm
.
tm_sec
=
sec
;
get_time
(
&
tm
);
time
->
tv_sec
=
timegm
(
&
tm
);
time
->
tv_nsec
=
msec
;
...
...
@@ -336,9 +325,9 @@ int data_obs::get_min() {
int
data_obs
::
get_sec
()
{
return
(
sec
);
}
// Microseconds
long
data_obs
::
get_msec
()
{
return
(
msec
);
return
(
msec
);
}
/********************************************************************************
...
...
@@ -523,7 +512,9 @@ int data_obs::get_Nsupp(){
********************************************************************************/
int
data_obs
::
string
(
std
::
string
*
string
,
int
precision
)
{
// using namespace std;
using
namespace
std
;
ostringstream
str
;
str
<<
setfill
(
'0'
)
<<
right
<<
setw
(
4
)
<<
year
<<
' '
<<
setw
(
2
)
<<
mon
<<
' '
...
...
@@ -540,41 +531,6 @@ int data_obs::string(std::string* string, int precision) {
}
// /********************************************************************************
// * *
// * Return string representation of data. *
// * *
// * The string is represented as "YYYY MM DD HH mm ss mis" (mis: milliseconds) *
// * *
// ********************************************************************************/
// int data_obs::string(std::string* string, int precision, bool iaga=false) {
// using namespace std;
// ostringstream str;
// str << setfill('0');
// // if we want a condensed output, remove YY MM DD and format for IAGA files
// if (iaga == true) {
// str << setw(2) << hour << ':' << setw(2) << min << ':' << setw(2) << sec << '.'
// << setw(3) << msec;
// } else {
// str << setw(4) << year;
// str << ' ' << setw(2) << mon << ' ' << setw(2) << day << ' ' << setw(2)
// << hour << ' ' << setw(2) << min << ' ' << setw(2) << sec << '.'
// << setw(precision) << msec;
// }
// // str << ' ' << setw(6) << estimated_timing_error;
// *string = str.str();
// return (0);
// }
/****************************************************************************
* *
* Parse string representation of data. *
...
...
@@ -601,7 +557,6 @@ int data_obs::parse(std::string* string) {
sec
=
(
int
)
secmsec
;
msec
=
(
secmsec
-
sec
)
*
1e9
;
// msec = (secmsec - sec);
return
(
str
.
tellg
());
...
...
src/data_obs_scalar.cpp
View file @
489caf57
...
...
@@ -123,19 +123,6 @@ int data_obs_scalar::set_value(double value) {
}
/********************************************************************************
* *
* Set specified elemetns of stored data. *
* *
********************************************************************************/
int
data_obs_scalar
::
set_string
(
char
*
raw_buffer
)
{
this
->
raw_buffer
=
std
::
string
(
raw_buffer
);
return
(
0
);
}
/********************************************************************************
* *
* Return string representation of data. *
...
...
@@ -146,34 +133,20 @@ int data_obs_scalar::set_string(char* raw_buffer) {
********************************************************************************/
int
data_obs_scalar
::
string
(
std
::
string
*
string
,
int
precision
)
{
// using namespace std;
// data_obs::string(string,precision);
// ostringstream str;
// str << setfill('0');
// str << date << ' ' << time;
// str << ' ' << fixed << setw(6+precision) << setprecision(precision) << value;
// str << ' ' << setw(2) << quality;
// *string = *string + str.str();
// return (0);
using
namespace
std
;
data_obs
::
string
(
string
,
precision
);
ostringstream
str
;
str
<<
" "
<<
raw_buffer
;
str
<<
setfill
(
'0'
);
str
<<
' '
<<
fixed
<<
setw
(
6
+
precision
)
<<
setprecision
(
precision
)
<<
value
;
str
<<
' '
<<
setw
(
2
)
<<
quality
;
*
string
=
*
string
+
str
.
str
();
return
(
0
);
}
/********************************************************************************
...
...
src/driver_obs_gsm.cpp
View file @
489caf57
...
...
@@ -85,8 +85,6 @@ int driver_obs_gsm::freerun(double freq) {
char
buf
[
100
];
// Data
std
::
string
date
;
std
::
string
time
;
double
value
;
int
quality
;
...
...
@@ -106,12 +104,10 @@ int driver_obs_gsm::freerun(double freq) {
if
(
receive
(
buf
,
sizeof
(
buf
),
3
,
&
recv_time
)
>=
0
)
{
// Parse data from answer
// sscanf(buf, "%s %s %lf %d", &date, &time, &value, &quality);
// fprintf(stderr,buf);
// fprintf(stderr,"\n");
sscanf
(
buf
,
"%lf %d"
,
&
value
,
&
quality
);
// Store to data structure
// data.set_data(date, time, value, quality);
data
.
set_string
(
buf
);
data
.
set_data
(
value
,
quality
);
data
.
set_time
(
&
recv_time
);
// Write measurement to buffer
...
...
src/driver_obs_gsm90.cpp
View file @
489caf57
...
...
@@ -107,7 +107,7 @@ int driver_obs_gsm90::run(double freq) {
***************************************************************************/
int
driver_obs_gsm90
::
freerun
(
double
freq
)
{
//
set_cycle(freq);
set_cycle
(
freq
);
/////////////////////////////////////////////////////////////////////////
//
...
...
src/driver_obs_obsdaq.cpp
View file @
489caf57
...
...
@@ -110,7 +110,7 @@ driver_obs_obsdaq::driver_obs_obsdaq(std::string port, int baud,
case
2
:
stop
();
break
;
case
1
:
case
1
:
break
;
default:
find_baud
();
...
...
@@ -118,6 +118,7 @@ driver_obs_obsdaq::driver_obs_obsdaq(std::string port, int baud,
set_baud
(
baud
);
break
;
}
// Initialize
init
();
...
...
@@ -320,7 +321,7 @@ int driver_obs_obsdaq::freerun(double freq) {
usleep
(
2e6
);
// Flush
usleep
(
1e6
);
usleep
(
1e6
);
flush
();
if
(
driver_obs
::
freq
<
10.0
){
...
...
@@ -352,7 +353,7 @@ int driver_obs_obsdaq::freerun(double freq) {
// Receive data
if
(
receive
(
buf
,
sizeof
(
buf
),
0
,
&
recv_time
)
>=
0
)
{
//
fprintf(stderr,"Received: %s\n",buf);
//fprintf(stderr,"Received: %s\n",buf);
// Set the time
data
.
set_time
(
&
recv_time
);
...
...
@@ -362,10 +363,11 @@ int driver_obs_obsdaq::freerun(double freq) {
// Parse data from answer
if
(
(
this
->*
parse_data
)(
&
data
,
buf
)
>=
0
){
// Calibrate the measurement/ASCII
driver_obs
::
cal
->
calibrate
(
&
data
);
// Calibrate the measurement/ASCII
driver_obs
::
cal
->
calibrate
(
&
data
);
}
}
// Write measurement to buffer
buffer
->
put
(
&
data
);
...
...
@@ -390,7 +392,6 @@ int driver_obs_obsdaq::stop() {
// Check if logger is running
while
(
waitanswer
(
2
)
==
0
)
{
// Stop free-run mode
// checked_send(stopstr,"",7,1.0);
Driver_Obs_Serial
::
send
(
stopstr
);
}
...
...
@@ -998,7 +999,6 @@ int driver_obs_obsdaq::parse_data_bin(data_obs_vector* data, char* buf) {
return
(
-
1
);
}
////////////////////////////////////////////////////////////////////////
//
// Parse the binary data (Manual 12.5.2).
...
...
@@ -1022,17 +1022,6 @@ int driver_obs_obsdaq::parse_data_bin(data_obs_vector* data, char* buf) {
// Check for correct length of buffer
if
(
strlen
(
buf
)
!=
reclen
){
// debug printing
time_t
timer
;
char
time_str_buffer
[
26
];
struct
tm
*
tm_info
;
timer
=
time
(
NULL
);
tm_info
=
localtime
(
&
timer
);
strftime
(
time_str_buffer
,
26
,
"[%Y-%m-%d %H:%M:%S]: "
,
tm_info
);
puts
(
time_str_buffer
);
// fprintf(stderr,time_str_buffer);
std
::
cerr
<<
time_str_buffer
;
fprintf
(
stderr
,
"Received number of bytes not consistent. "
"Expected: %d. Received: %lu
\n
"
,
reclen
,
strlen
(
buf
));
...
...
@@ -1385,8 +1374,6 @@ int driver_obs_obsdaq::init_run(double freq){
}
// Save calibration constants
if
(
auto_cal
)
{
driver_obs
::
cal
->
save_adc_calibrate
();
...
...
src/driver_serial.cpp
View file @
489caf57
...
...
@@ -29,7 +29,6 @@
// C++ Headers
#include
<iostream>
#include
<chrono>
// Custom C++ Headers
#include
<driver_serial.hpp>
...
...
@@ -216,12 +215,6 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
}
// [DEBUG]
// timing tests (demo 1)
// auto t0_outer = std::chrono::high_resolution_clock::now();
// auto t0 = std::chrono::high_resolution_clock::now();
// std::chrono::duration<double, std::milli> elapsed_time = t0 - t0;
// Repeat loop until all termination characters have been received
while
(
n
<
termlen
)
{
...
...
@@ -249,14 +242,13 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
//
if
(
read
(
fd
,
&
c
,
1
)
>
0
)
{
//
fprintf(stderr, "Received: %d / %c / %d / %d %d \n",c,c,term[n],n,!ignnul || c !=0);
//
fprintf(stderr, "Buffer: %d, %s \n",i,buf);
//
fprintf(stderr, "Received: %d / %c / %d / %d %d \n",c,c,term[n],n,!ignnul || c !=0);
//
fprintf(stderr, "Buffer: %d, %s \n",i,buf);
// A correct termination character has arrived
if
(
c
==
term
[
n
])
{
n
++
;
buf
[
i
++
]
=
c
;
// fprintf(stderr,"termchar\n");
}
// A character was received
else
if
(
!
ignnul
||
c
!=
0
)
{
...
...
@@ -272,18 +264,9 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
i
-=
n
;
buf
[
i
]
=
0
;
n
=
0
;
// fprintf(stderr,"termreset\n");
}
// Save character to buffer
buf
[
i
++
]
=
c
;
// fprintf(stderr,"non-termchar\n");
// [DEBUG]
// timing tests
// auto t1 = std::chrono::high_resolution_clock::now();
// std::chrono::duration<double, std::milli> fp_ms = t1 - t0;
// fprintf(stderr,"time in call: %f\n",fp_ms.count() );
// elapsed_time += fp_ms;
}
// Check for buffer overrun
if
(
i
>=
buflen
)
{
...
...
@@ -294,25 +277,19 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
}
}
}
//
// Receive was successful if we arrive here.
//
// Set zero character correctly to ignore termination characters.
buf
[
i
-
n
]
=
0
;
//
fprintf(stderr, "i / n / termlen / Buffer: %d / %d / %d / %s / \n",i,n,termlen,buf);
//fprintf(stderr, "i / n / termlen / Buffer: %d / %d / %d / %s / \n",i,n,termlen,buf);
// Flush the serial port
// flush();
// [DEBUG]
// timing tests
// auto t1_outer = std::chrono::high_resolution_clock::now();
// std::chrono::duration<double, std::milli> fp_ms_outer = t1_outer - t0_outer;
// fprintf(stderr,"elapsed time in outer loop: %f\n",fp_ms_outer.count() );
// fprintf(stderr,"total time actually processing characters: %f\n",elapsed_time.count() );
//flush();
return
(
0
);
...
...
@@ -734,12 +711,6 @@ int driver_serial::init() {
return
(
-
1
);
}
// [DEBUG]
// if ((fd = open((char *) port.c_str(), O_RDWR | O_NOCTTY)) < 0) {
// std::cerr << "Couldn't open serial port " << port << std::endl;
// return (-1);
// }
//
// Check if we are indeed dealing with a serial device.
//
...
...
usr/START/ObsDAQ
View file @
489caf57
...
...
@@ -15,8 +15,5 @@ source $PAR_FILE
# Create logging directory
mkdir
-p
$DIR_LOG
# Set the port to high rate
setserial
$PORT_VEC
low_latency
# Start data acquisition
{
trap
'kill 0'
EXIT
;
OBSDAQ_Logger
$PAR_FILE
2>
$DIR_LOG
/OBSDAQ.log
;
pkill
-g
0
;
}
|
{
trap
'kill 0'
EXIT
;
Stream_Reader
$PAR_FILE
2>
$DIR_LOG
/Stream_Reader.log
;
pkill
-g
0
;
}
usr/src/GSM_Logger.cpp
View file @
489caf57
...
...
@@ -33,6 +33,6 @@ int main(int argc, char* argv[]) {
// Take continuous measurements
fprintf
(
stderr
,
"Run
\n
"
);
gsm90
.
free
run
(
par
.
get_int
(
"FREQ_SCA"
));
gsm90
.
run
(
par
.
get_int
(
"FREQ_SCA"
));
}
usr/src/OBSDAQ_Logger.cpp
View file @
489caf57
...
...
@@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
std
::
vector
<
double
>
scale
=
{
X_s
/
R
,
Y_s
/
R
,
Z_s
/
R
,
S1_s
,
S2_s
,
S3_s
,
S4_s
,
S5_s
};
// Add standard pipe buffer to multi buffer
buffer_obs_mult
mult
=
new
buffer_obs_mult
(
new
buffer_obs_pipe
(
9
));
buffer_obs_mult
mult
=
new
buffer_obs_mult
(
new
buffer_obs_pipe
(
5
));
// Add file buffer, if file_format is given
if
(
(
par
.
get_str
(
"FILE_RAW"
)
!=
""
)
&&
...
...
usr/src/Serial_Talk.cpp
View file @
489caf57
...
...
@@ -12,22 +12,16 @@ int main(){
std
::
string
cmd
;
int
baud
;
std
::
string
port
;
char
term
[
1
];
term
[
0
]
=
13
;
// term[0]=182; // for GSM90
char
buf
[
10
00
];
char
buf
[
5
00
];
std
::
cerr
<<
"BAUD: "
;
std
::
cin
>>
baud
;
std
::
cerr
<<
"PORT: "
;
std
::
cin
>>
port
;
driver_serial
serial
=
driver_serial
(
port
,
term
,
1
,
baud
);
// driver_serial serial = driver_serial("/dev/OBSDAQ",term,1,baud);
driver_serial
serial
=
driver_serial
(
"/dev/OBSDAQ"
,
term
,
1
,
baud
);
serial
.
set_ignnul
(
true
);
while
(
1
){
...
...
@@ -44,14 +38,9 @@ int main(){
serial
.
send
((
const
char
*
)
cmd
.
c_str
());
serial
.
receive
(
buf
,
sizeof
(
buf
),
5
);
// serial.receive_raw(buf,sizeof(buf),5);
std
::
cerr
<<
buf
<<
std
::
endl
;
for
(
int
ix
=
0
;
ix
<
sizeof
(
buf
);
ix
++
)
{
std
::
cerr
<<
(
int
)
buf
[
ix
]
<<
" "
;
}
/*
// Extract data from channels 1-3
uint32_t num = (uint32_t) 0x800000L;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment