Tool/software: Code Composer Studio
simplelink_cc13x2_26x2_sdk_4_30_00_54
I have a problem while executing the OsalPort_msgDeallocate (pMsg->pBuf) function in NPITask_sendBufToStack ().
Exception often occurs due to an invalid address. In the debugger, I actually see a novalid address when executing OsalPort_MSG_ID (pMsg) (OsalPort_msgDeallocate () function).
I am confused about the order of freeing memory:
OsalPort_free (pMsg);
OsalPort_msgDeallocate (pMsg-> pBuf);
Isn't this a mistake?
static uint8_t NPITask_sendBufToStack( NPIMSG_msg_t *pMsg )
{
uint8_t msgStatus = 0;
mtOSALSerialData_t *pOsalMsg;
uint8 *pReq = (uint8 *)pMsg->pBuf;
/* Allocate memory for the MT message */
pOsalMsg = (mtOSALSerialData_t *)OsalPort_msgAllocate( sizeof ( mtOSALSerialData_t ) );
if (pOsalMsg)
{
/* Fill up what we can */
pOsalMsg->hdr.event = CMD_SERIAL_MSG;
pOsalMsg->msg = OsalPort_malloc( MT_RPC_FRAME_HDR_SZ + pReq[MT_RPC_POS_LEN] );
if(pOsalMsg->msg) {
memcpy(pOsalMsg->msg, pReq, (MT_RPC_FRAME_HDR_SZ + pReq[MT_RPC_POS_LEN]) );
msgStatus = OsalPort_msgSend( MTServiceTaskID, (byte *)pOsalMsg );
}
}
OsalPort_free(pMsg);
OsalPort_msgDeallocate(pMsg->pBuf);
return (msgStatus);
}