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
1a3ea236
Commit
1a3ea236
authored
Jan 29, 2019
by
Achim Morschhauser
Browse files
Problem at startup fixed
parent
49d87ad2
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/driver_obs_obsdaq.cpp
View file @
1a3ea236
...
...
@@ -102,32 +102,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
();
...
...
@@ -688,6 +676,7 @@ int driver_obs_obsdaq::checked_send(const char* cmd, const char* reply,
}
return
(
-
1
);
}
strbuf
=
std
::
string
(
buf
);
// Construct expected answer
...
...
@@ -699,7 +688,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
);
}
...
...
@@ -709,7 +698,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
);
}
...
...
@@ -1275,6 +1264,7 @@ int driver_obs_obsdaq::check_baud(int baud){
if
(
Driver_Obs_Serial
::
set_baud
(
baud
)
<
0
)
{
return
(
-
1
);
}
////////////////////////////////////////////////////////////////////////
//
...
...
@@ -1282,7 +1272,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
...
...
@@ -1292,10 +1282,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 @
1a3ea236
...
...
@@ -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
++
;
...
...
usr/src/OBSDAQ_Logger.cpp
View file @
1a3ea236
...
...
@@ -37,7 +37,7 @@ int main() {
// Initialize new OBSDAQ device
driver_obs_obsdaq
obsdaq
=
driver_obs_obsdaq
(
par
.
get_str
(
"PORT"
),
par
.
get_int
(
"BAUD"
),
&
pipe
,
&
cal
,
1
);
par
.
get_int
(
"BAUD"
),
&
pipe
,
&
cal
,
0x0F
);
// Get some data
...
...
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