Altera_Forum
Honored Contributor
18 years agoEthernet
http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif Hello everybody http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
I've a problem with a TCP connection in my development kit nios2 stratix 60_rohserr_t conectado()
{
printf("Estamos conectaos!");
printf("Enviando.......\n");
while(1)
{
tcp_write(pcb, i, sizeof(i), 0);
lan91c111if_service(&netif);
i++;
}
return(ERR_OK);
}
int main(void)
{
//struct netif netif;
struct ip_addr ipaddr, netmask, gw;
struct ip_addr ipdest;
struct pbuf* pbuf;
//struct tcp_pcb* pcb;
//int i=0;
int *pi;
*pi = i;
alt_avalon_lan91c111_if* dev_list_ptr = (alt_avalon_lan91c111_if*)alt_ethernet_device_list.next;
printf("Prueba con TCP\n\n");
pbuf = pbuf_alloc(PBUF_TRANSPORT,30,PBUF_RAM);
pbuf_free(pbuf);
pbuf -> payload = (int*)pi;
printf("payload = %d\n",pbuf->payload);
/*
* Initialize lwip
*/
lwip_init();
printf ("Setting IP address to: %d.%d.%d.%d\n", IPADDR0, IPADDR1, IPADDR2, IPADDR3);
printf ("Setting netmask to: %d.%d.%d.%d\n", NETMASK0, NETMASK1, NETMASK2, NETMASK3);
printf ("Setting gateway address to: %d.%d.%d.%d\n\n\n", GWADDR0, GWADDR1, GWADDR2, GWADDR3);
IP4_ADDR(&ipaddr, IPADDR0, IPADDR1, IPADDR2, IPADDR3);
IP4_ADDR(&netmask, NETMASK0, NETMASK1, NETMASK2, NETMASK3);
IP4_ADDR(&gw, GWADDR0, GWADDR1, GWADDR2, GWADDR3);
netif_add(&netif, &ipaddr, &netmask, &gw,
(void*)dev_list_ptr,
lan91c111if_init,
ip_input);
netif_set_default(&netif);
// IP4_ADDR(&ipdest, IPADDRDEST0, IPADDRDEST1, IPADDRDEST2, IPADDRDEST3);
// printf ("Setting destination IP address to: %d.%d.%d.%d\n", IPADDRDEST0, IPADDRDEST1, IPADDRDEST2, IPADDRDEST3);
printf("iniciant el tema TCP!\n");
I supose that here starts my problems: I don't know what i'm doing wrong, it's close to all exemples tcp_init();
pcb = tcp_new();
tcp_bind(pcb,&ipaddr, 70);
pcb2=&tcp_listen(pcb)
tcp_accept(pcb2, conectado());
printf("A prendre pel sac!\n");
} Could anybody help me? I will be very happy, thank you a lot for your time