From: "Ignacio García Pérez" <iggarpe@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] pipe fun
Date: Mon, 21 Nov 2005 11:11:52 +0100 [thread overview]
Message-ID: <43819D68.4000800@domain.hid> (raw)
Hi,
This has to be something really simple but I'm hitting a wall. I have a
rt module that creates a pipe and periodically writes some data to it.
In the following program, the read fails with "No space left on device":
int main (void) {
int r, fd; u_char c;
fd = open("/proc/xenomai/registry/pipes/rt2event", O_RDWR);
if (fd < 0) {
fprintf(stderr, "ERROR opening pipe: %s\n", strerror(errno));
return -1;
}
for (;;) {
r = read(fd, &c, sizeof(c));
if (r == 0) { fprintf(stderr, "ERROR reading (returned 0)\n");
break; }
if (r < 0) { fprintf(stderr, "ERROR reading: %s\n",
strerror(errno)); break; }
fprintf(stderr, "%02hX ", c);
}
close(fd);
return 0;
}
However, the following program works fine!!!
int main (void) {
int r; u_char c;
FILE *f;
f = fopen("/proc/xenomai/registry/pipes/rt2event", "r+b");
if (f == NULL) {
fprintf(stderr, "ERROR opening pipe: %s\n", strerror(errno));
return -1;
}
for (;;) {
r = fread(&c, sizeof(c), 1, f);
if (r == 0) { fprintf(stderr, "ERROR reading (returned 0)\n");
break; }
if (r < 0) { fprintf(stderr, "ERROR reading: %s\n",
strerror(errno)); break; }
fprintf(stderr, "%02hX ", c);
}
fclose(f);
return 0;
}
Any clues?
By the way, I noticed a "cat /proc/xenomai/registry/pipes/rt2event |
xxd" won't work, perhaps due to the same reason?
next reply other threads:[~2005-11-21 10:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-21 10:11 Ignacio García Pérez [this message]
2005-11-21 10:44 ` [Xenomai-help] pipe fun Dmitry Adamushko
2005-11-21 11:24 ` Ignacio García Pérez
2005-11-21 12:11 ` Dmitry Adamushko
2005-11-21 12:36 ` Philippe Gerum
2005-11-21 12:55 ` Dmitry Adamushko
2005-11-21 18:28 ` Philippe Gerum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43819D68.4000800@domain.hid \
--to=iggarpe@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.