mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 18:13:49 +01:00
add debug information to chardev_loop
This commit is contained in:
parent
de3b85ffc3
commit
c04b7fa8be
@ -55,10 +55,11 @@ void chardev_loop(ringbuffer_t *rb)
|
|||||||
msg_receive(&m);
|
msg_receive(&m);
|
||||||
|
|
||||||
if (m.sender_pid != pid) {
|
if (m.sender_pid != pid) {
|
||||||
DEBUG("Receiving message from another thread\n");
|
DEBUG("Receiving message from another thread: ");
|
||||||
|
|
||||||
switch(m.type) {
|
switch(m.type) {
|
||||||
case OPEN:
|
case OPEN:
|
||||||
|
DEBUG("OPEN\n");
|
||||||
if (reader_pid == -1) {
|
if (reader_pid == -1) {
|
||||||
reader_pid = m.sender_pid;
|
reader_pid = m.sender_pid;
|
||||||
/* no error */
|
/* no error */
|
||||||
@ -72,6 +73,7 @@ void chardev_loop(ringbuffer_t *rb)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case READ:
|
case READ:
|
||||||
|
DEBUG("READ\n");
|
||||||
if (m.sender_pid != reader_pid) {
|
if (m.sender_pid != reader_pid) {
|
||||||
m.content.value = -EINVAL;
|
m.content.value = -EINVAL;
|
||||||
r = NULL;
|
r = NULL;
|
||||||
@ -84,6 +86,7 @@ void chardev_loop(ringbuffer_t *rb)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CLOSE:
|
case CLOSE:
|
||||||
|
DEBUG("CLOSE\n");
|
||||||
if (m.sender_pid == reader_pid) {
|
if (m.sender_pid == reader_pid) {
|
||||||
DEBUG("uart0_thread: closing file from %i\n", reader_pid);
|
DEBUG("uart0_thread: closing file from %i\n", reader_pid);
|
||||||
reader_pid = -1;
|
reader_pid = -1;
|
||||||
@ -98,12 +101,14 @@ void chardev_loop(ringbuffer_t *rb)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
DEBUG("UNKNOWN\n");
|
||||||
m.content.value = -EINVAL;
|
m.content.value = -EINVAL;
|
||||||
msg_reply(&m, &m);
|
msg_reply(&m, &m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rb->avail && (r != NULL)) {
|
if (rb->avail && (r != NULL)) {
|
||||||
|
DEBUG("Data is available\n");
|
||||||
int state = disableIRQ();
|
int state = disableIRQ();
|
||||||
int nbytes = min(r->nbytes, rb->avail);
|
int nbytes = min(r->nbytes, rb->avail);
|
||||||
DEBUG("uart0_thread [%i]: sending %i bytes received from %i to pid %i\n", pid, nbytes, m.sender_pid, reader_pid);
|
DEBUG("uart0_thread [%i]: sending %i bytes received from %i to pid %i\n", pid, nbytes, m.sender_pid, reader_pid);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user