All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Fwd: can't use message pipe - Cannot allocate memory
@ 2007-06-07 15:49 NZG
  2007-06-07 17:03 ` Philippe Gerum
  0 siblings, 1 reply; 12+ messages in thread
From: NZG @ 2007-06-07 15:49 UTC (permalink / raw)
  To: xenomai

I'm trying to pass a message from user space to Xenomai and it doesn't seem
 to be working. I keep getting an error when attempting to write to the pipe
 in user space.

rt_pipe_write error

: Cannot allocate memory

This happens whether I use posix calls or real time calls.

If I change the poolsize to 0 for allocation from the heap, writes no longer
error out but the data is not received in real time space.

Does this work for anyone else? Anyone have any ideas I could try?

thx,
NZG

code specifics follow...................................................

3 differen POOLSIZE attempts
**************************************************
#define KOMMANDBUFFER 100
//#define POOLSIZE_CONTROL (sizeof(kommand_t)*KOMMANDBUFFER)
//#define POOLSIZE_CONTROL 0
#define POOLSIZE_CONTROL	1024




real-time thread
***********************************
if((err=rt_pipe_create (p, name, P_MINOR_AUTO, POOLSIZE_CONTROL))!=0){
	error(0,-err, "could not create rt pipe");
	return err;
}

/**
 * retrieve a message from the message buffer
 * and updates the kommand structure passed to it.
 * @returns the type of command retrieved.
 *
 */
static inline int getkommand(kommand_t *k){
int err;
  err = rt_pipe_read(&command_pipe,k,sizeof(kommand_t),TM_NONBLOCK);
  if(err<0)error(0,-err, "rt_pipe_read error\n");
  return k->type;//return the type of message
}

while(getkommand(&kommand)!=KILLCYCLE);

user space using real time calls
***********************************
 err=rt_pipe_write(&command_pipe, &k,sizeof(kommand_t),P_NORMAL);
	if(err<0)error(0,-err, "rt_pipe_write error\n");

alternateuser space using posix calls
***********************************
	    int cfd = open(COMMANDPIPE, O_RDWR);

	   if(cfd<0){
	   	printf("can't open %s (%s)\n",COMMANDPIPE, strerror(-cfd));
	   	fflush(stdout);
	   	return;
	   }

       err=write(cfd,&k,sizeof(kommand_t));

       if(err==0)printf("couldn't write to %s\n",COMMANDPIPE);

       if(err<0)printf("err writing to %s (%s)\n",COMMANDPIPE,
strerror(errno));

       if(close(cfd)<0)printf("couldn't close %s\n",COMMANDPIPE

-------------------------------------------------------


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-06-08  6:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-07 15:49 [Xenomai-help] Fwd: can't use message pipe - Cannot allocate memory NZG
2007-06-07 17:03 ` Philippe Gerum
2007-06-07 17:19   ` Philippe Gerum
2007-06-07 18:11     ` NZG
2007-06-07 18:22       ` Jan Kiszka
2007-06-07 18:37         ` NZG
2007-06-07 19:27           ` Jan Kiszka
2007-06-07 19:39             ` NZG
2007-06-07 20:15             ` Philippe Gerum
2007-06-07 22:29             ` Philippe Gerum
2007-06-07 22:47               ` Jan Kiszka
2007-06-08  6:55                 ` [Xenomai-core] " Philippe Gerum

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.