[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] LWIP client code causes hard fault error
From: |
shettys |
Subject: |
Re: [lwip-users] LWIP client code causes hard fault error |
Date: |
Tue, 26 Jun 2012 06:38:53 -0700 (PDT) |
Thanks for this.
I have not initialized the tcp_arg,tcp_sent & tcp_recv functions since i do
not use them , hence i think that there is no reason to
add this in the code ( tcp_arg(pcbname, NULL); tcp_sent(pcbname, NULL);
tcp_recv(pcbname, NULL);. Please correct me if i am wrong.
Sometimes when i start the server and start the lwip client code(from my arm
cortex development board) it sends the data fine.
When i disconnect the connection and try reconnecting again immediately it
goes to a hard fault. Is it something to do with the timers?Thanks
Funk, Artur wrote:
>
> When does it fails? While the first transfer or after several tries? If
> it fails after several calls of your sending function, the problem could
> be, that you don't free allocated memory or don't close the established
> connection proper. If it fails on first transfer, it could be a pointer
> reason. Your function seems to be incomplete isn't it?
> Here is an example to close the connection after sending
> tcp_arg(pcbname, NULL);
> tcp_sent(pcbname, NULL);
> tcp_recv(pcbname, NULL);
>
> mem_free(data);
> tcp_close(pcbname);
>
> void TCP_send(void)
> {
> uint32_t (*ptr)[3]; // pointer to the ADC_TDstamped_SRAM
> array.
> #ifdef UserButton_InteruptFor_ADCConversion
> sprintf((char*)data, "Potentiometer value is, %d\n",
> ADC3ConvertedValue);
>
> /* allocate pbuf */
> es->p_tx = pbuf_alloc(PBUF_TRANSPORT, strlen((char*)data) ,
> PBUF_POOL);
>
> if (es->p_tx)
> {
>
> /* copy data to pbuf */
> pbuf_take(es->p_tx, (char*)data, strlen((char*)data));
>
> /* send data */
> TCPData_send(pcb,es);
> }
> }
>
> What I can see is:
> uint32_t (*ptr)[3]; <- unused
>
> sprintf((char*)data.... <- where is data dfined?
>
> es->p_tx = pbuf_alloc(PBUF_TRANSPORT, strlen((char*)data) <- are u sure
> the data is always null terminated?
>
>
> Note if you allocate each time new memory space for you data, don't
> forget to free the memory and to set the pointer to NULL.
>
> I hope I can calm u down if I would say that such errors I have had in
> the past were based on my own mistakes and not on LwIP.
>
>
>
> Best regards
>
>
> Artur
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
>
--
View this message in context:
http://old.nabble.com/LWIP-client-code-causes-hard-fault-error-tp34071696p34072399.html
Sent from the lwip-users mailing list archive at Nabble.com.
- [lwip-users] LWIP client code causes hard fault error, shettys, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error, Sanchayan, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error, shettys, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error, shettys, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error, Sanchayan, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error, Funk, Artur, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error,
shettys <=
- Re: [lwip-users] LWIP client code causes hard fault error, Funk, Artur, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error, shettys, 2012/06/26
- Re: [lwip-users] LWIP client code causes hard fault error, shettys, 2012/06/26