cancel
Showing results for 
Search instead for 
Did you mean: 

nx_tcp_socket_send Cannot send continuously in while

Hhaon.1
Associate II
 while(1)
  {
    TX_MEMSET(data_buffer, '\0', sizeof(data_buffer));
    
    /* allocate the packet to send over the TCP socket */
    ret = nx_packet_allocate(&AppPool, &data_packet, NX_IPv4_TCP_PACKET, TX_WAIT_FOREVER);
 
    if (ret != NX_SUCCESS)
    {
    	printf("aaaa1\r\n");
      break;
    }
 
    /* append the message to send into the packet */
    ret = nx_packet_data_append(data_packet, (VOID *)data_buffer, sizeof(data_buffer), &AppPool, TX_WAIT_FOREVER);
 
    if (ret != NX_SUCCESS)
    {
    	printf("aaaa2\r\n");
     // nx_packet_release(data_packet);
      break;
    }
 
   
    ret = nx_tcp_socket_send(&TCPSocket, data_packet, 30000 );
 
    if (ret != NX_SUCCESS)
    {
    	printf("tcp send error:%#x\r\n",ret);
        break;
    }
 
  }

hardware:STM32H747I-DISCO

i want send TCP data continuously  in a while ;

but this is a problem; Error message after sending 5 data;errcode is 0x38 ;But I'm sure the Internet is good;

so i check code i find ;

HAL_ETH_Transmit_IT -- > ETH_Prepare_Tx_Descriptors return HAL_ETH_ERROR_BUSY;

if((READ_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCWBF_OWN) == ETH_DMATXNDESCWBF_OWN) || (dmatxdesclist->PacketAddress[descidx] != NULL))
  {
    return HAL_ETH_ERROR_BUSY;
  }

so How to solve this problem?

1 REPLY 1
alister
Lead

>so How to solve this problem?

Increasing your number of tx dma descriptors will help a bit.

If the app sends packets faster than they can be transmitted, your driver needs to push back (block) or drop.

>i want send TCP data continuously in a while ;

It may look like in the app. But TCP guarantees in-order delivery and to do that it waits for an ACK to each segment it's sent and retries etc. The more and the faster you send, the more buffers it needs, and again, like with the DMA descriptors, when those run out, the app can't expect to send more.