[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Members variables are destroyed when outof scope

Posted on 2002-03-24
5
Medium Priority
?
237 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:
Vinayak Kumbar earned 225 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

831 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