Hi,
I don't call exec() from my run method, here it is :
void CanRead::run()
{
m_nCount = 0;
unsigned long nMsgAmount = 2;
CANDATA can[MAX];
while( true )
{
#ifdef __CANON_
unsigned long numMsgs = 0;
PASSTHRU_MSG *pRxMsg = NULL;
pRxMsg = theApp->GetMessageDetail( &numMsgs, 0 );
nMsgAmount = numMsgs; // store amount of messages we got
int index = 0;
// Read can data, store in buffer ( read say N amount and then emit? )
while ( numMsgs )
{
unsigned int iCanId = 0;
for ( int iLoop = 0; iLoop < 4; iLoop++)
{
iCanId = (iCanId << 8 ) | pRxMsg->Data[iLoop];
}
if( pRxMsg->RxStatus & 0x100 )
can[index].strId.sprintf( "%X X", iCanId);
else
can[index].strId.sprintf( "%03X", iCanId);
for ( int iLoop = 4; (unsigned)iLoop < (pRxMsg->DataSize ); iLoop++)
{
szTemp.sprintf("%02X ", pRxMsg->Data[iLoop]);
can[index].strData += szTemp;
}
can[index].strTime.sprintf("%04d", pRxMsg->Timestamp);
numMsgs--;
m_nCount++;
} // end while ( ulNoMsgs )
#else // some dummy data for testing table view
can[0].strId = "0xfea";
can[0].strData = "222222222222";
can[0].strTime = "----";
can[1].strId = "0xfea";
can[1].strData = "111111111111";
can[1].strTime = "----";
m_nCount += nMsgAmount;
#endif
// send out signal
if( nMsgAmount > 0 )
emit scrolltable( m_nCount - 2, nMsgAmount, &can[0] );
msleep(1);
} // end while ( true )
}
void CanRead::run()
{
m_nCount = 0;
unsigned long nMsgAmount = 2;
CANDATA can[MAX];
QString szTemp;
while( true )
{
#ifdef __CANON_
unsigned long numMsgs = 0;
PASSTHRU_MSG *pRxMsg = NULL;
pRxMsg = theApp->GetMessageDetail( &numMsgs, 0 );
nMsgAmount = numMsgs; // store amount of messages we got
int index = 0;
// Read can data, store in buffer ( read say N amount and then emit? )
while ( numMsgs )
{
unsigned int iCanId = 0;
for ( int iLoop = 0; iLoop < 4; iLoop++)
{
iCanId = (iCanId << 8 ) | pRxMsg->Data[iLoop];
}
if( pRxMsg->RxStatus & 0x100 )
can[index].strId.sprintf( "%X X", iCanId);
else
can[index].strId.sprintf( "%03X", iCanId);
for ( int iLoop = 4; (unsigned)iLoop < (pRxMsg->DataSize ); iLoop++)
{
szTemp.sprintf("%02X ", pRxMsg->Data[iLoop]);
can[index].strData += szTemp;
}
can[index].strTime.sprintf("%04d", pRxMsg->Timestamp);
numMsgs--;
m_nCount++;
} // end while ( ulNoMsgs )
#else // some dummy data for testing table view
can[0].strId = "0xfea";
can[0].strData = "222222222222";
can[0].strTime = "----";
can[1].strId = "0xfea";
can[1].strData = "111111111111";
can[1].strTime = "----";
m_nCount += nMsgAmount;
#endif
// send out signal
if( nMsgAmount > 0 )
emit scrolltable( m_nCount - 2, nMsgAmount, &can[0] );
msleep(1);
} // end while ( true )
}
To copy to clipboard, switch view to plain text mode
Regards,
Steve
Bookmarks