• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » safeRTOS + lwip 1.3.2 + lm3s9b96 connection timeout error detection
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS

safeRTOS + lwip 1.3.2 + lm3s9b96 connection timeout error detection

safeRTOS + lwip 1.3.2 + lm3s9b96 connection timeout error detection

This question is not answered
efe
Posted by efe
on Aug 07 2012 13:50 PM
Prodigy120 points

Hi all, 

I am trying to create a project with a reliable tcp connection using the lwip 1.3.2 with safertos. I found some sample code online and updated it a bit to check for additional errors and port utilization however i am having a few issues, has anyone run into something similar and were you able to work around it: 

1) If i deliberately go to an address that doesn't exist (bad IP or server down...) It looks like my hc_error function never gets called. Additionally after I call tcp_connect my hc_poll function is never called either so i am unable to detect the error case and abort the connection. 

2) I have to constantly increment my port number for each connection i create for some reason when hitting the IIS server the original connection is never properly closed even though I am calling tcp_close. ( Please note that i had to switch using to tcp_bind(pcb, IP_ADDR_ANY, 0); instead of specifying a single port number. )

Here is the code i am using to open up a connection: 

int hc_open(struct ip_addr* remoteIP, char *Page, char *PostVars,
void (*returnpage)(u8_t, hc_errormsg, char *, u16_t, void*), void* arg) {
struct tcp_pcb *pcb = NULL;
struct hc_state *state;
static u8_t num = 0;
// local port
//u16_t port = 4545;

// Get a place for a new webclient state in the memory
state = malloc(sizeof(struct hc_state));

// Create a new PCB (PROTOCOL CONTROL BLOCK)
pcb = tcp_new();
if (pcb == NULL || state == NULL) {
//UARTprintf("hc_open: Not enough memory for pcb or state\n");
//Not enough memory
return 0;
}

// Define webclient state vars
num++;
state->Num = num;
state->RecvData = NULL;
state->ConnectionTimeout = 0;
state->Len = 0;
state->ReturnPage = returnpage;
state->CallingClass = arg;

// Make place for PostVars & Page
if (PostVars != NULL)
state->PostVars = malloc(strlen(PostVars) + 1);
state->Page = malloc(strlen(Page) + 1);

// Check for "out of memory"
if (state->Page == NULL || (state->PostVars == NULL && PostVars != NULL)) {
free(state->Page);
free(state->PostVars);
free(state);
tcp_close(pcb);
return 0;
}
// Place allocated copy data
strcpy(state->Page, Page);
if (PostVars != NULL)
strcpy(state->PostVars, PostVars);
else
state->PostVars = 0;

// Bind to local IP & local port
tcp_bind(pcb, IP_ADDR_ANY, 0);

// Use conn -> argument(s)
tcp_arg(pcb, state);

// Setup the TCP error function
tcp_err(pcb, hc_error);

tcp_poll(pcb, hc_poll, 10);

// Open connect (SEND SYN)
err_t conResult = tcp_connect(pcb, remoteIP, 80, hc_connected);

if (conResult != ERR_OK)
return -1;

return num;
}

safeRTOS lwip 1.3.2 lm3s9b96
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Stellaris John
    Posted by Stellaris John
    on Aug 07 2012 16:47 PM
    Intellectual2210 points

    Efe,

    You may want to cast a wider net in your search for lwIP answers by asking a question or searching through the user mailing lists at http://savannah.nongnu.org/mail/?group=lwip. Your questions look to be high level enough to be hardware independent.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use