Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giulia Facchi
Skyward Boardcore
Commits
8e5cb22a
Commit
8e5cb22a
authored
2 years ago
by
EmilioCorigliano
Committed by
Emilio Corigliano
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[VN100] Correctly using the usart bus instead of creating it in the driver
parent
6370560d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/shared/sensors/VN100/VN100.cpp
+9
-16
9 additions, 16 deletions
src/shared/sensors/VN100/VN100.cpp
src/shared/sensors/VN100/VN100.h
+8
-9
8 additions, 9 deletions
src/shared/sensors/VN100/VN100.h
src/tests/sensors/test-vn100.cpp
+3
-1
3 additions, 1 deletion
src/tests/sensors/test-vn100.cpp
with
20 additions
and
26 deletions
src/shared/sensors/VN100/VN100.cpp
+
9
−
16
View file @
8e5cb22a
...
...
@@ -27,11 +27,10 @@
namespace
Boardcore
{
VN100
::
VN100
(
USART
Type
*
portNumber
,
int
baudRate
,
CRCOptions
crc
,
VN100
::
VN100
(
USART
&
usart
,
int
baudRate
,
CRCOptions
crc
,
uint16_t
samplePeriod
)
:
portNumber
(
portNumber
),
baudRate
(
baudRate
),
crc
(
crc
)
:
usart
(
usart
),
baudRate
(
baudRate
),
samplePeriod
(
samplePeriod
),
crc
(
crc
)
{
this
->
samplePeriod
=
samplePeriod
;
}
bool
VN100
::
init
()
...
...
@@ -151,7 +150,7 @@ bool VN100::sampleRaw()
}
// Send the IMU sampling command
serialInterface
->
writeString
(
preSampleImuString
->
c_str
());
usart
.
writeString
(
preSampleImuString
->
c_str
());
// Wait some time
// TODO dimension the time
...
...
@@ -200,9 +199,6 @@ bool VN100::closeAndReset()
// Free the recvString memory
delete
recvString
;
// Free the serialInterface memory
delete
serialInterface
;
return
true
;
}
...
...
@@ -241,7 +237,7 @@ VN100Data VN100::sampleData()
}
// Returns Quaternion, Magnetometer, Accelerometer and Gyro
serialInterface
->
writeString
(
preSampleImuString
->
c_str
());
usart
.
writeString
(
preSampleImuString
->
c_str
());
// Wait some time
// TODO dimension the time
...
...
@@ -269,7 +265,7 @@ VN100Data VN100::sampleData()
// Returns Magnetometer, Accelerometer, Gyroscope, Temperature and Pressure
// (UNCOMPENSATED) DO NOT USE THESE MAGNETOMETER, ACCELEROMETER AND
// GYROSCOPE VALUES
serialInterface
->
writeString
(
preSampleTempPressString
->
c_str
());
usart
.
writeString
(
preSampleTempPressString
->
c_str
());
// Wait some time
// TODO dimension the time
...
...
@@ -319,7 +315,7 @@ bool VN100::disableAsyncMessages(bool waitResponse)
bool
VN100
::
configDefaultSerialPort
()
{
// Initial default settings
serialInterface
=
new
USART
(
portNumber
,
115200
);
usart
.
setBaudrate
(
115200
);
// Check correct serial init
return
true
;
...
...
@@ -342,11 +338,8 @@ bool VN100::configUserSerialPort()
return
false
;
}
// Destroy the serial object
delete
serialInterface
;
// I can open the serial with user's baud rate
serialInterface
=
new
USART
(
portNumber
,
baudRate
);
usart
.
setBaudrate
(
baudRate
);
// Check correct serial init
return
true
;
...
...
@@ -654,7 +647,7 @@ bool VN100::sendStringCommand(std::string command)
}
// I send the final command
serialInterface
->
writeString
(
command
.
c_str
());
usart
.
writeString
(
command
.
c_str
());
// Wait some time
// TODO dimension the time
...
...
@@ -667,7 +660,7 @@ bool VN100::recvStringCommand(char *command, int maxLength)
{
int
i
=
0
;
// Read the buffer
if
(
!
(
serialInterface
->
readBlocking
(
command
,
maxLength
))
)
if
(
!
usart
.
readBlocking
(
command
,
maxLength
))
{
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
src/shared/sensors/VN100/VN100.h
+
8
−
9
View file @
8e5cb22a
...
...
@@ -80,13 +80,13 @@ public:
/**
* @brief Constructor.
*
* @param
USART port numbe
r.
* @param
usart Serial bus used for the senso
r.
* @param BaudRate different from the sensor's default [9600, 19200, 38400,
* 57600, 115200, 128000, 230400, 460800, 921600].
* @param Redundancy check option.
* @param samplePeriod Sampling period in ms
*/
VN100
(
USART
Type
*
portNumber
=
USART2
,
int
baud
R
ate
=
921600
,
VN100
(
USART
&
usart
,
int
baud
r
ate
,
CRCOptions
crc
=
CRCOptions
::
CRC_ENABLE_8
,
uint16_t
samplePeriod
=
20
);
...
...
@@ -238,8 +238,13 @@ private:
*/
uint16_t
calculateChecksum16
(
uint8_t
*
message
,
int
length
);
USARTType
*
portNumber
;
/**
* @brief Serial interface that is needed to communicate
* with the sensor via ASCII codes.
*/
USART
&
usart
;
int
baudRate
;
uint16_t
samplePeriod
;
CRCOptions
crc
;
bool
isInit
=
false
;
...
...
@@ -266,12 +271,6 @@ private:
*/
unsigned
int
recvStringLength
=
0
;
/**
* @brief Serial interface that is needed to communicate
* with the sensor via ASCII codes.
*/
USARTInterface
*
serialInterface
=
nullptr
;
/**
* @brief Mutex to synchronize the reading and writing of the threadSample
*/
...
...
This diff is collapsed.
Click to expand it.
src/tests/sensors/test-vn100.cpp
+
3
−
1
View file @
8e5cb22a
...
...
@@ -31,7 +31,9 @@ int main()
{
VN100Data
sample
;
string
sampleRaw
;
VN100
sensor
{
USART1
,
921600
,
VN100
::
CRCOptions
::
CRC_ENABLE_16
};
USART
usart
(
USART1
,
921600
);
VN100
sensor
{
usart
,
921600
,
VN100
::
CRCOptions
::
CRC_ENABLE_16
};
// Let the sensor start up
Thread
::
sleep
(
1000
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment