Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
cm-projects
RIOT
Commits
e17b664e
Commit
e17b664e
authored
9 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
sys: remove chardev_thread
parent
a13bc46f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sys/chardev_thread.c
+0
-131
0 additions, 131 deletions
sys/chardev_thread.c
sys/include/chardev_thread.h
+0
-39
0 additions, 39 deletions
sys/include/chardev_thread.h
with
0 additions
and
170 deletions
sys/chardev_thread.c
deleted
100644 → 0
+
0
−
131
View file @
a13bc46f
/**
* Character device messaging loop.
*
* Copyright (C) 2013, INRIA.
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*
* @ingroup chardev
* @{
* @file
* @brief Runs an infinite loop in a separate thread to handle access to character devices such as uart.
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @}
*/
#include
<stdio.h>
#include
<errno.h>
#include
"irq.h"
#include
"msg.h"
#include
"ringbuffer.h"
#include
"posix_io.h"
/* increase stack size in uart0 when setting this to 1 */
#define ENABLE_DEBUG (0)
#include
"debug.h"
static
int
min
(
int
a
,
int
b
)
{
if
(
b
>
a
)
{
return
a
;
}
else
{
return
b
;
}
}
void
chardev_loop
(
ringbuffer_t
*
rb
)
{
msg_t
m
;
kernel_pid_t
reader_pid
=
KERNEL_PID_UNDEF
;
struct
posix_iop_t
*
r
=
NULL
;
puts
(
"UART0 thread started."
);
while
(
1
)
{
msg_receive
(
&
m
);
if
(
!
msg_sent_by_int
(
&
m
))
{
DEBUG
(
"Receiving message from another thread: "
);
switch
(
m
.
type
)
{
case
OPEN
:
DEBUG
(
"OPEN
\n
"
);
if
(
reader_pid
==
KERNEL_PID_UNDEF
)
{
reader_pid
=
m
.
sender_pid
;
/* no error */
m
.
content
.
value
=
0
;
}
else
{
m
.
content
.
value
=
-
EBUSY
;
}
msg_reply
(
&
m
,
&
m
);
break
;
case
READ
:
DEBUG
(
"READ
\n
"
);
if
(
m
.
sender_pid
!=
reader_pid
)
{
m
.
content
.
value
=
-
EINVAL
;
r
=
NULL
;
msg_reply
(
&
m
,
&
m
);
}
else
{
r
=
(
struct
posix_iop_t
*
)(
void
*
)
m
.
content
.
ptr
;
}
break
;
case
CLOSE
:
DEBUG
(
"CLOSE
\n
"
);
if
(
m
.
sender_pid
==
reader_pid
)
{
DEBUG
(
"uart0_thread: closing file from %"
PRIkernel_pid
"
\n
"
,
reader_pid
);
reader_pid
=
KERNEL_PID_UNDEF
;
r
=
NULL
;
m
.
content
.
value
=
0
;
}
else
{
m
.
content
.
value
=
-
EINVAL
;
}
msg_reply
(
&
m
,
&
m
);
break
;
default:
DEBUG
(
"UNKNOWN
\n
"
);
m
.
content
.
value
=
-
EINVAL
;
msg_reply
(
&
m
,
&
m
);
}
}
if
(
rb
->
avail
&&
(
r
!=
NULL
))
{
DEBUG
(
"Data is available
\n
"
);
unsigned
state
=
disableIRQ
();
int
nbytes
=
min
(
r
->
nbytes
,
rb
->
avail
);
DEBUG
(
"uart0_thread [%i]: sending %i bytes received from %"
PRIkernel_pid
" to pid %"
PRIkernel_pid
"
\n
"
,
thread_getpid
(),
nbytes
,
m
.
sender_pid
,
reader_pid
);
ringbuffer_get
(
rb
,
r
->
buffer
,
nbytes
);
r
->
nbytes
=
nbytes
;
m
.
sender_pid
=
reader_pid
;
m
.
type
=
OPEN
;
m
.
content
.
ptr
=
(
char
*
)
r
;
msg_reply
(
&
m
,
&
m
);
r
=
NULL
;
restoreIRQ
(
state
);
}
}
}
void
*
chardev_thread_entry
(
void
*
rb_
)
{
ringbuffer_t
*
rb
=
rb_
;
chardev_loop
(
rb
);
return
NULL
;
}
This diff is collapsed.
Click to expand it.
sys/include/chardev_thread.h
deleted
100644 → 0
+
0
−
39
View file @
a13bc46f
/*
* Copyright (C) 2010 Kaspar Schleiser
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup sys_chardevthread Chardev Thread
* @ingroup sys
* @brief Chardev thread
* @{
*
* @file
* @brief Handles I/O from a char devices
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef __CHARDEV_THREAD_H
#define __CHARDEV_THREAD_H
#include
"ringbuffer.h"
#ifdef __cplusplus
extern
"C"
{
#endif
void
chardev_loop
(
ringbuffer_t
*
rb
);
void
*
chardev_thread_entry
(
void
*
rb_
);
#ifdef __cplusplus
}
#endif
#endif
/* __CHARDEV_THREAD_H */
/** @} */
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