This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
We have implemented Modbus protocol over TCP using lwip Stack without using any RTOS. Our control send the Modbus Queries 0x03 (Read Holding Register) and 0x10 (Write Multiple register)on every 1 seconds.
For Testing, We are using PLC Slave modbus simulator from Modbustools.com with our control.
In Halogen, under EMAC tab we configured "No of receive packet buffer" as 10. We also tested by setting buffer to 15 and 30 and in both cases, control stuck in receive interrupt in less than 20sec time.
We observed that Control works properly for Few seconds (repeatedly observed control works around 22 seconds ) then control hangs in Rx_Interrupt handler loop forever, Can anyone help on to resolve the issue?
Query and response log is attached below. Last query and response is highlighted in below log
QJ,
Thanks For your Reply.
Earlier we used to fill our local buffer into Rx ISR as well as Process that data to Modbus Application code . We have moved that Process function in main loop and reduce the Emac Rx isr time.
But still we observe the same result(after 22sec Control hang in hdkif_rx_inthandler() function). One more Observation, Once it stuck in Rx Isr loop Control start increment RXDMA and RXOver run Emac registers. please find below captured snap.
We have checked and Tool response time we set 10msec. Also We have tested with Two different tool and we observe the same behaviour.
Hello QJ,
I have limited the Throughput from Modbus side. Now, Control Transmit the query after 200msec and Modbus Tool response time also increased from 10msec to 100msec.
But still we observed the same result. Control stuck in Rx ISR loop as mentioned in above thread.
Can anyone LWIP expert comment on above Modbus over TCP issue? I am stuck ....
I have resolved this issue,
It was my mistake in code in the Receive call back function that I was not freeing up the pubf pointer.
after placing the following condition,
static err_t ModbusTCPrecv(void *arg, struct tcp_pcb *Rcevtpcb, struct pbuf *ptrModbusResBuf, err_t errMDRcvTCP)
{
if(ptrModbusResBuf)
{
// Copy the received data from MOBUS TCP slave to local buffer
pbuf_free(ptrModbusResBuf); /*added this condition to resolve the issue*/
}
}
Thank you QJ for your kind support.