lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Api questions (help and advice needed)


From: shogun
Subject: [lwip-users] Api questions (help and advice needed)
Date: Sun, 28 Nov 2010 10:37:24 -0500

I have been trying to better understand LWIP and looking for help and or
documentation to help me understand LWIP better.  I am using a Stellaris CPU
from TI and been using the RAW API without an OS using lwip version 1.3.1
and just using the callbacks to receive data and tcp_write() to send data.
I do have one connection sending and receiving data OK but I know I did
something wrong because when I added a second connection I started having
problems because the communications would stop and the debugger would show
the software running these two lines of code only:

(line 180 from src\core\tcp_in.c) for(pcb = tcp_active_pcbs; pcb != NULL;
pcb = pcb->next)  


(line 201) prev = pcb;

I want to use two TCP/IP connections on two different ports (port x and port
y).  One port (x) is for sending and receiving data for the application and
the other port (y) is what is typically used by developers for printf and to
interact with the software to send and receive commands etc.  Typically the
serial port is used here but I want use a connection for this.

I do plan to add OS support to my app soon and have a question about the API
when using an RTOS but first I wanted to understand my problem now without
an OS so I don't compound any problem I have when I add a RTOS. The main
loop is in a loop looking for data to process and send.  This data comes in
via a device in an interrupt and sets a flag that main looks for and when
main finds there is data it will process and send it using tcp_write().
Correct me if I am wrong but I think this part is OK since the data is being
send only from main context.  I think my problem is only in the receive
callback. What is the best way to handle the callback when data is received
in a callback? In the receive callback what should I move out from the
callback into main?  Do I just set a flag in the receive callback such as a
pointer to the pbuf with the data and have main look for this flag/pointer?
Should I have main copy the data from the payload and also have main do the
pbuf_free() and tcp_recved() or should tcp_recved() be called in the receive
callback?  It's not clear to me if tcp_recved() can be called before the
data "payload" is copied out into main or it can be called in the callback
interrupt to indicate the other side (sender) the data have been received
for a ACK.  Since the receive callback contains a pointer to PCB, is the
address of this PCB typically put in a memory location that main looks for
so main can copy the data out, free the memory and also call tcp_recved()?
Could someone help me understand this?

Now the question about the OS and API.   I just got a CPU with safeRTOS in
ROM so I can start using that OS but I want to get a better understanding of
the stack before I jump in.  I have been looking for documentation on LWIP
to help me understand the interface better.  I have read the document
"Design and Implementation of the LWIP TCP/IP Stack" but it is from 2001.  I
also have the rawapi.txt doc and have read various things on the internet
about LWIP.  After reading the "Design and Implementation of the LWIP TCP/IP
Stack" I was thinking I should use the API in documented in Chapter 16
(netconn_) or ch 17 the BSD API.  Since the document is out of date, what
should I be reading and using for a reference to help me understand this to
select the right API and implement it correctly?



Thanks,
DB






reply via email to

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