2024-05-10 08:04 AM - edited 2024-05-10 08:05 AM
I am developing an TCP/IP Server Client application on my NUCLEO-F207ZG development board.I am implementing a function to send ADC values on Ethernet.
void Client_Data_Send(void)
{
char temp_buff[TEMP_BUFF_SIZE];
volatile uint32_t buff_len;
volatile uint16_t Temperature = 0;
struct pbuf *p = NULL;
Temperature = TEMP;
buff_len = sprintf(temp_buff,"DHT11 Sensor value from TCP Client : %u \n\r",Temperature);
/*allocate pbuf from ram*/
p = (pbuf_alloc(PBUF_TRANSPORT,buff_len,PBUF_POOL));
(tcp_client->p)= (p);
if(tcp_client->p != NULL)
{
/*copy the data to send into the allocated pbuf*/
pbuf_take( tcp_client->p ,(char *)temp_buff,buff_len);
/*send data*/
tcp_client_send(tx_pcb, tcp_client);
/*free mem*/
pbuf_free( tcp_client->p);
}
}
Above is the function I implemented.
At line (tcp_client->p)= (p); when I debuged I came to know that values are not getting assinged.
Below are the screen shot.
since wrong values for all members getting assigned I am facing Hard fault issue. Is it structure alignment issue? I am using LwIP library for Tcp/Ip application.
2024-05-23 09:31 AM
Hello @pradeepwagre ,
At first glance this code seems to have some issues and it is not conformed to the guidelines of implementation with LWIP on STM32s.
You can follow this User Manual Developing applications on STM32Cube with LwIP TCP/IP stack
to get more info bout the way to use LwIP tcp/ip stack.
you can check the way to use LwIP either with or without Rtos and take this following example as reference.
You can also implement and example using LwIP without RTOS by following this Application Note (see section 4.1.2) in which we implement a periodic process in While(1) loop.
BR