My application is built with LWIP 1.4.1 running on a TI MCU and uses raw TCP
and raw UDP calls, no RTOS.
The TCP is used to send commands to the hardware and is always acknowledged
with an "ACK" message.
The UDP is used to send sensor data to the client every 10ms.
I can send messages and receive "ACK" without error and I can enable the UDP
output without error but when I combine TCP and UDP my application will
eventually generate a hardware fault. Looking at the stack it seems to be in
the "plug_holes" function.
I am a first time user of LWIP. Any assistance would be appreciated.
This is my main loop that outputs the UDP:
// allocate pbuf for UDP
p=pbuf_alloc(PBUF_TRANSPORT, 32, PBUF_RAM);
//
// Loop forever, processing the LED blinking. All the work is done in
// interrupt handlers.
//
while(1)
{
// get latest input
change = updateUdpPacket(udpOut);
/* can't send UDP untill TCP connected */
if (clientIpAddr.addr != 0) {
// send UPD if data delay expires or input changed state
if (change || g_100usTick == 0) {
// only output UDP if data delay is enabled (-1 is disabled)
if (data_stream_delay_ms >= 0) {
if (p) {
// Toggle the red LED.
MAP_GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_5,
(MAP_GPIOPinRead(GPIO_PORTP_BASE,
GPIO_PIN_5) ^
GPIO_PIN_5));
sprintf(p->payload, "%s %04X %s\n", VM.PodId, g_usSeq,
udpOut);
// increment the UDP number
g_usSeq++;
// send the UDP message
udp_sendto(UDPpcb, p, &clientIpAddr, UDP_PORT);
}
}
// reset the data delay counter
VM.DataStreamDelay = data_stream_delay_ms; // convert to float
g_100usTick = VM.DataStreamDelay / 0.1; // set data delay
counter to 100us ticks
}
}
}
This is my TCP receive callback:
err_t TCPrecv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
err_t ret_err;
u16_t len;
int cmdDone = false;
if (p != NULL && err == ERR_OK)
{
/* process pcb */
cmdDone = ProcessData(p->payload, p->len, tcpOut);
// cleanup receive window and pcb
tcp_recved(tpcb, p->len);
pbuf_free(p);
}
//
// If a null packet is passed in, close the connection.
//
else if((err == ERR_OK) && (p == NULL))
{
//
// Clear out all of the TCP callbacks.
//
TCPclose(tpcb);
}
else
{
ret_err = err;
}
if (cmdDone) {
len = strlen(tcpOut);
// write the response (tcp_output not needed when tcp_write called from
receive callback)
ret_err = tcp_write(tpcb, tcpOut, len, 1);
if (ret_err)
len = 0;
}
return ret_err;
}
Regards,
Robert Applebee
Software Project Engineer
Astronics Test Systems Inc.,
4 Goodyear
Irvine, California 92618 USA
O: +1.949.460.6795
E: [email protected]<mailto:[email protected]>
www.astronicstestsystems.com<http://www.astronicstestsystems.com/>
This E-mail is confidential. It may also be legally privileged. If you are not
the addressee you may not copy, forward, disclose or use any part of it. If you
have received this message in error, please delete it and all copies from your
system and notify the sender immediately by return E-mail.
Internet communications cannot be guaranteed to be timely, secure, error or
virus-free. The sender does not accept liability for any errors or omissions.
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users