All,

trying to write a simple producer / consumer using message pipes in
the native API, this phrase from the documentation (found here [1])
confuses me:

"-EPIPE is returned if the associated special device is not yet open."

It's not so much the sentence itself, but more the fact that I'm not
getting that return value from rt_pipe_stream() when streaming bytes
to a RT_PIPE that hasn't had its "special device" opened in secondary
domain.

I've attached a modified trivial-periodic.c that demonstrates what I'm
seeing. Afaik there is nothing open(2)-ing the /dev/rtp9 in the
secondary domain. All writes succeed, up to about write 31 (*1024),
after which all writes return 0.

[..]
wrote: 1024, res: 1024
wrote: 1024, res: 948
wrote: 1024, res: 0
wrote: 1024, res: 0
[..]

Is the documentation incorrect, or am I misunderstanding something?

Related info:
  Xenomai: 2.5.5.2
  Kernel: 2.6.32.26

[1] 
http://www.xenomai.org/documentation/trunk/html/api/group__pipe.html#gb4d85ecda7675a75611500070c28b22e
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/pipe.h>
#include <rtdk.h>


RT_TASK demo_task;


void demo(void *arg)
{
	rt_task_set_periodic(NULL, TM_NOW, 5e8);

	RT_PIPE pipe;
	int res = rt_pipe_create(&pipe, "some_name", 9, 0);
	if(res < 0)
	{
		rt_printf(strerror(-res));
		return;
	}

	const unsigned int bsize = 1024;
	unsigned char buf[bsize];

	while(1)
	{
		rt_task_wait_period(NULL);

		res = rt_pipe_stream(&pipe, &buf, bsize);
		rt_printf("wrote: %u, res: %d\n", bsize, res);

		rt_task_sleep(1e8);
	}
}

void catch_signal(int sig)
{
}

int main(int argc, char* argv[])
{
	signal(SIGTERM, catch_signal);
	signal(SIGINT, catch_signal);

	mlockall(MCL_CURRENT|MCL_FUTURE);

	rt_print_auto_init(1);
	rt_task_create(&demo_task, "trivial", 0, 99, 0);
	rt_task_start(&demo_task, &demo, NULL);

	pause();

	rt_task_delete(&demo_task);

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

Reply via email to