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
Nicolò Caruso
Skyward Boardcore
Commits
86e63f4d
Commit
86e63f4d
authored
2 years ago
by
EmilioCorigliano
Committed by
Emilio Corigliano
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[VN100] Fixed self test failing for reading wrong data
parent
8e5cb22a
Branches
vn100-upd
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
+11
-20
11 additions, 20 deletions
src/shared/sensors/VN100/VN100.cpp
src/shared/sensors/VN100/VN100.h
+1
-2
1 addition, 2 deletions
src/shared/sensors/VN100/VN100.h
src/tests/sensors/test-vn100.cpp
+20
-6
20 additions, 6 deletions
src/tests/sensors/test-vn100.cpp
with
32 additions
and
28 deletions
src/shared/sensors/VN100/VN100.cpp
+
11
−
20
View file @
86e63f4d
...
@@ -27,8 +27,7 @@
...
@@ -27,8 +27,7 @@
namespace
Boardcore
namespace
Boardcore
{
{
VN100
::
VN100
(
USART
&
usart
,
int
baudRate
,
CRCOptions
crc
,
VN100
::
VN100
(
USART
&
usart
,
int
baudRate
,
CRCOptions
crc
,
uint16_t
samplePeriod
)
uint16_t
samplePeriod
)
:
usart
(
usart
),
baudRate
(
baudRate
),
samplePeriod
(
samplePeriod
),
crc
(
crc
)
:
usart
(
usart
),
baudRate
(
baudRate
),
samplePeriod
(
samplePeriod
),
crc
(
crc
)
{
{
}
}
...
@@ -108,12 +107,6 @@ bool VN100::init()
...
@@ -108,12 +107,6 @@ bool VN100::init()
return
false
;
return
false
;
}
}
if
(
!
this
->
start
())
{
LOG_ERR
(
logger
,
"Unable to start the sampling thread"
);
return
false
;
}
// Set the isInit flag true
// Set the isInit flag true
isInit
=
true
;
isInit
=
true
;
...
@@ -128,11 +121,11 @@ void VN100::run()
...
@@ -128,11 +121,11 @@ void VN100::run()
while
(
!
shouldStop
())
while
(
!
shouldStop
())
{
{
long
long
initialTime
=
miosix
::
getTick
();
long
long
initialTime
=
miosix
::
getTick
();
{
// Sample the data locking the mutex
// Sample the data locking the mutex
miosix
::
Lock
<
FastMutex
>
l
(
mutex
);
miosix
::
Lock
<
FastMutex
>
l
(
mutex
);
threadSample
=
sampleData
();
threadSample
=
sampleData
();
}
// Sleep for the sampling period
// Sleep for the sampling period
miosix
::
Thread
::
sleepUntil
(
initialTime
+
samplePeriod
);
miosix
::
Thread
::
sleepUntil
(
initialTime
+
samplePeriod
);
}
}
...
@@ -418,20 +411,18 @@ bool VN100::selfTestImpl()
...
@@ -418,20 +411,18 @@ bool VN100::selfTestImpl()
return
false
;
return
false
;
}
}
// I check the model number (I perform the procedure twice to delete junk
// removing junk
// problems)
usart
.
clearQueue
();
sendStringCommand
(
"VNRRG,01"
);
miosix
::
Thread
::
sleep
(
100
);
// These sleep are important at very high baud rates
recvStringCommand
(
recvString
,
recvStringMaxDimension
);
miosix
::
Thread
::
sleep
(
100
);
// I check the model number
if
(
!
sendStringCommand
(
"VNRRG,01"
))
if
(
!
sendStringCommand
(
"VNRRG,01"
))
{
{
LOG_WARN
(
logger
,
"Unable to send string command"
);
LOG_WARN
(
logger
,
"Unable to send string command"
);
return
false
;
return
false
;
}
}
miosix
::
Thread
::
sleep
(
100
);
if
(
!
recvStringCommand
(
recvString
,
recvStringMaxDimension
))
if
(
!
recvStringCommand
(
recvString
,
recvStringMaxDimension
))
{
{
LOG_WARN
(
logger
,
"Unable to receive string command"
);
LOG_WARN
(
logger
,
"Unable to receive string command"
);
...
...
This diff is collapsed.
Click to expand it.
src/shared/sensors/VN100/VN100.h
+
1
−
2
View file @
86e63f4d
...
@@ -86,8 +86,7 @@ public:
...
@@ -86,8 +86,7 @@ public:
* @param Redundancy check option.
* @param Redundancy check option.
* @param samplePeriod Sampling period in ms
* @param samplePeriod Sampling period in ms
*/
*/
VN100
(
USART
&
usart
,
int
baudrate
,
VN100
(
USART
&
usart
,
int
baudrate
,
CRCOptions
crc
=
CRCOptions
::
CRC_ENABLE_8
,
CRCOptions
crc
=
CRCOptions
::
CRC_ENABLE_8
,
uint16_t
samplePeriod
=
20
);
uint16_t
samplePeriod
=
20
);
bool
init
()
override
;
bool
init
()
override
;
...
...
This diff is collapsed.
Click to expand it.
src/tests/sensors/test-vn100.cpp
+
20
−
6
View file @
86e63f4d
...
@@ -31,28 +31,42 @@ int main()
...
@@ -31,28 +31,42 @@ int main()
{
{
VN100Data
sample
;
VN100Data
sample
;
string
sampleRaw
;
string
sampleRaw
;
GpioPin
u2tx1
(
GPIOA_BASE
,
2
);
GpioPin
u2rx1
(
GPIOA_BASE
,
3
);
u2rx1
.
alternateFunction
(
7
);
u2rx1
.
mode
(
Mode
::
ALTERNATE
);
u2tx1
.
alternateFunction
(
7
);
u2tx1
.
mode
(
Mode
::
ALTERNATE
);
USART
usart
(
USART1
,
921600
);
USART
usart
(
USART1
,
921600
);
VN100
sensor
{
usart
,
921600
,
VN100
sensor
{
usart
,
921600
,
VN100
::
CRCOptions
::
CRC_ENABLE_16
};
VN100
::
CRCOptions
::
CRC_ENABLE_16
};
// Let the sensor start up
// Let the sensor start up
Thread
::
sleep
(
1000
);
Thread
::
sleep
(
1000
);
printf
(
"Initializing sensor
\n
"
);
if
(
!
sensor
.
init
())
if
(
!
sensor
.
init
())
{
{
printf
(
"Error initializing the sensor!
\n
"
);
printf
(
"Error initializing the sensor!
\n
"
);
return
0
;
return
0
;
}
}
printf
(
"Sensor init successful!
\n
"
);
printf
(
"Running self-test
\n
"
);
if
(
!
sensor
.
selfTest
())
if
(
!
sensor
.
selfTest
())
{
{
printf
(
"Error self test check!
\n
"
);
printf
(
"Unable to execute self-test
\n
"
);
return
0
;
}
if
(
!
sensor
.
start
())
{
printf
(
"Unable to start the sampling thread
\n
"
);
return
0
;
return
0
;
}
}
printf
(
"Sensor s
elf test successful
!
\n
"
);
printf
(
"Sensor s
ampling thread started
!
\n
"
);
// Sample and print 100 samples
// Sample and print 100 samples
for
(
int
i
=
0
;
i
<
100
;
i
++
)
for
(
int
i
=
0
;
i
<
100
;
i
++
)
...
...
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