Ren Yuhong wrote:

> Dear All,
>
> I am combining Qt & RT Linux to develpe a simple motor controller. I use
> Qt to design a GUI, since I need to use RT FIFO for communication
> between Qt's GUI and the real time kernel module, I need to handle the
> RT FIFO within GUI, following is my codes:
>
> ---------------------------------------------
> /********************
>  Constructor
>  NB: "TEST" is a dialog
> *********************/
> TestImpl::TestImpl( QWidget* parent,const char* name, bool modal, WFlags
> f) :  TEST( parent, name, modal,f)
> {
>
>      // Try to connect with RT task via FIFO
>      fd1 = open("/dev/rtf1", O_RDWR);
>      if ( fd1 == -1 )
>      {
>       printf("Can not open /dev/rtf1\n");
>       close(fd1);
>       //return -1;
>      }
>
>     fd2 = open("/dev/rtf2", O_RDWR);  //RDWR
>      if ( fd2 == -1 )
>      {
>       printf("Can not open /dev/rtf2\n");
>       close(fd2);
>       //return -1;
>      }
> }
>
> ------------------------------------------------
> /***********
>  Destructor
>  ***********/
> TestImpl:: ~TestImpl()
> {
> close(fd1);
> close(fd2);
> }
> -----------------------------------------------
>
> With the above constructor and destructor, it is Ok to open the dialog
> class only ONCE within my GUI.  If I open it for the second time, the
> error message comes out as follows:
> --------------
> QGArray: Cannot allocate array with negative length
> Segmentation fault (core dumped)
> --------------
>
> I am wondering if the RT FIFOs have really been closed or not. I used
> RHIDE to debug it, and found that the codes went through "close(fd1);
> close(fd2);".
>

Why do you suspect the FIFO's when you're error message is complaining
about QGArray code? Have you tried gdb to see where the seg fault occurs?

--Gordon


-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to