[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Raw api + multiple TCP Connections
From: |
Jan Menzel |
Subject: |
Re: [lwip-users] Raw api + multiple TCP Connections |
Date: |
Mon, 22 May 2017 15:00:22 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 |
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_terr)
>
> {
>
> // 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_terr)
>
> {
>
> // 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
>
- Re: [lwip-users] Raw api + multiple TCP Connections, (continued)
- 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, 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 <=
- 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