stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.44k stars 1.75k forks source link

Add functions for reading raw data #51

Closed apple4ever closed 12 years ago

apple4ever commented 12 years ago

I would like a function to be able to get the raw data back from a sending request or a response. I have some code that copies msg in send_msg() and receive_msg(), but I'm having some memory leaks, so I'd like to know how to move forward.

Basically it should store the last raw request and response that is actually put on the wire (rtu or tcp) that can be read after each transmission/reception. IE:

int modbus_last_raw_query(modbus_t mb_param, uint8_t rawQuery); int modbus_last_raw_response(modbus_t mb_param, uint8_t rawResponse);

stephane commented 12 years ago

To be thread safe, you must store the information in the modbus context (so not enabled by default to avoid overhead) and the modbus context must be protected if shared.

PS: mb_param was the context name used in libmodbus 2.0, I hope you work with libmodbus 3.x

stephane commented 12 years ago

Oh and it's a question not a libmodbus issue so I'm closing it. You can use the mailing list to talk about that.