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
ba053dae
Commit
ba053dae
authored
Nov 06, 2018
by
Achim Morschhauser
Browse files
Initialization of driver_obs_obsdaq
parent
63dc9511
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/driver_obs_obsdaq.hpp
View file @
ba053dae
...
...
@@ -123,6 +123,14 @@ int set_term();
private:
/** Initialize the instrument with given baud rate */
int
set_baud
(
int
baud
);
/** Find the correct baud rate */
int
find_baud
();
/** Check if we are listening on correct baud rate */
int
check_baud
(
int
baud
);
/** Send an OBSDAQ-type command to address of RS-485 serial port */
int
send
(
const
char
*
cmd
);
/** Send an OBSDAQ-type command to address of RS-485 serial port */
...
...
src/driver_obs_obsdaq.cpp
View file @
ba053dae
...
...
@@ -73,17 +73,7 @@ driver_obs_obsdaq::driver_obs_obsdaq(std::string port, buffer_obs* buffer,
// Check for baud rate with the right address.
// Stop any running measurement when doing so.
const
char
*
cmds
[]
=
{
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"$M"
};
set_baud
((
char
**
)
cmds
,
9
);
find_baud
();
// Initialize the OBSDAQ
init
();
...
...
@@ -110,11 +100,21 @@ driver_obs_obsdaq::driver_obs_obsdaq(std::string port, int baud,
sprintf
(
addr_str
,
"%02X"
,
addr
);
RS485_addrstr
=
std
::
string
(
addr_str
);
// Set the hardware baud rate
set_baud
(
baud
);
/* 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
stop
();
...
...
@@ -1123,3 +1123,71 @@ int driver_obs_obsdaq::init_run(double freq){
}
/****************************************************************************
*
* Set the baud rate.
*
* Set filter rates.
*
***************************************************************************/
int
driver_obs_obsdaq
::
set_baud
(
int
baud
)
{
std
::
string
cmd
;
////////////////////////////////////////////////////////////////////////
//
// Set the baud rate of ObsDAQ
//
////////////////////////////////////////////////////////////////////////
cmd
=
"%"
+
RS485_addrstr
+
"00"
+
"07"
+
"00"
;
if
(
checked_send
(
cmd
.
c_str
(),
"!"
,
1
,
2
)
<
0
){
return
(
-
1
);
}
////////////////////////////////////////////////////////////////////////
//
// Set the baud rate of serial port
//
////////////////////////////////////////////////////////////////////////
if
(
Driver_Obs_Serial
::
set_baud
(
baud
)
<
0
)
{
return
(
-
1
);
}
return
(
0
);
}
/****************************************************************************
*
* Find the correct baud rate.
*
***************************************************************************/
int
driver_obs_obsdaq
::
find_baud
()
{
const
char
*
cmds
[]
=
{
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"||||||||||||||||||||||||||||||||||||||||||||||||"
,
"$M"
,
"$M"
};
Driver_Obs_Serial
::
set_baud
((
char
**
)
cmds
,
10
);
}
/****************************************************************************
*
* Check if the specified baud rate is correct
*
***************************************************************************/
int
driver_obs_obsdaq
::
check_baud
(
int
baud
){
return
(
0
);
}
\ No newline at end of file
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