 |
The StateWizard Question is more important than the answer. (Plato)
|
| View previous topic :: View next topic |
| Author |
Message |
minghua_yao
Joined: 24 Jun 2009 Posts: 2
|
Posted: Wed Jun 24, 2009 9:20 am Post subject: Engine Event Handling |
|
|
I have the following state machine application. When receives data from bus, create an event and then post to state machine application thread.
base thread: // Create an exteranl event and post it to state machine application
void msgSend(GValueArray* payload)
{
XPostThreadExtPtrEvent(&handler, MSGID, (void*)payload, sizeof(payload), NULL,0,SME_EVENT_CAT_OTHER);
{
guint service;
guint8 addr[BTMGR_BT_ADDR_LEN];
decode_gValueArray_uay(GValueArray* payload, guint* u, guint8* ay, size_t size)
}
}
destination thread:// Receive the event and handle it.
int OnBTapp_appmode_idleINT_CONNECTION_IND(SME_OBJ_T *pObj, SME_EVENT_T *pEvent)
{
guint service;
guint8 addr[BTMGR_BT_ADDR_LEN];
decode_gValueArray_uay((GValueArray*)(pEvent->Data.Ptr.pData), &service, addr, BTMGR_BT_ADDR_LEN);
}
For my gcc compiler, the error prompt: Segementation fault _________________ Minghua.Yao
Continental AG |
|
| Back to top |
|
 |
StateW_Info
Joined: 22 Jan 2007 Posts: 57
|
Posted: Wed Jun 24, 2009 9:39 am Post subject: Engine Event Handling |
|
|
There is an error in your code.
XPostThreadExtPtrEvent(&handler, MSGID, (void*)payload, sizeof(payload), NULL,0,SME_EVENT_CAT_OTHER);
==>
XPostThreadExtPtrEvent(&handler, MSGID, (void*)payload, sizeof(GValueArray), NULL,0,SME_EVENT_CAT_OTHER);
sizeof(payload) is always 4. Use sizeof(GValueArray) instead.
///////////////////////////////////////////////////////////////////
| Code: |
int XPostThreadExtPtrEvent(SME_THREAD_CONTEXT_T* pDestThreadContext, int nMsgID, void *pData, int nDataSize,
SME_OBJ_T *pDestObj, unsigned long nSequenceNum,unsigned char nCategory)
{
X_EXT_MSG_T Msg;
X_EXT_MSG_POOL_T *pMsgPool;
if (nMsgID==0 || pDestThreadContext==NULL || NULL==pDestThreadContext->pExtEventPool)
return -1;
Msg.nMsgID = nMsgID;
Msg.pDestObj = pDestObj;
Msg.pDestThread = pDestThreadContext;
Msg.nSequenceNum = nSequenceNum;
Msg.nCategory = nCategory;
Msg.nDataFormat = SME_EVENT_DATA_FORMAT_PTR;
if (pData!=NULL && nDataSize>0)
{
#if SME_CPP
Msg.Data.Ptr.pData = new char[nDataSize];
#else
Msg.Data.Ptr.pData = malloc(nDataSize);
#endif
memcpy(Msg.Data.Ptr.pData, pData, nDataSize);
Msg.Data.Ptr.nSize = nDataSize;
} else
{
Msg.Data.Ptr.pData = NULL;
Msg.Data.Ptr.nSize = 0;
}
pMsgPool = (X_EXT_MSG_POOL_T *)(pDestThreadContext->pExtEventPool);
XSignalEvent(&(pMsgPool->EventToThread),&(pMsgPool->MutexForPool),(XTHREAD_SAFE_ACTION_T)XAppendMsgToBuf,&Msg);
return 0;
}
|
/////////////////////////////////////////////////////////////////// _________________ StateWizard Tech Support
Question is more important than the answer. (Plato) |
|
| Back to top |
|
 |
minghua_yao
Joined: 24 Jun 2009 Posts: 2
|
Posted: Wed Jun 24, 2009 9:45 am Post subject: Engine Event Handling |
|
|
Both sizeof(payload) and sizeof(GValueArray) i have try, the sizeof(payload) is always 4 as you said, the sizeof(GValueArray) is 0xc. The sending action seems successful. _________________ Minghua.Yao
Continental AG |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|