This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TIMAC When to deallocate data request buffer after MAC_BAD_STATE confirmation

Other Parts Discussed in Thread: TIMAC

Hi,

While using and abusing the MAC Sample Application (MSA) that comes with TIMAC, I recently discovered that if a MAC_MCPS_DATA_CNF is received with the status MAC_BAD_STATE then the attempt to deallocate the data request buffer fails.

As far as I can tell, the reason it fails is that the pointer to the data request is null. However, it should point to the one the caller of MAC_Mcps_Data_req() made and passed in, regardless of if the request was sucessful.

Unfortunately the MAC API documentation does not cover the exact set of circumstances that cause this failure (but it's probably because I'm being a bad citizen wrt the MAC layer). Whether or not I am abusing the MAC, I believe there should be a reasonable course of action to recover from a MAC_BAD_STATE status.

My possible solutions are:

1. I can inspect the pData->dataCnf.hdr.status field and only attempt to deallocate if the status is a "valid" one. 

2. I can inspect the pData->dataCnf.pDataReq field and only attempt to deallocate if it is not null.

For both of these options how do I deallocate the buffer that the caller of MAC_Mcps_Data_req() made? Does the MAC Layer do this for me? What if I want to reuse the buffer?

Finally, how many other cases like this are there? Is there any documentation of the proprietary status values (other than listing them), how they are used and how the application code should handle receiving an event with them?

Any help would be greatly appreciated,

Thanks,

Andrew

The part I am talking about is here:

case MAC_MCPS_DATA_CNF:
          pData = (macCbackEvent_t *) pMsg;

          /* If last transmission completed, ready to send the next one */
          if ((pData->dataCnf.hdr.status == MAC_SUCCESS) ||
              (pData->dataCnf.hdr.status == MAC_CHANNEL_ACCESS_FAILURE) ||
              (pData->dataCnf.hdr.status == MAC_NO_ACK))
          {
            osal_start_timerEx(MSA_TaskId, MSA_SEND_EVENT, MSA_WAIT_PERIOD);
          }

          mac_msg_deallocate((uint8**)&pData->dataCnf.pDataReq); <<<< Here the pDataReq is NULL, and the deallocate fails
          break;