/* Releases a Modbus client channel object, previously created with  */
void TbxMbClientFree(tTbxMbClient channel)
/* Releases a Modbus client channel object, previously created with  */
void TbxMbClientFree(tTbxMbClient channel)
{
  TBX_ASSERT(channel != NULL);
  if (channel != NULL)
  {
    tTbxMbClientCtx * clientCtx = (tTbxMbClientCtx *)channel;
    TBX_ASSERT(clientCtx->type == TBX_MB_CLIENT_CONTEXT_TYPE);
    TbxMbOsalSemFree(clientCtx->transceiveSem);
    TbxCriticalSectionEnter();
    clientCtx->tpCtx->channelCtx = NULL;
    clientCtx->tpCtx = NULL;
    clientCtx->type = 0U;
    clientCtx->pollFcn = NULL;
    clientCtx->processFcn = NULL;
    clientCtx->transceiveSem = NULL;
    TbxCriticalSectionExit();
    TbxMemPoolRelease(clientCtx);
  }
}