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?

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to