lwip-users
[Top][All Lists]
Advanced

[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 04:43:57 -0700 (PDT)

Yes i am using the arm cortex m3. Did you have such problems ?

Sanchayan wrote:
> 
> Hello,
> 
> Which processor are you using?
> 
> Are you using ARM Cortex M3?
> 
> 
> On 26-06-2012 16:23, shettys wrote:
>> Hello,
>>
>> Could somebody please help me with my problem in setting up a TCP client.
>> The code is as posted below.
>> I call the TCPConnection_start before i go into the main loop, which
>> initializes the connection. Then i call the TCP_send periodically( to
>> send
>> some ADC values).
>> When my server opens a connection on Port 7 and I run my program it works
>> fine and the ADC values are sent. However sometimes it just goes into a
>> hard
>> fault handler. Could someone please let me know where i am wrong?
>>
>> void TCPConnection_start(void)
>> {
>>    struct ip_addr DestIPaddr;
>>   
>>    /* create new tcp pcb */
>>    pcb = tcp_new();
>>    if (pcb != NULL)
>>    {
>>      IP4_ADDR( &DestIPaddr, DEST_IP_ADDR0, DEST_IP_ADDR1, DEST_IP_ADDR2,
>> DEST_IP_ADDR3 );
>>         
>>      /* connect to destination address/port */
>>      tcp_connect(pcb,&DestIPaddr,DEST_PORT,TCPConnection_Established);
>>    }
>> }
>>
>> /**
>>    * @brief Function called when TCP connection established
>>    * @param tpcb: pointer on the connection contol block
>>    * @param err: when connection correctly established err should be
>> ERR_OK
>>    * @retval err_t: returned error
>>    */
>> static err_t TCPConnection_Established(void *arg, struct tcp_pcb *pcb,
>> err_t
>> err)
>> {
>>    if (err == ERR_OK)
>>    {
>>    /* allocate structure es to maintain tcp connection informations */
>>      es = (struct echoclient *)mem_malloc(sizeof(struct echoclient));
>>    
>>      if (es != NULL)
>>      {
>>        es->state = ES_CONNECTED;
>>        es->pcb = pcb;
>>       }
>>     }
>> }
>>
>>
>> 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);
>>        }
>> }
>>
>>    
>> /**
>>    * @brief function used to send data
>>    * @param  tpcb: tcp control block
>>    * @param  es: pointer on structure of type echoclient containing info
>> on
>> data
>>    *             to be sent
>>    * @retval None
>>    */
>> static void TCPData_send(struct tcp_pcb *pcb, struct echoclient * es)
>> {
>>    struct pbuf *ptr;
>>    err_t wr_err = ERR_OK;
>>   
>>    while ((wr_err == ERR_OK) &&
>>           (es->p_tx != NULL) &&
>>           (es->p_tx->len <= tcp_sndbuf(pcb)))
>>    {
>>      
>>      /* get pointer on pbuf from es structure */
>>      ptr = es->p_tx;
>>
>>      /* enqueue data for transmission */
>>      wr_err = tcp_write(pcb, ptr->payload, ptr->len, 1);
>>      
>>      if (wr_err == ERR_OK)
>>      {
>>        /* continue with next pbuf in chain (if any) */
>>        es->p_tx = ptr->next;
>>        
>>        if(es->p_tx != NULL)
>>        {
>>          /* increment reference count for es->p */
>>          pbuf_ref(es->p_tx);
>>        }
>>        
>>        /* free pbuf: will free pbufs up to es->p (because es->p has a
>> reference count > 0) */
>>        pbuf_free(ptr);
>>     }
>>     else if(wr_err == ERR_MEM)
>>     {
>>        /* we are low on memory, try later, defer to poll */
>>       es->p_tx = ptr;
>>     }
>>     else
>>     {
>>      }
>>    }
>> }
> 
> 
> 
> 
> Disclaimer: This message (including any attachments) contains confidential
> information and is intended solely for the use of the individual or entity
> to whom they are addressed. If you are not the intended recipient you are
> notified that disclosing, copying, distributing or taking any action based
> on the contents of this information is strictly prohibited. If you have
> received this email in error please notify address@hidden Please note
> that any views or opinions presented in this email are solely those of the
> author and do not necessarily represent those of Godrej & Boyce Mfg. Co.
> Ltd. group of companies. The recipient should check this email and any
> attachments for the presence of viruses. Godrej & Boyce Mfg. Co. Ltd.
> group of companies accepts no liability for any damage caused by any virus
> transmitted by this email.  
> 
> 
> _______________________________________________
> 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-tp34071696p34071860.html
Sent from the lwip-users mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]