Skip to content
Snippets Groups Projects
Commit c04b7fa8 authored by Ludwig Knüpfer's avatar Ludwig Knüpfer
Browse files

add debug information to chardev_loop

parent de3b85ff
No related branches found
No related tags found
No related merge requests found
...@@ -55,10 +55,11 @@ void chardev_loop(ringbuffer_t *rb) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment