Solved

Members variables are destroyed when outof scope

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

10 Experts available now in Live!

Get 1:1 Help Now