2024-07-24 12:14 AM - edited 2024-07-24 03:17 AM
struct pbuf * ModbusIxFace(struct pbuf *p)
{
MBDEFS_BOOL mbHandle;
struct pbuf *pTx = pbuf_alloc(Layer, TX_BUFFER_SIZE, bufType);
mbHandle = HandleModbusRequest(p->payload);
HAL_Delay(40);
memcpy(pTx->payload, (void *)(QUERY_MESG_HEADER *)MBSlave_SendBuffer, sizeof(MBSlave_SendBuffer));
//pIx = p;
return pTx;
}
HandleModbusRequest(..) function receives the Modbus request packet and processes it.
The Modbus request is built into the global byte array, MBSlave_SendBuffer[], and it is
copied to the payload of a new packet buffer. All the Modbus protocol processing happens
in the HandleModbusRequest(..) function.
In the server code, it is needed to find a place, where I can check if it is echo or Modbus response. If it is echo response, I won't send it. If it is Modbus response, I'll send it. If any more details are required, I'll provide. Please help.
2024-08-01 06:12 AM
Hello @VSomasekhar,
If I understand you correctly, you want to disable the Echo response and allow only the Modbus response on your TCP server. We propose modifying the tcp_echoserver_recv function in the tcp_echoserver.c file so that the ModbusIxFace function is called to handle the Modbus request. If ModbusIxFace returns a valid response, it is sent to the client. Otherwise, no Echo response is sent.
This modification can ensure that only Modbus responses are transmitted, thereby eliminating unwanted Echo responses.
With Regards,