/* Interface function to be called by a channel to obtain write access to the transmission packet. Returns NULL is the packet is currently not accessible. Can by called to prepare the transmit packet before calling the transport layer's transmitFcn().  */
static tTbxMbTpPacket * TbxMbRtuGetTxPacket(tTbxMbTp transport)
/* Interface function to be called by a channel to obtain write access to the transmission packet. Returns NULL is the packet is currently not accessible. Can by called to prepare the transmit packet before calling the transport layer's transmitFcn().  */
static tTbxMbTpPacket * TbxMbRtuGetTxPacket(tTbxMbTp transport)
{
  tTbxMbTpPacket * result = NULL;
  TBX_ASSERT(transport != NULL);
  if (transport != NULL)
  {
    tTbxMbTpCtx * tpCtx = (tTbxMbTpCtx *)transport;
    TBX_ASSERT(tpCtx->type == TBX_MB_RTU_CONTEXT_TYPE);
    TbxCriticalSectionEnter();
    uint8_t currentState = tpCtx->state;
    TbxCriticalSectionExit();
    if (currentState != TBX_MB_RTU_STATE_TRANSMISSION)
    {
      result = &tpCtx->txPacket;
    }
  }
  return result;
}