Need to know how to use packet buffers to send response packets, once the response packet is built.
This is regarding the issue I am currently handling. I am using STM3240G evaluation board to run a Modbus server having a TCP Raw socket-based echo server interface which receives Modbus request packets, sent from ModScan32 tool. The request packet is received without any errors on port 502, by the Modbus server running on the evaluation board. I am building a response Modbus packet as an array of unsigned char type, and type casting it to (void *) and assigning it to the payload member of a pbuf structure. I am assigning this pbuf structure pointer to the pbuf structure pointer member of the tcp echo server(es) structure. But the Modbus response packet is not received at the ModScan32 tool. My main doubt is regarding the values initialized in the pbuf structure.
My questions are:
What are the valid values for the pbuf structure members when TCP Raw socket interface is used to send a response message?
When I return the same received pbuf, the response packets are received in the ModScan32 tool. But when I change the payload in this pbuf, the received packet data is not changing - why? I am using the tcp echo server but want to return response data in the response packet, which is not happening. This is the exact problem I want a resolution for.
In other words, I just want to send a Modbus response packet from the evaluation board to the ModScan32 tool. The request Modbus packet is received in the Board, and I can display the structure fields in the IDE. Once this is done, I'll adapt this method to my application. But the payload field in the pbuf structure is not getting updated, even if I assign the send_buffer to the payload field. If sample code is available, I can understand the root cause better and be able to resolve this issue myself.
It is also possible that the send_buffer is built incorrectly, without taking the byte orientation into consideration. I have set endian-ness to BIG_ENDIAN.
Since the response is for a specific request, tcp echo server structure (es) has to be the same for both request and response. If I can send a Modbus packet from the Board to the ModScan32 tool, I can adapt this to my task. Please help in this regard. If any more details are required, I'll provide. Thanks.
