Hello.
I have a problem with receiving data in frames over 4096 bytes with the UDP protocol.I use interrupt. I wrote the code in a way that I receive a 16KB data at a time and then send the same data. But there are two points and problems: 1) For every 1024 bytes of sent data at the one message, an interrupt is activated. 2) Only 6000 bytes of data are received without being lost
There is no guarantee of receiving the rest of the frame data.
Although I guess that the data frame is removed from the end.
Anyway I guess it’s a problem RX buffer management.
Also, I only have one socket for UDP and buffer with a buffer size of 16 KB.
Can you tell me what is the problem??
this is my code:
#include “main.h”
#include “stm32f4xx_hal.h”
#include “socket.h”
#include “w5500.h”
#include “wizchip_conf.h”
#include “setup.h”
#include <string.h>
//********************************** UDP LAN Variable *****************************************
uint8_t remote_ip[4]={192,168,1,1};
uint16_t remote_port=5000;
uint16_t SOCK_UDPS=1;
uint16_t local_port=5000;
uint16_t len=0;
uint8_t buffer[16000];
wiz_NetInfo netInfo = {.mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // Mac address
.ip = {192, 168, 1, 2}, // IP address
.sn = {255, 255, 255, 0}, // Subnet mask
.gw = {192, 168, 1, 254}}; // Gateway address
uint8_t bufSize = {16,0,0,0,0,0,0,0};
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
HAL_Delay(100);
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_UART4_Init();
MX_SPI2_Init();
MX_SPI1_Init();
/* Initialize interrupts */
MX_NVIC_Init();
/* USER CODE BEGIN 2 /
__HAL_UART_ENABLE_IT(&huart4,UART_IT_RXNE);
HAL_UART_Receive_IT(&huart4,SX_Recv_Uart,SX1280_Packet_Length);
Init_5500();
/ USER CODE END 2 */
/* Infinite loop /
/ USER CODE BEGIN WHILE */
while (1)
{
}
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin==ETH_INTn_Pin)
{
if((getSn_IR(0)>>2)&getSIR())
{
setSn_IR(0, 0x04);
setSIR(0x01);
}
if((len=getSn_RX_RSR(0))>0)
{
memset(buffer,0,len+1);
len=recvfrom(0,buffer, len, remote_ip,&remote_port);
UDP_send(buffer,len);
}
}
}
void Init_5500(void)
{
// reset WIZNET chip
reset_wiznet();
// setup WIZ550io
reg_wizchip_cs_cbfunc( wiznet_sel, wiznet_desel );
reg_wizchip_spi_cbfunc( wiznet_receive_data, wiznet_send_data );
// wizchip_sw_reset();
wizchip_init(bufSize, bufSize);
wizchip_setnetinfo(&netInfo);
wizchip_getnetinfo(&netInfo);
socket(0,Sn_MR_UDP,local_port,0);
HAL_Delay(100);
UDP_send(“salam”,5);
}