Inverted Byte order
I'm wondering if there is a way to handle a non-standard client who swaps the byte order on responses.
I've run into a couple of scenarios where this happens, and I would like to handle it in the project I'm working on.
A way? Yes. Easy? No.
Check out ModbusLocator.bytesToValue and ModbusLocator.valueToShorts. The ordering of bytes is hardcoded. There are two possible solutions: create new data types that duplicate the existing except for byte order for the types that you need. Or, you can add a switch to, i guess, a slave device that determines whether the bytes are swapped or not, and use the switch appropriately in the data type conversion code.
Good to know, thanks!
Looking at this made me wonder, using the convenience methods in the TCP master class, and the modbuslocator, is there currently a way to get multiple values.
Looking at the getValue method, it appears like it utilizes the batch feature, but only with a single read (or multiple registers, but only up to the required number for the specified value type).
For my app, the user sets the starting register/bit location, and the length they want to read, so I would ideally get some type of array back with the data in it. Then they can also select how to display that data (i.e. float, signed int, unsigned it, word swapped float, etc.)
Sending that information to the locator and pulling it back out directly from it in that form would be handy.
In general, I've really liked what you're doing here, and love some of the flexibility in this library over jamodbus (hence why I'm trying to adapt from it), but I'm just trying to get my head around everything, so forgive me if my questions are pretty noob-ish.