Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
f4grx
NuttX RTOS
Commits
125d9e35
Commit
125d9e35
authored
10 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Fix a cornercase problem in in the UART simulation
parent
3f0e65a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arch/sim/src/up_simuart.c
+22
-15
22 additions, 15 deletions
arch/sim/src/up_simuart.c
with
22 additions
and
15 deletions
arch/sim/src/up_simuart.c
+
22
−
15
View file @
125d9e35
...
...
@@ -232,30 +232,37 @@ int simuart_getc(void)
int
index
;
int
ch
;
/* Locking the scheduler should eliminate the race conditions in the
* unlikely case of mutliple reading threads.
*/
sched_lock
();
for
(;;)
{
/* Wait for a byte to become available */
simuart_wait
();
/* The UART buffer show be non-empty... check anyway */
if
(
g_uarthead
!=
g_uarttail
)
while
(
g_uarthead
==
g_uarttail
)
{
/* Take the next byte from the tail of the buffer */
simuart_wait
();
}
index
=
g_uarttail
;
ch
=
(
int
)
g_uartbuffer
[
index
];
/* Increment the tai index (with wrapping) */
/* The UART buffer is non-empty... Take the next byte from the tail
* of the buffer.
*/
if
(
++
index
>
=
SIMUART_BUFSIZE
)
{
index
=
0
;
}
index
=
g_uarttail
;
ch
=
(
int
)
g_uartbuffer
[
index
];
/* Increment the tai index (with wrapping) */
g_uarttail
=
index
;
return
ch
;
if
(
++
index
>=
SIMUART_BUFSIZE
)
{
index
=
0
;
}
g_uarttail
=
index
;
sched_unlock
();
return
ch
;
}
}
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