Solved

Members variables are destroyed when outof scope

Posted on 2002-03-24
5
213 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now