lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Tcp Server on Texas Instrument RM57


From: Julio Cesar Aguilar Zerpa
Subject: Re: [lwip-users] Tcp Server on Texas Instrument RM57
Date: Mon, 31 Oct 2016 13:18:13 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

Hi Noam,


thanks again for your help.


Which LwIP version do you have? The function 'tcp_new_ip_type' is just another way to allocate a new tcp pcb (I use version 1.4.1). I don't think that is the cause of the problem, though.

However, I did try it again with your init function and the program has the same behavior as before.


In my 'main.cpp' I have a while loop that gets data from the serial port and then calls 'tcpServer_send' (I want to send that data over ethernet). This function call is not in the same context as the LwIP callbacks, so I guess that's why it doesn't work. How do you send data from outside this context?


Best regards,

Julio


Am 31.10.2016 um 12:26 schrieb Noam Weissman:

Hi,

 

As a continuation to my earlier mail…

 

Where do you call tcpServer_send ??

 

In tcpecho_raw_init function you call function tcp_new_ip_type  I am not familier with this function ?

 

My init function looks like this:

 

struct tcp_pcb *Listening_pcb;  //  is define static global

 

 

void TcpTermInit(u16 TcpTermPort)

{

   struct tcp_pcb *pcb;

   err_t err;

     

   pcb = tcp_new();

  

   if(pcb != NULL)

   {                          

     // bind local IP with our port

     err = tcp_bind(pcb, IP_ADDR_ANY, TcpTermPort);

    

     if(err == ERR_OK)

     {

       // The tcp_listen() function returns a new connection control block, and

       // the one passed as an argument to the function will be deallocated. The

       // reason for this behavior is that less memory is needed for a connection

       // that is listening, so tcp_listen() will reclaim the memory needed for

       // the original connection and allocate a new smaller memory block for the

       // listening connection.      

       Listening_pcb = tcp_listen(pcb);

  

       // if we are here that mean that we did not use all available connection

       // and we are ready to treat another one.

       tcp_setprio(Listening_pcb, TCP_PRIO_MIN);         

       

       tcp_accept(Listening_pcb, tcp_term_accept);

     }

     else

     {

       /* abort? output diagnostic? */   

     }

   }

 

   else

   {

     /* abort? output diagnostic? */ 

   }

}

 

 

BR,

Noam.

 

 

From: lwip-users [mailto:address@hidden] On Behalf Of Julio Cesar Aguilar Zerpa
Sent: Monday, October 31, 2016 11:00 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Tcp Server on Texas Instrument RM57

 

Hi Noam,

 

Thank you for helping me.


1. First of all are you running with an OS or without?
    I am using the RM57 Microprocessor -> without OS

2. Secondly do you understand that with RAW API you should not call any LwIP if the call is not from within the LwIP own context?
    That is a very important point that I didn't know about! So, then how should I send data? How do I initialize the pbuf pointer?

3. As far as I see you are not copying the data into the new buffer. How is the send itself? does the function tcpecho_raw_send copying the data to the buffer?
   
Yes, you are right. I noticed that. I then tried it with "TEST_DATA" as global. Same problem (but at least the data was correct at tcpecho_raw_send)

4. The code is just partial so I cannot see the picture
    You can see the code if you have the examples. It's the 'tcpecho_raw'. I will attach it just in case you don't have it. I made some minor modifications to check if there's a connection and also added the function already described. (Again: the 'echo' part works -> received data is being sent back correctly, but sending data that wasn't received is not working)

5. Secondly check if tcp_write uses the copy mode into an internal buffer or use a reference to data.
    Yes, it uses the copy mode.

I also tried to send the data using the 'tcp_write' function directly instead of calling tcpecho_raw_send and it returned error -11 (no connection) but was receiving and sending data over the callbacks.

It appears your second statement is one of the reason my program is not working. I don't have any current docu, do you have any?
How do I send data? Is there another example that receives data over callbacks and is able to send data created on its own memory space?

Best regards,
Julio

Am 29.10.2016 um 02:04 schrieb Noam Weissman:

Hi,

 

First of all are you running with an OS or without ?

Secondly do you understand that with RAW API you should not call any LwIP

if the call is not from within the LwIP own context ?

 

As far as I see you are not copying the data into the new buffer. How is the send itself ?

does the function tcpecho_raw_send copying the data to the buffer ?

 

RAW API means that everything you do is in the same context. If you block on the function

tcpecho_raw_send and/or do something that takes too much time yes the data will not properly

handled.

 

The code is just partial so I cannot see the picture.

 

I would start with setting your uint8 data[] = "TEST_DATA"; to static OUTSIDE of the function. This way

it will not change when you exit from the function.

 

Secondly check if tcp_write uses the copy mode into an internal buffer or use a reference to data.

 

BR,

Noam.

 


From: lwip-users <address@hidden> on behalf of Julio Cesar Aguilar Zerpa <address@hidden>
Sent: Friday, October 28, 2016 4:56 PM
To: address@hidden
Subject: [lwip-users] Tcp Server on Texas Instrument RM57

 

Hi there,

I am trying to use the LwIP library (1.4.1) to create a simple tcp
server on a Texas Instrument RM57.

So far, I could make the "tcpecho_raw" example to work using an static ip.

I also added the following function (which did not work), to be able to
send data that wasn't an echo:

void tcpServer_send()
{
     uint8 data[] = "TEST_DATA";
     struct pbuf* buffer = pbuf_alloc(PBUF_RAW, sizeof(data), PBUF_POOL);

     if (buffer)
     {
         sciDisplayText(sciREG1, txt_new_line, sizeof(txt_new_line));
         sciDisplayText(sciREG1, "buffer created", sizeof("buffer
created"));

         buffer->tot_len = sizeof(data);
         buffer->len = sizeof(data);
         buffer->payload = data;
         tcpecho_es->p = buffer;

         tcpecho_raw_send(tcpecho_raw_pcb, tcpecho_es);
     }
}

As you can see, the function prints a debug msg ("buffer created"). I
modified the function 'tcpecho_raw_send' to also print a debug msg (the
data being sent).

When I run the program, I can see the msg "buffer created" every time
the function is called, but the msg from 'tcpecho_raw_send' comes only
when I close the client! (And the msg is missing the acutal data, btw).

NOTE: I want to build a server that receives some commands and sends a
block of data (4KB) every 60 ms. I am using the raw API because I don't
want to use blocking functions (from what I understood the netconn API
uses blocking functions).

I would appreciate any help.

Best regards,

Julio Aguilar


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

lists.nongnu.org

Welcome to the lwip-users mailing list. Use it to ask questions, share your experience and discuss new ideas. To see the collection of prior postings to the list ...

 




_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users



Mit freundlichen Grüßen
Götting KG
i.A. Julio Cesar Aguilar Zerpa
-- 
M.Sc. Julio Cesar Aguilar Zerpa
Forschung & Entwicklung
address@hidden
Tel. +49(0)-5136-8096-39
————————————————————
Götting KG
Celler Str. 5, D-31275 Lehrte/Röddensen
Geschäftsführer H.-H. Götting
HR A 31127 | Amtsgericht Hildesheim
Gerichtsstand Lehrte
USt.-Id. Nr. DE 115055039
USt.-Nr. 16-226-13403
Phone +49(0)-5136-8096-0
Fax +49(0)-5136-8096-80
address@hidden | www.goetting.de
————————————————————


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

Mit freundlichen Grüßen
Götting KG
i.A. Julio Cesar Aguilar Zerpa
-- 
M.Sc. Julio Cesar Aguilar Zerpa
Forschung & Entwicklung
address@hidden
Tel. +49(0)-5136-8096-39
————————————————————
Götting KG
Celler Str. 5, D-31275 Lehrte/Röddensen
Geschäftsführer H.-H. Götting
HR A 31127 | Amtsgericht Hildesheim
Gerichtsstand Lehrte
USt.-Id. Nr. DE 115055039
USt.-Nr. 16-226-13403
Phone +49(0)-5136-8096-0
Fax +49(0)-5136-8096-80
address@hidden | www.goetting.de
————————————————————

reply via email to

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