Skip to contentSkip to conversation

native pipe can not write

Xenomai-help Henk Geraads 2 participants 4 messages Dec 4, 2007 – Dec 5, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

we are currently using a PXA270 board with kernel 2.6.15 with xenomai 2.2.2. We are having the same problem. We create a pipe like; rt_pipe_create(&dti_pipe_wr, "DTI_FROM_UART", FIFO_WR, 1000);

i=rt_pipe_write(&dti_pipe_wr, data->dti_rcvbuf, 20, P_NORMAL)

we got error = -ENOMEM?

Is this the same error?

Quoted 25 lines

-- Gilles Chanteperdrix wrote :

Quoted 23 lines · wrote:

Hi,
I try to use the message pipe in native API, but I can not write to the pipe. Can anyone help me to find what is wrong?
And in Linux side it says:"write failed: Cannot allocate memory" Thank you!
Following is the program and return message.
#./test_pipe
create return: 0, write return: -12, read return: -110

#include <stdio.h>
#include <errno.h>
#include <native/task.h>
#include <sys/mman.h>

RT_PIPE pipe_desc;
RT_TASK task;

void op_pipe(void *arg)

{
        int  err, pipe_fd, wre, rre;
        char buf[16] = {'a', 'b', 'c'};
        char rd;
Quoted 11 lines
Quoted 5 lines
        err = rt_pipe_create(&pipe_desc, "my_testpipe2", 3, 128);
        char tmp[] = {"test pipe"};

        wre = rt_pipe_write(&pipe_desc, buf, 2, P_NORMAL);
        rre = rt_pipe_read(&pipe_desc, &rd, 2, 100);

I do not know if this is related with your issue, but the receive buff is too small: you want write 2 bytes in a 1 byte buffer.

Signature · 1 line
        Gilles Chanteperdrix.

If we create the pipe on the heap, that means at creation time with size '0' the pipe seems at first to works, but the memory of other processes (not related) is corrupted and those processes crashes!

Henk Geraads

#1 lore raw
Quoted 11 lines · Henk Geraads

Hi,

we are currently using a PXA270 board with kernel 2.6.15 with xenomai 2.2.2. We are having the same problem. We create a pipe like; rt_pipe_create(&dti_pipe_wr, "DTI_FROM_UART", FIFO_WR, 1000);

i=rt_pipe_write(&dti_pipe_wr, data->dti_rcvbuf, 20, P_NORMAL)

we got error = -ENOMEM?

Is this the same error?

See this discussion thread:
https://mail.gna.org/public/xenomai-help/2007-12/msg00012.html

Signature · 1 line
                                               Gilles Chanteperdrix
#2 lore raw

Hi,

Does this mean I have to perform the following patch also in my system?

skins/native/syscall.c +2 -2
@@ -2468,10 +2468,10 @@
 
 		if (size > 0)
 			__xn_copy_to_user(curr, buf, mbuf, size);
+
+		rt_queue_free(q, mbuf);
 	}
 
-	rt_queue_free(q, mbuf);
-
 	return (int)rsize;
 }
 

Br,

Henk Geraads

-----Oorspronkelijk bericht-----
Van: Gilles Chanteperdrix [mailto:[email protected]]
Verzonden: dinsdag 4 december 2007 14:28
Aan: [email protected]
CC: [email protected]
Onderwerp: Re: [Xenomai-help] native pipe can not write

Quoted 4 lines · Henk Geraads

Hi,

we are currently using a PXA270 board with kernel 2.6.15 with xenomai

2.2.2. We are having the same problem. We create a pipe like;

Quoted 7 lines

rt_pipe_create(&dti_pipe_wr, "DTI_FROM_UART", FIFO_WR, 1000);

i=rt_pipe_write(&dti_pipe_wr, data->dti_rcvbuf, 20, P_NORMAL)

we got error = -ENOMEM?

Is this the same error?

See this discussion thread:
https://mail.gna.org/public/xenomai-help/2007-12/msg00012.html

--
Gilles Chanteperdrix

#3 lore raw
Quoted 9 lines · Henk Geraads

Hi,

Does this mean I have to perform the following patch also in my system?

skins/native/syscall.c (revision 3196) renamed from skins/native/syscall.c (revision 3195) +0 -0
@@ -2468,10 +2468,10 @@
 

skins/native/syscall.c (revision 3196) line 2476

Quoted 10 lines
skins/native/syscall.c (revision 3196) renamed from skins/native/syscall.c (revision 3195) +2 -2
                if (size > 0)
                        __xn_copy_to_user(curr, buf, mbuf, size);
+
+               rt_queue_free(q, mbuf);
        }
 
-       rt_queue_free(q, mbuf);
-
        return (int)rsize;
 }

No, it is a bit more complicated than that. Several changes were made in the heap implementation. If you want to test the fixed implementation, which will allow to know if the problem you have is the one that was fixed, you should try svn trunk.

Signature · 1 line
                                               Gilles Chanteperdrix