Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Ardupilot
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
OpenSource
Ardupilot
Commits
4f37a936
Commit
4f37a936
authored
12 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
SITL: prevent the GPS pipe filling up and delaying GPS readings
parent
025e27aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/Desktop/support/sitl_gps.cpp
+12
-0
12 additions, 0 deletions
libraries/Desktop/support/sitl_gps.cpp
with
12 additions
and
0 deletions
libraries/Desktop/support/sitl_gps.cpp
+
12
−
0
View file @
4f37a936
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include
<SITL.h>
#include
<SITL.h>
#include
<AP_GPS.h>
#include
<AP_GPS.h>
#include
<AP_GPS_UBLOX.h>
#include
<AP_GPS_UBLOX.h>
#include
<sys/ioctl.h>
#include
"desktop.h"
#include
"desktop.h"
#include
"util.h"
#include
"util.h"
...
@@ -46,6 +47,17 @@ static struct {
...
@@ -46,6 +47,17 @@ static struct {
*/
*/
ssize_t
sitl_gps_read
(
int
fd
,
void
*
buf
,
size_t
count
)
ssize_t
sitl_gps_read
(
int
fd
,
void
*
buf
,
size_t
count
)
{
{
#ifdef FIONREAD
// use FIONREAD to get exact value if possible
int
num_ready
;
while
(
ioctl
(
fd
,
FIONREAD
,
&
num_ready
)
==
0
&&
num_ready
>
256
)
{
// the pipe is filling up - drain it
uint8_t
tmp
[
128
];
if
(
read
(
fd
,
tmp
,
sizeof
(
tmp
))
!=
sizeof
(
tmp
))
{
break
;
}
}
#endif
return
read
(
fd
,
buf
,
count
);
return
read
(
fd
,
buf
,
count
);
}
}
...
...
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