lwIP API without OS

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

lwIP API without OS

Mauricio brazuka
Hi everybody,

i am using Nios II 5.0 IDE and i try to create one project with the NIOS using the lwIP as Standalone.
Is it possible to use the lwIP 0.7.1 without an operating system running with the NIOS II?
I use the Linux as development platform and i tried to run the example "unixsim/simhost" from lwIP together with the NIOS but dont works.
I thought the lwIP (api_lib.c) can provide the emulation of the operating system, but i dont understand why can I define the architecture (sys_arch.c, sys_arch.h) to my Hardware(NIOSII). I need really to do this?
I am getting error "SYS_MBOX_NULL undefined" when i try to compile with the Nios IDE. Under Linux the unixsim run ok.

Can someone help me please?


Thanks a lot
Mauricio


Besseren Schutz gegen Spam - jetzt bei dem neuen Yahoo! Mail .
_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: lwIP API without OS

Christiaan Simons
Hi Mauricio,

> i am using Nios II 5.0 IDE and i try to create one project with the
> NIOS using the lwIP as Standalone.
> Is it possible to use the lwIP 0.7.1 without an operating system
> running with the NIOS II?

Yes. You'll need to use the raw-API
as documented in lwip/docs/rawapi.txt.

The raw-API is an asynchronous API,
so you'll need to make some sort of event loop.

> I use the Linux as development platform and i tried to run the
> example "unixsim/simhost" from lwIP together with the NIOS but dont
works.

Try the current lwIP sources from http://savannah.nongnu.org/projects/lwip
(use anonymous CVS to obtain the current development sources)

> I thought the lwIP (api_lib.c) can provide the emulation of the
> operating system, but i dont understand why can I define the
> architecture (sys_arch.c, sys_arch.h) to my Hardware(NIOSII). I need
> really to do this?

It does not emulate an operating system!
The socket API always requires an operating system,
this is always true, not only for lwIP.

Hope this helps,

Bye,
Christiaan.



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

RE: lwIP API without OS

Nishen Naidu
In reply to this post by Mauricio brazuka
Make sure you define NO_SYS in your lwip opts file and use the raw api.
basically you have to implement the functions like
netio_recv,netio_accept,netio_init
SYS_MBOX_NULL should be defined to NULL
 
example implementation:
 
 
static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
        
 
            tcp_arg(pcb, NULL);
           tcp_sent(pcb, NULL);
            tcp_recv(pcb, netio_recv);
           return ERR_OK;
 }
 
void netio_init(void)
{
 struct tcp_pcb *pcb;
 
 pcb = tcp_new();
 tcp_bind(pcb, IP_ADDR_ANY, 1000);
 pcb = tcp_listen(pcb);
 tcp_accept(pcb, netio_accept);
}
static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
 
struct pbuf* ptr;  
 
int pktlen = 0;
 
 if (err == ERR_OK && p != NULL)
 {
  tcp_recved(pcb, p->tot_len);
  //just echo the same string 
  
 
  //pkt received.. 
//do something with your pkt    
  if (ptr!=NULL)
  {
   
   

   err = tcp_write(pcb, ptr->payload, pktlen, 0);
  }
 

  
  //send the packet back out again using tcp_write
 
  pbuf_free(p);
  pbuf_free(ptr);    
 
 }
 else
  pbuf_free(p);
 
 if (err == ERR_OK && p == NULL)
 {
//check if we come here..
// free the connection number
  tcp_arg(pcb, NULL);
  tcp_sent(pcb, NULL);
  tcp_recv(pcb, NULL);
  tcp_close(pcb);
 
 }
 

 return ERR_OK;
}
 
Nishen
 
-----Original Message-----
From: lwip-users-bounces+nishenn=[hidden email] [mailto:lwip-users-bounces+nishenn=[hidden email]]On Behalf Of Mauricio brazuka
Sent: 10 August 2006 10:23
To: [hidden email]
Subject: [lwip-users] lwIP API without OS

Hi everybody,

i am using Nios II 5.0 IDE and i try to create one project with the NIOS using the lwIP as Standalone.
Is it possible to use the lwIP 0.7.1 without an operating system running with the NIOS II?
I use the Linux as development platform and i tried to run the example "unixsim/simhost" from lwIP together with the NIOS but dont works.
I thought the lwIP (api_lib.c) can provide the emulation of the operating system, but i dont understand why can I define the architecture (sys_arch.c, sys_arch.h) to my Hardware(NIOSII). I need really to do this?
I am getting error "SYS_MBOX_NULL undefined" when i try to compile with the Nios IDE. Under Linux the unixsim run ok.

Can someone help me please?


Thanks a lot
Mauricio


Besseren Schutz gegen Spam - jetzt bei dem neuen Yahoo! Mail .

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

Re: lwIP API without OS

Mauricio brazuka
In reply to this post by Christiaan Simons
Hi,

Thanks for the answer!

Then i cant use funktions like:
netconn_write(conn, (void *)str, strlen(str), NETCONN_NOCOPY)

But with the raw-API i can to use linux as develoment environment to test and then compile the programm to Nios?

Bye
Mauricio

Christiaan Simons <[hidden email]> schrieb:
Hi Mauricio,

> i am using Nios II 5.0 IDE and i try to create one project with the
> NIOS using the lwIP as Standalone.
> Is it possible to use the lwIP 0.7.1 without an operating system
> running with the NIOS II?

Yes. You'll need to use the raw-API
as documented in lwip/docs/rawapi.txt.

The raw-API is an asynchronous API,
so you'll need to make some sort of event loop.

> I use the Linux as development platform and i tried to run the
> example "unixsim/simhost" from lwIP together with the NIOS but dont
works.

Try the current lwIP sources from http://savannah.nongnu.org/projects/lwip
(use anonymous CVS to obtain the current development sources)

> I thought the lwIP (api_lib.c) can provide the emulation of the
> operating system, but i dont understand why can I define the
> architecture (sys_arch.c, sys_arch.h) to my Hardware(NIOSII). I need
> really to do this?

It does not emulate an operating system!
The socket API always requires an operating system,
this is always true, not only for lwIP.

Hope this helps,

Bye,
Christiaan.



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


Keine Lust auf Tippen? Rufen Sie Ihre Freunde einfach an.
Yahoo! Messenger. Jetzt installieren .
_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

RE: lwIP API without OS

Mauricio brazuka
In reply to this post by Nishen Naidu
Hi,

thanks a lot for your answer, i will try this.

Bye
Mauricio

Nishen Naidu <[hidden email]> schrieb:
Make sure you define NO_SYS in your lwip opts file and use the raw api.
basically you have to implement the functions like
netio_recv,netio_accept,netio_init
SYS_MBOX_NULL should be defined to NULL
 
example implementation:
 
 
static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
        
 
            tcp_arg(pcb, NULL);
           tcp_sent(pcb, NULL);
            tcp_recv(pcb, netio_recv);
           return ERR_OK;
 }
 
void netio_init(void)
{
 struct tcp_pcb *pcb;
 
 pcb = tcp_new();
 tcp_bind(pcb, IP_ADDR_ANY, 1000);
 pcb = tcp_listen(pcb);
 tcp_accept(pcb, netio_accept);
}
static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
 
struct pbuf* ptr;  
 
int pktlen = 0;
 
 if (err == ERR_OK && p != NULL)
 {
  tcp_recved(pcb, p->tot_len);
  //just echo the same string 
  
 
  //pkt received.. 
//do something with your pkt    
  if (ptr!=NULL)
  {
   
   

   err = tcp_write(pcb, ptr->payload, pktlen, 0);
  }
 

  
  //send the packet back out again using tcp_write
 
  pbuf_free(p);
  pbuf_free(ptr);    
 
 }
 else
  pbuf_free(p);
 
 if (err == ERR_OK && p == NULL)
 {
//check if we come here..
// free the connection number
  tcp_arg(pcb, NULL);
  tcp_sent(pcb, NULL);
  tcp_recv(pcb, NULL);
  tcp_close(pcb);
 
 }
 

 return ERR_OK;
}
 
Nishen
 
-----Original Message-----
From: lwip-users-bounces+nishenn=[hidden email] [mailto:lwip-users-bounces+nishenn=[hidden email]]On Behalf Of Mauricio brazuka
Sent: 10 August 2006 10:23
To: [hidden email]
Subject: [lwip-users] lwIP API without OS

Hi everybody,

i am using Nios II 5.0 IDE and i try to create one project with the NIOS using the lwIP as Standalone.
Is it possible to use the lwIP 0.7.1 without an operating system running with the NIOS II?
I use the Linux as development platform and i tried to run the example "unixsim/simhost" from lwIP together with the NIOS but dont works.
I thought the lwIP (api_lib.c) can provide the emulation of the operating system, but i dont understand why can I define the architecture (sys_arch.c, sys_arch.h) to my Hardware(NIOSII). I need really to do this?
I am getting error "SYS_MBOX_NULL undefined" when i try to compile with the Nios IDE. Under Linux the unixsim run ok.

Can someone help me please?


Thanks a lot
Mauricio

Besseren Schutz gegen Spam - jetzt bei dem neuen Yahoo! Mail .
_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users


Yahoo! Messenger - kostenlos* mit Familie und Freunden von PC zu PC telefonieren .
_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users