Solved

Members variables are destroyed when outof scope

Posted on 2002-03-24
5
220 Views
Last Modified: 2013-11-20
Whenever some data was received into Gryphon, the OnRx() function got triggered.
In OnRx() the CTestappDlg member function ReceiveData() is called.
In ReceivedData(), the pointer ‘mygryphon’ (dgGryphon * mygryphon) becomes null.
As an alternative, declared the pointer (mygryphon ) as global and tried accessing
the member functions. Even doing so did not help.

Please suggest.

//Connect to the Gryphon
void CTestappDlg::OnGryconnect()          //Connecting to the Gryphon.....
{
     
     bool result = m_mygryphon->BeginSession( (dgString) m_ip1 );
     if(!result)
     {
          m_mygryphon->GetLastOpStatus( &m_errnum, &m_errstr );
          m_text.Format( "BeginSession()...Error: %s", m_errstr.c_str() );
                     m_output.AddString(m_text);
          return;
     }
     else
                  m_output.AddString("BeginSession()...OK");

     if(!SetOnRx(OnRx, FT_DATA, 0))
     {
          m_text.Format("SetOnRx()... Error:%s", m_errstr.c_str());
          m_output.AddString(m_text);
     }
}

void OnRx()
{
     CTestappDlg::ReceiveData();
}

void CTestappDlg::ReceiveData()
{
     if( !m_mygryphon->RecvFrame( &dataframe, my_channel[i] ) )
     {
          m_mygryphon->GetLastOpStatus( &m_errnum, &m_errstr );
          m_text.Format( "RecvFrame()... Error: %s", m_errstr.c_str() );
                  m_output.AddString(m_text);
          return;
     }
     else
     m_output.AddString( "RecvFrame()... OK" );
}

Thank you !
0
Comment
Question by:l_angelo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:l_angelo
ID: 6892288
Its urgent !
0
 
LVL 23

Expert Comment

by:chensu
ID: 6892385
Set a data breakpoint when m_mygryphon is equal to 0.
0
 
LVL 8

Accepted Solution

by:
VinExpert earned 75 total points
ID: 6893248
Hi angelo,

I need to know some details of what u r doing so that I can give u the solution.

1. What version of Gryphon library u r using?
2. Who is calling ur OnRx() function?
3. Have U written any embedded client application to do that?
4. Just have a peristant dialog pointer to ur main dialog, say in app class and try accessing the ReceiveData function using that pointer. i,e.., in app's .h file declare CTestappDlg *m_pDlg; Then in OnInitDialog,
CTestappDlg *pApp = (CTestappDlg *)AfxgetApp();
pApp->m_pDlg = this;
Then in ur OnRx function

void OnRx()
{
CTestappDlg *pApp = (CTestappDlg *)AfxgetApp();
pApp->m_pDlg->ReceiveData();
}

Then try it.

If possible u can send me that sample to k_bbb100@hotmail.com. I have the Gryphon and relevant software with me, so that I can debug it for U.

Try it out.
VinExpert
0
 

Expert Comment

by:lil_elvis2000
ID: 6894710
Use the debugger and break when value of m_mygryphon changes as is being suggested.

This can be done after debugger starts..at location where m_mygryphon is created..set a breakpoint, step over. then in breakpoints dialog (Edit | Breakpoints...) click on data tab and enter m_mygryphon, click okay.

in my experience you need to do it this way. or C++ seems to disable the breakpoint.

good luck.
0
 

Author Comment

by:l_angelo
ID: 6894860
Thanks VinExpert !

Probably this should work for me.....
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question