Skip to main content
Visitor II
July 15, 2023
Question

TCP Server receives proper data but shows incorrect received data length in STM32F439

  • July 15, 2023
  • 2 replies
  • 1261 views

Hi, I am using STM32F439 as TCP Server with LWIP TCPecho example. 

I am properly receiving data of any length from TCP Client, and I am also able to send back the received data to TCP Client without any issues. However, if the received data length is more than 536 bits, the data length pointer will always indicate 536 as the length received.

Data Pointer: es-> p-> payload

Data Length Pointer: es-> p-> len

I am not able to get to the problem as why this is happening and I need the accurate length to send the data to other microcontroller via SPI.

It will of a great help if anyone could help me to solve this problem.

I am also attaching my tcpserverecho.c file for the reference.

Thank You.

This topic has been closed for replies.

2 replies

RhSilicon
Lead
July 15, 2023

I'm not sure if this solves your problem, but check if it helps:

Generally, the packet size gets restricted by the Maximum Transmission Unit (MTU) of network resources. MTU is the maximum size of the data transfer limit set by hardware in a network. The packet size should never exceed MTU

https://www.baeldung.com/cs/tcp-max-packet-size

LCE
Principal II
July 17, 2023

I think 536 is the default MTU for lwIP, which you can increase in the lwip_opt.h file up to 1500.

Further, make sure that your RX buffers are big enough.