[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Raw api + multiple TCP Connections
From: |
Noam Weissman |
Subject: |
Re: [lwip-users] Raw api + multiple TCP Connections |
Date: |
Mon, 22 May 2017 13:04:06 +0000 |
Jan see his code. He was trying to compare listening port with working port
-----Original Message-----
From: lwip-users [mailto:address@hidden On Behalf Of Jan Menzel
Sent: Monday, May 22, 2017 4:00 PM
To: address@hidden
Subject: Re: [lwip-users] Raw api + multiple TCP Connections
Hi Werner!
In you initial post you wrote, that your system catches a Hardfault. A
Hardfault indicates are general MCU failure which can be something like memory
corruption, stack problem, unaligned address, division by zero or even
escalated from some other fault. The actual reason can usually be extracted
from some system registers. To my limited understanding, this is very unlikely
an Lwip problem.
Best regards
Jan
On 22.05.2017 13:38, Werner Motz wrote:
> U are right, but I don't know where the mistake is. I can debug it and
> the breakpoints in myCallback1 and myCallback2 are hit.
>
> The also debugged the init_Server and the binding or listen gave no
> error. Both connections are initiated correctly.
>
>
>
>
>
> I do init:
>
>
>
> voidinit_Server(void)
>
> {
>
> structtcp_pcb*pcb_1;
>
> structtcp_pcb*pcb_2;
>
>
>
> pcb_1=tcp_new();
>
> pcb_2=tcp_new();
>
>
>
> tcp_bind(pcb_1,IP_ADDR_ANY,PortCAN1);
>
> tcp_bind(pcb_2,IP_ADDR_ANY,PortCAN2);
>
>
>
> pcb_1->flags|=TF_NODELAY;
>
> pcb_1->flags|=TF_ACK_NOW;
>
>
>
> pcb_2->flags|=TF_NODELAY;
>
> pcb_2->flags|=TF_ACK_NOW;
>
>
>
> tcp_arg(pcb_1,pcb_1);
>
> tcp_arg(pcb_2,pcb_2);
>
>
>
> pcb_1=tcp_listen(pcb_1);
>
> pcb_2=tcp_listen(pcb_2);
>
>
>
> tcp_accept(pcb_1,accept);
>
> tcp_accept(pcb_2,accept);
>
> }
>
>
>
>
>
> staticerr_taccept(void*arg,structtcp_pcb*pcb,err_terr)
>
> {
>
> LWIP_UNUSED_ARG(arg);
>
> LWIP_UNUSED_ARG(err);
>
>
>
> // set the receive callback for this connection
>
> if(pcb->local_port==PortCAN1)
>
> {
>
> tcp_setprio(pcb,TCP_PRIO_MAX);
>
> tcp_recv(pcb,myCallback1);
>
> }
>
> elseif(pcb->local_port==PortCAN2)
>
> {
>
> tcp_setprio(pcb,TCP_PRIO_MAX);
>
> tcp_recv(pcb,myCallback2);
>
> }
>
>
>
> // just use an integer number indicating the connection id as
> the
>
> // callback argument
>
> tcp_arg(pcb,(void*)pcb);
>
>
>
>
>
> // Inform lwIP that an incoming connection has been accepted.
>
> tcp_accepted(pcb);
>
>
>
> returnERR_OK;
>
> }
>
>
>
>
>
> staticerr_tmyCallback1(void*arg,structtcp_pcb*tpcb,structpbuf*p,err_te
> rr)
>
> {
>
> // avoid compiler warnings
>
> (void)arg;
>
> (void)err;
>
> chardata[8]={1,2,3,4,5,6,7,8};
>
>
>
> if(!p)//end of linked list
>
> {
>
> tcp_close(tpcb);
>
> tcp_recv(tpcb,NULL);
>
> returnERR_OK;
>
> }
>
>
>
> tcp_recved(tpcb,p->tot_len);//Antwort
>
>
>
> tcp_write(tpcb,&data[0],8,TCP_WRITE_FLAG_COPY);
>
> tcp_output(tpcb);
>
> pbuf_free(p);
>
>
>
> returnERR_OK;
>
> }
>
>
>
>
>
> staticerr_tmyCallback2(void*arg,structtcp_pcb*tpcb,structpbuf*p,err_te
> rr)
>
> {
>
> // avoid compiler warnings
>
> (void)arg;
>
> (void)err;
>
> chardata[8]={1,2,3,4,5,6,7,8};
>
>
>
> if(!p)//end of linked list
>
> {
>
> tcp_close(tpcb);
>
> tcp_recv(tpcb,NULL);
>
> returnERR_OK;
>
> }
>
>
>
> tcp_recved(tpcb,p->tot_len);//Antwort
>
>
>
> tcp_write(tpcb,&data[0],8,TCP_WRITE_FLAG_COPY);
>
> tcp_output(tpcb);
>
> pbuf_free(p);
>
>
>
> returnERR_OK;
>
> }
>
>
>
>
>
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users
- Re: [lwip-users] Raw api + multiple TCP Connections, (continued)
- Re: [lwip-users] Raw api + multiple TCP Connections, Werner Motz, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections, Noam Weissman, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections, Werner Motz, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections, Noam Weissman, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections, Simon Goldschmidt, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections, Noam Weissman, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections, Simon Goldschmidt, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections, Werner Motz, 2017/05/26
- Re: [lwip-users] Raw api + multiple TCP Connections, Joel Cunningham, 2017/05/27
- Re: [lwip-users] Raw api + multiple TCP Connections, Jan Menzel, 2017/05/22
- Re: [lwip-users] Raw api + multiple TCP Connections,
Noam Weissman <=
- Re: [lwip-users] Raw api + multiple TCP Connections, Simon Goldschmidt, 2017/05/22