Tool/software:
I would like to do a simple program:
Wake up from a GPIO, emit a packet, go to sleep, and so on.
Based on the example rfPacketTx and rfPacketRx it works.
void SendPacket(void)
{
RCL_init();
rclHandle = RCL_open(&rclClient, &LRF_config);
rclPacketTxCmdGenericTx.rfFrequency = FREQUENCY;
/* Start command as soon as possible */
rclPacketTxCmdGenericTx.common.scheduling = RCL_Schedule_Now;
rclPacketTxCmdGenericTx.common.status = RCL_CommandStatus_Idle;
rclPacketTxCmdGenericTx.config.fsOff = FS_OFF; // Turn off FS
/* Callback triggers on last command done */
rclPacketTxCmdGenericTx.common.runtime.callback = defaultCallback;
rclPacketTxCmdGenericTx.common.runtime.rclCallbackMask.value = RCL_EventLastCmdDone.value;
/* Set RCL TX buffer packet to be packet buffer */
txPacket = (RCL_Buffer_TxBuffer *)&packet;
// Create packet with random payload
uint8_t *txData;
txData = RCL_TxBuffer_init(txPacket, NUM_PAD_BYTES, HDR_LEN, MAX_LENGTH);
// Zero out data in header before the length field
for (int s = 0; s < LEN_INDEX; s++)
{
txData[s] = 0U;
}
// Set the packet length
txData[LEN_INDEX] = MAX_LENGTH;
// Generate a random payload
for (int i = HDR_LEN; i < MAX_LENGTH; i++)
{
txData[i] = rand();
}
// Set packet to transmit
RCL_TxBuffer_put(&rclPacketTxCmdGenericTx.txBuffers, txPacket);
rclPacketTxCmdGenericTx.common.status = RCL_CommandStatus_Idle;
// Submit command
RCL_Command_submit(rclHandle, &rclPacketTxCmdGenericTx);
//Pend on command completion
RCL_Command_pend(&rclPacketTxCmdGenericTx);
while(!gCmdDone)
{};
gCmdDone = 0;
RCL_close(rclHandle);
}
Now I would like to separate the program into two parts:
The following function is run once at the beginning of the program:
void Init(void)
{
RCL_init();
rclHandle = RCL_open(&rclClient, &LRF_config);
rclPacketTxCmdGenericTx.rfFrequency = FREQUENCY;
// Start command as soon as possible
rclPacketTxCmdGenericTx.common.scheduling = RCL_Schedule_Now;
rclPacketTxCmdGenericTx.common.status = RCL_CommandStatus_Idle;
rclPacketTxCmdGenericTx.config.fsOff = FS_OFF; // Turn off FS
// Callback triggers on last command done
rclPacketTxCmdGenericTx.common.runtime.callback = defaultCallback;
rclPacketTxCmdGenericTx.common.runtime.rclCallbackMask.value = RCL_EventLastCmdDone.value;
// Set RCL TX buffer packet to be packet buffer
txPacket = (RCL_Buffer_TxBuffer *)&packet;
}
The following function is run at every wake-up by the GPIO:
void SendPacket(void)
{
// Create packet with random payload
uint8_t *txData;
txData = RCL_TxBuffer_init(txPacket, NUM_PAD_BYTES, HDR_LEN, MAX_LENGTH);
// Zero out data in header before the length field
for (int s = 0; s < LEN_INDEX; s++)
{
txData[s] = 0U;
}
// Set the packet length
txData[LEN_INDEX] = MAX_LENGTH;
// Generate a random payload
for (int i = HDR_LEN; i < MAX_LENGTH; i++)
{
txData[i] = rand();
}
// Set packet to transmit
RCL_TxBuffer_put(&rclPacketTxCmdGenericTx.txBuffers, txPacket);
rclPacketTxCmdGenericTx.common.status = RCL_CommandStatus_Idle;
// Submit command
RCL_Command_submit(rclHandle, &rclPacketTxCmdGenericTx);
//Pend on command completion
RCL_Command_pend(&rclPacketTxCmdGenericTx);
while(!gCmdDone)
{};
gCmdDone = 0;
}
The program seems to run, but it doesn't work. The packet is never received.
Is it mandatory to make an initialization of the RCL each time the processor is woke-up from sleep to emit a new packet?
Regards,
Laurent