rtf_create_handler again

Jose Antonio Sanchez getaceres at yahoo.es
Tue Oct 12 13:52:17 CEST 2004


Thanks. I didn't know that. I'm using fifos because my
application isn't entirely based on RTAI and it has a
GUI. The only way I've found to comunicate RTAI with a
GUI (GTK+ or QT) it's through a FIFO and a handler on
the GUI part. I'm not using Mailboxes because there's
no handler to receive data so it's not usable from Gtk
or Qt which are based entirely on events.
My personal opinion is that it's not a good idea to
throw away FIFOS from RTAI since they are a good way
to comunicate Real Time processes with GUI processes
that needs events to react or add handlers to
mailboxes so they are usable from event programs like
a GUI is.
I'm not using a module because I'm on an early stage
of development and it bothers me to reboot every time
my real time process crashes, so I have it on user
space most of time and I only have in kernel space
(through rt_make_hard_real_time()) a small piece that
really needs that kind of determinism. I think it's a
safer way to develop an application, so having in user
space the same facilities than in kernel modules, it's
a great help.
Should I try fusion to have this? I've read it's
entirely based on lxrt and xenomai so there's no need
to have kernel modules.
 --- Paolo Mantegazza <mantegazza at aero.polimi.it>
escribió: 
> Jose Antonio Sanchez wrote:
> >  --- Paolo Mantegazza <mantegazza at aero.polimi.it>
> > escribió: 
> > 
> >>Jose Antonio Sanchez wrote:
> >>
> >>>Sorry to insist, but I don't know what to do. I
> >>
> >>don't
> >>
> >>>know if I'm not getting response because nobody
> >>
> >>knows
> >>
> >>>how to solve it or because it's so easy to solve
> >>
> >>that
> >>
> >>>it's a waste of time to answer a newbie this
> >>>questions, but I can't do anything to solve it.
> >>>I'm getting an unresolved symbol on compile time
> >>>everytime I call rtf_create_handler on rtai 3.1
> >>
> >>I've
> >>
> >>>compiled it with the three inline modes, and it's
> >>
> >>the
> >>
> >>>same on everyone of them. I've looked
> rtai_fifos.h
> >>
> >>and
> >>
> >>>rtai_fifos.c and that function it's there. Maybe
> >>
> >>I'm
> >>
> >>>passing the handler the wrong way? What is the
> >>
> >>correct
> >>
> >>>way to do that? What is the right prototype for a
> >>>handler? Could it be that I'm using it with lxrt
> >>>instead of a module?
> >>>I'm lost. I don't know what's the problem. I
> don't
> >>>know if it's a bug of RTAI or not. Please, if
> >>
> >>somebody
> >>
> >>>knows anything, if someone has used it anytime,
> >>
> >>could
> >>
> >>>you please tell me how did you do it? how your
> >>>makefile was? what handler prototype did you use?
> >>>Thanks.
> >>>
> >>
> >>A further comment.
> >>
> >>I suspect that your problem might be due to the
> way
> >>you compile modules 
> >>with Linux 2.6.7. If that is the case you should
> >>study a bit one of the 
> >>making way for the examples found in
> >>showroom/v3.x/kern.
> >>
> >>I've just compiled an old examples found in the
> >>24.1.x series and it has 
> >>no problem with the fifo handler.
> >>
> >>Paolo.
> >>
> >> 
> > 
> > 
> > Here it goes:
> > /* function definitions */
> > #define PERIOD 10000000
> > #define FIFO_ENTRADA 1
> > 
> > void *get_data(void *data);
> > int *handler(unsigned int fifo, int rw);
> > ...............................
> > /* main task creation */
> > int main (int argc, char **argv) {
> >    mlockall(MCL_CURRENT | MCL_FUTURE);
> >    main_t =
> >
>
rt_task_init_schmod(nam2num("MAIN"),10,0,0,SCHED_FIFO,0);
> > ..............................
> > /* Create receive fifo */
> >    tam_o = sizeof(order);
> >    if ((err=rtf_create(1,tam_o)) != 0) {
> >       printf("Hubo un error creando fifo, err =
> > %d\n",err);
> >       if (err == ENODEV) {
> >       printf("No such device\n");
> >       }
> >       else {
> >          if (err == ENOMEM) {
> >          printf("Could not allocate FIFO
> memory\n");
> >          }
> >       }
> >       rtf_destroy(0);
> >       rtf_destroy(1);
> >       stop_rt_timer();
> >       rt_task_delete(mytask);
> >       exit(0);
> >    }
> > .....................................
> > /* Handler creation (in main) */
> > rtf_create_handler(FIFO_ENTRADA,handler);
> > .....................................
> > /* Handler function (out of main)*/
> > int *handler(unsigned int fifo, int rw) {
> >    order msg;
> >    int *res;   
> >    if (rtf_get(1,&msg,sizeof(msg)) == sizeof(msg))
> {
> >       A = msg.A;
> >       w = msg.w;
> >       B = msg.B;
> >       return 0;
> >    }
> >    else {
> >       printf("Error desconocido\n");
> >       return -1;
> >    }
> >    return res;
> > }
> > .............................................
> > 
> > As I said, I'm using lxrt, so i've not compiled it
> as
> > a module. Maybe it's a problem of mine and I can't
> use
> > rtf_create_handler in a lxrt task.
> > 
> > This is the makefile I'm using:
> > 
> > prefix := $(shell rtai-config --prefix)
> > 
> > ifeq ($(prefix),)
> > $(error Please add <rtai-install>/bin to your PATH
> > variable)
> > endif
> > 
> > CC = $(shell rtai-config --cc)
> > LXRT_CFLAGS = $(shell rtai-config --lxrt-cflags)
> > LXRT_LDFLAGS = $(shell rtai-config --lxrt-ldflags)
> > 
> > all: test
> > 
> > test: test.c
> > 	$(CC) $(LXRT_CFLAGS) -o $@ $< $(LXRT_LDFLAGS) -lm
> 
> > 
> > clean:
> > 	rm -f *.o test
> > 
> > .PHONY: clean
> > 
> > This is the ouput when trying to compile my
> program:
> > 
> > gcc -I. -I/usr/realtime-noin/include -g
> > -I/usr/src/kernel-source-2.6.7/include -Wall
> > -Wstrict-prototypes -pipe -o test test.c
> > -L/usr/realtime-noin/lib -llxrt -lpthread -lm
> > test.c: En la función `main':
> > test.c:126: aviso: implicit declaration of
> function
> > `rtf_create_handler'
> > test.c: En la función `handler':
> > test.c:221: aviso: return se crea un puntero desde
> un
> > entero sin una conversión
> > /tmp/ccQT1q4d.o(.text+0x271): En la función
> `main':
> > /home/jose/curro/poco a poco/threads/test.c:126:
> > undefined reference to `rtf_create_handler'
> > collect2: ld devolvió el estado de salida 1
> > make: *** [test] Error 1
> > 
> > The strange thing it's that I'm using rtf_get and
> > rtf_create and none of them gives me this error,
> only
> > rtf_create_handler.
> > 
> 
> The problem is that you cannot create a handler in
> user space. It could 
> be done, e.g. following the scheme found in serial,
> but I will not do 
> it. The reason is simple FIFOS are in RTAI for
> legacy support and not 
> 
=== message truncated === 


		
______________________________________________
Renovamos el Correo Yahoo!: ¡100 MB GRATIS!
Nuevos servicios, más seguridad
http://correo.yahoo.es




More information about the Rtai mailing list