Extracting data from lwIP TCP/IP flow on microcontroller

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Extracting data from lwIP TCP/IP flow on microcontroller

Zsolt Nagy
Hello Everyone,

I'm using a Texas Instruments RM57L843 microcontroller and I would like to communicate with it from the PC. I managed to set up communication with static IP, and successfully pinged the controller. I'm using the drivers provided by TI. I'm using raw api, trying to keep things as low level as possible.

Now I would like to extract data from the bitstream, e.g.: if I press "P" on the keyboard of the computer, I would like to extract that "P" in the controller from the bitstream; and this applies to not just letters, but words and numbers, too.

Also, I noticed that there were significantly more packets received by the controller, than the 4 ping packets - I guess, these were part of the necessary network communication. So another job would be to extract the packets I need, I send, from this dataflow.

Thanks for your reply in advance.

Regards,

Zsolt Nagy

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Extracting data from lwIP TCP/IP flow on microcontroller

goldsimon@gmx.de
On 25.07.2018 12:10, Zsolt Nagy wrote:

> Hello Everyone,
>
> I'm using a Texas Instruments RM57L843 microcontroller and I would
> like to communicate with it from the PC. I managed to set up
> communication with static IP, and successfully pinged the controller.
> I'm using the drivers provided by TI. I'm using raw api, trying to
> keep things as low level as possible.
>
> Now I would like to extract data from the bitstream, e.g.: if I press
> "P" on the keyboard of the computer, I would like to extract that "P"
> in the controller from the bitstream; and this applies to not just
> letters, but words and numbers, too.
>
> Also, I noticed that there were significantly more packets received by
> the controller, than the 4 ping packets - I guess, these were part of
> the necessary network communication. So another job would be to
> extract the packets I need, I send, from this dataflow.
>
> Thanks for your reply in advance.

So do you have a question?

Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Extracting data from lwIP TCP/IP flow on microcontroller

Zsolt Nagy
In reply to this post by Zsolt Nagy
The question is: how to?

After establishing connection between the RM57L843 and the PC and after I'm trying to get the data from the struct passed to the application layer (recv_data), I always get the following results in recv_data, after reading it from the watchdog variable:

*recv_data    struct pbuf    {next=0xEA005BB2 {next=???,payload=0xEAFFFFFE,tot_len=65534,len=60159,type=254 '\xfe'...    0x00000000   



2018-07-25 12:10 GMT+02:00 Zsolt Nagy <[hidden email]>:
Hello Everyone,

I'm using a Texas Instruments RM57L843 microcontroller and I would like to communicate with it from the PC. I managed to set up communication with static IP, and successfully pinged the controller. I'm using the drivers provided by TI. I'm using raw api, trying to keep things as low level as possible.

Now I would like to extract data from the bitstream, e.g.: if I press "P" on the keyboard of the computer, I would like to extract that "P" in the controller from the bitstream; and this applies to not just letters, but words and numbers, too.

Also, I noticed that there were significantly more packets received by the controller, than the 4 ping packets - I guess, these were part of the necessary network communication. So another job would be to extract the packets I need, I send, from this dataflow.

Thanks for your reply in advance.

Regards,

Zsolt Nagy


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Extracting data from lwIP TCP/IP flow on microcontroller

Sergio R. Caprile
In reply to this post by Zsolt Nagy
OK...
You seem to need a tutorship or a crash course in networking followed by
a study of lwIP.

You need to first get a grasp of the layer model as an abstraction: if
you set things right, that is, if you assign the proper IP address and
open the proper TCP port, you will get a callback with a pointer to what
you sent from the other side. There is no "other traffic" to worry about.
There's a catch: TCP is not a serial port, you will get exactly what you
sent, but not necessarily timed in the same way.

Then there is lwIP... and its RAW API. Here, in your callbacks, you
don't get plain data, you get pbufs. A pbuf is a structure holding a bit
of your data. Here 'a bit' is what arrived in a single Ethernet frame,
which depends on how TCP arranged it at the other end, and it might be
scattered through many pbufs in a pbuf chain, depending on how memory
was alloced when the driver asked for it.

You should take a look at the many available examples and learn how to
do what you want to do.
For example, a simple RAW API TCP callback can be:
static err_t myrecv(void *arg, struct tcp_pcb* pcb, struct pbuf *p,
err_t err)
{
static char buffer[MSG_LEN];

        if ((p == NULL) || (err != ERR_OK)){
                // Connection closed by remote end
                // need to close pcb and related stuff
                return ERR_OK;
        }
        // assuming MSG_LEN >= p->tot_len, otherwise is a bit more complicated
        pbuf_copy_partial(p, buffer, p->tot_len, 0);
        tcp_recved(pcb, p->tot_len);
        pbuf_free(p);
        // your data is now in a contiguous buffer, use it
        return ERR_OK;
}
There are many posts on the list discussing this.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users