?
Solved

Members variables are destroyed when outof scope

Posted on 2002-03-24
5
Medium Priority
?
228 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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