EasyLink_transmit函数实现如下:
EasyLink_Status EasyLink_transmit(EasyLink_TxPacket *txPacket)
{
RF_CmdHandle cmdHdl;
uint8_t *pu8Data;
EasyLink_Status status = EasyLink_Status_Tx_Error;
if ( (!configured) || suspended)
{
return EasyLink_Status_Config_Error;
}
if (txPacket->len > EASYLINK_MAX_DATA_LENGTH)
{
return EasyLink_Status_Param_Error;
}
//Check and take the busyMutex
if (Semaphore_pend(busyMutex, 0) == false)
{
return EasyLink_Status_Busy_Error;
}
/* Transmit */
pTransmitDataEntry = (rfc_dataEntryGeneral_t*)txBuffer;
pTransmitDataEntry->length = txPacket->len + NUM_APPENDED_BYTES_TX;
pTransmitDataEntry->status = DATA_ENTRY_PENDING;
pTransmitDataEntry->pNextEntry = (uint8_t*)pTransmitDataEntry; // Circle buffer.
dataTxQueue.pCurrEntry = (uint8_t*)pTransmitDataEntry;
dataTxQueue.pLastEntry = NULL;
/* txPaket copy and send. */
pu8Data = &pTransmitDataEntry->data;
memcpy(pu8Data, &txPacket->payload, txPacket->len);
memcpy(&EasyLink_cmdTx, &RF_cmdTxHS, sizeof(RF_cmdTxHS));
EasyLink_cmdTx.pQueue = &dataTxQueue;
EasyLink_cmdTx.startTrigger.triggerType = TRIG_NOW;
EasyLink_cmdTx.startTrigger.pastTrig = 1;
EasyLink_cmdTx.startTime = 0;
// RF_cmdTxHS.startTime = time;
RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&EasyLink_cmdTx, RF_PriorityHigh, 0, 0);
// cmdHdl = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdTxHS, RF_PriorityNormal, &tx_callback, 0);
/* Wait for Command to complete */
// RF_EventMask result = RF_pendCmd(rfHandle, cmdHdl, EASYLINK_RF_EVENT_MASK);
if (result & RF_EventLastCmdDone)
{
status = EasyLink_Status_Success;
}
//Release the busyMutex
Semaphore_post(busyMutex);
return status;
}
其中,EASYLINK_MAX_DATA_LENGTH为256。
txPacket[0] = 0xCC
txPacket[1] = 0x77,
txPacket[2] = 16的倍数,小于等于250
测试的时候发现,如果txPacket[3-5]同时为0,即txPacket[3] = 0x0, txPacket[4] = 0x0, txPacket[5] = 0x0, EasyLink_transmit会执行失败。
请问,EasyLink_transmit对txPacket数据包有什么样的要求?