Skip to content
GitLab
Menu
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
935e7a20
Commit
935e7a20
authored
Jan 30, 2019
by
Tobias Bjerg
Browse files
Merge branch 'rasp3_DTU' of gitext.gfz-potsdam.de:mors/GeomagLogger into rasp3_DTU
parents
4e984fd6
bec7dd2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/driver_obs_obsdaq.cpp
View file @
935e7a20
...
...
@@ -103,32 +103,20 @@ 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
){
find_baud
();
stop
();
set_baud
(
baud
);
}
else
{
stop
();
}
// 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
);
break
;
}
// Initialize
init
();
...
...
@@ -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
);
}
...
...
@@ -1276,6 +1265,7 @@ int driver_obs_obsdaq::check_baud(int baud){
if
(
Driver_Obs_Serial
::
set_baud
(
baud
)
<
0
)
{
return
(
-
1
);
}
////////////////////////////////////////////////////////////////////////
//
...
...
@@ -1283,7 +1273,7 @@ int driver_obs_obsdaq::check_baud(int baud){
//
////////////////////////////////////////////////////////////////////////
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
);
...
...
src/driver_serial.cpp
View file @
935e7a20
...
...
@@ -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
++
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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