problem with reading from rt_pipe with a normal linux process
Hi,
i do the following:
- create a pipe:
rt_pipe_create (&data_pipe, "data_pipe", PIPE_MINOR, PIPE_SIZE);
- write data to the pipe:
rt_pipe_write(&data_pipe, &pipe_buf, pipe_buf_sz, P_NORMAL);
- open the pipe from a normal linux process:
pipe_fd = open(DATA_PIPE, O_RDONLY);
- read the data from the pipe:
ret = read(pipe_fd, &pipe_buf, sizeof(pipe_buf));
Opening works, but the reading doesn't work. I get the error code "-1", Operation not permitted.
Permission for the device file is ok:
voyage:~# ls -l /dev/rtp0 crw-rw-rw- 1 root root 150, 0 Jun 21 2006 /dev/rtp0
What am I doing wrong?
Thanks
Marco
Linux voyage 2.6.16.1-03-xenomai-2.1.2 #1 PREEMPT Tue Jul 11 10:17:15 GMT 2006 i586 GNU/Linux
Gnu C 17: util-linux 2.12p mount 2.12p module-init-tools 3.2-pre1 e2fsprogs 1.37 pcmcia-cs 3.2.5 PPP 2.4.3 Linux C Library 2.3.2 Dynamic linker (ldd) 2.3.2 Procps 3.2.1 Net-tools 1.60 Kbd 69: Sh-utils 5.2.1 Modules Loaded xeno_16550A xeno_rtdm uhci_hcd ohci_hcd usbcore
dm_mod
Mhmm, strange, I can read the data with a "cat /dev/rtp0"....
Quoted 53 lines · Marco Jackel
Hi,
i do the following:- create a pipe:
rt_pipe_create(&data_pipe, "data_pipe",PIPE_MINOR,PIPE_SIZE);- write data to the pipe:
rt_pipe_write(&data_pipe, &pipe_buf, pipe_buf_sz, P_NORMAL);- open the pipe from a normal linux process:
pipe_fd=open(DATA_PIPE, O_RDONLY);- read the data from the pipe:
ret =
read(pipe_fd, &pipe_buf, sizeof(pipe_buf));Opening works, but the reading doesn't work. I get the error code "-1", Operation not permitted.
Permission for the device file is ok:
voyage:~# ls -l /dev/rtp0 crw-rw-rw- 1 root root 150, 0 Jun 21 2006 /dev/rtp0What am I doing wrong?
Thanks
MarcoLinux voyage 2.6.16.1-03-xenomai-2.1.2 #1 PREEMPT Tue Jul 11 10:17:15 GMT 2006 i586 GNU/Linux
Gnu C 17: util-linux 2.12p mount 2.12p module-init-tools 3.2-pre1 e2fsprogs 1.37 pcmcia-cs 3.2.5 PPP 2.4.3 Linux C Library 2.3.2 Dynamic linker (ldd) 2.3.2 Procps 3.2.1 Net-tools 1.60 Kbd 69: Sh-utils 5.2.1 Modules Loaded xeno_16550A xeno_rtdm uhci_hcd ohci_hcd usbcore
dm_mod
Quoted 2 lines · Marco Jackel
Mhmm, strange, I can read the data with a "cat
/dev/rtp0"....
Hint: read returns its error code in errno. What does that one tell you?
Jan
Quoted 61 lines
Quoted 52 lines · Marco Jackel
Hi,
i do the following:- create a pipe:
rt_pipe_create(&data_pipe, "data_pipe",PIPE_MINOR,PIPE_SIZE);- write data to the pipe:
rt_pipe_write(&data_pipe, &pipe_buf, pipe_buf_sz, P_NORMAL);- open the pipe from a normal linux process:
pipe_fd=open(DATA_PIPE, O_RDONLY);- read the data from the pipe:
ret =
read(pipe_fd, &pipe_buf, sizeof(pipe_buf));Opening works, but the reading doesn't work. I get the error code "-1", Operation not permitted.
Permission for the device file is ok:
voyage:~# ls -l /dev/rtp0 crw-rw-rw- 1 root root 150, 0 Jun 21 2006 /dev/rtp0What am I doing wrong?
Thanks
MarcoLinux voyage 2.6.16.1-03-xenomai-2.1.2 #1 PREEMPT Tue Jul 11 10:17:15 GMT 2006 i586 GNU/Linux
Gnu C 17: util-linux 2.12p mount 2.12p module-init-tools 3.2-pre1 e2fsprogs 1.37 pcmcia-cs 3.2.5 PPP 2.4.3 Linux C Library 2.3.2 Dynamic linker (ldd) 2.3.2 Procps 3.2.1 Net-tools 1.60 Kbd 69: Sh-utils 5.2.1 Modules Loaded xeno_16550A xeno_rtdm uhci_hcd ohci_hcd usbcoreQuoted 1 line
dm_mod_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Quoted 1 line · Jan Kiszka
Hint: read returns its error code in errno. What does that one tell you?
read returns -1, "operation not permitted"
Quoted 5 lines · Marco Jackel
Quoted 1 line · Jan Kiszka
Hint: read returns its error code in errno. What does that one tell you?
read returns -1, "operation not permitted"
errno == EPERM? A bit weird. Try strace'ing both your program and the cat tool to look for a difference.
Jan
Quoted 8 lines · Jan Kiszka
Quoted 4 lines · Marco Jackel
Quoted 1 line · Jan Kiszka
Hint: read returns its error code in errno. What does that one tell you?
read returns -1, "operation not permitted"
errno == EPERM? A bit weird. Try strace'ing both your program and the cat tool to look for a difference.
strace says "-1" in this case is ENOBUFS
The failure in my programm is that it writes binary data to a pipe with rt_pipe_write (preserves message boundary) and normal linux process wants to read it byte by byte with read(). Read wants to receive the whole message, but the message is bigger than 1 byte, so it returns ENOBUFS.
The solution is to use rt_pipe_stream (don't preserves message boundary). Do I have to use rt_pipe_alloc before? Is there a small sample program somewhere?
Thanks,
Marco
Quoted 7 lines · Marco Jackel
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Marco Jackel
Quoted 1 line · Jan Kiszka
Hint: read returns its error code in errno. What does that one tell you?
read returns -1, "operation not permitted"
Quoted 9 lines
Quoted 2 lines
errno == EPERM? A bit weird. Try strace'ing both your program and the cat tool to look for a difference.
strace says "-1" in this case is ENOBUFS
The failure in my programm is that it writes binary data to a pipe with
rt_pipe_write(preserves message boundary) and normal linux process wants to read it byte by byte withread(). Read wants to receive the whole message, but the message is bigger than 1 byte, so it returns ENOBUFS.
Yep. Well, I agree that this is clearly not the best designed part of the entire interface...
Quoted 2 lines
The solution is to use
rt_pipe_stream(don't preserves message boundary). Do I have to usert_pipe_allocbefore?
No, rt_pipe_stream() manages an internal buffer to convey the byte stream, and deals with the rt_pipe_alloc/free interface on its own. You just need to pass it the raw data buffer and size.
Quoted 12 lines
Is there a small
sample program somewhere?Thanks,
Marco_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.