I made ModbusTCP slave based on the esp-idf examples.
It works but the floating point byte order is not understood by the connected Modbus master.
I need to make an extra data array just for the Modbus data transfer. Is there any way just change the byte order in esp-idf Modbus library?
This is my solution at the moment:
- void DataExchange::updateModbusArray()
- {
- for(int i=0; i < _numElements; i++)
- {
- _modbusArray[i*4+0] = *((char*)_dataArray + i*4+2);
- _modbusArray[i*4+1] = *((char*)_dataArray + i*4+3);
- _modbusArray[i*4+2] = *((char*)_dataArray + i*4+0);
- _modbusArray[i*4+3] = *((char*)_dataArray + i*4+1);
- }
- }