mtconnect / adapter

MTConnect adapter framework
90 stars 73 forks source link

Modbus Adapter no facility to read swapped float values #20

Closed kalpakkarnik closed 4 years ago

kalpakkarnik commented 4 years ago

In Modbus MtConnect adapter unable to read swapped float values . Need one more data type along with ieee_float to read swapped float values from modbus device.

wsobel commented 4 years ago

Hi,

The adapter framework has not been maintained for a while. Please feel free to fix and send pull request.

Thanks, W

On Apr 2, 2020, at 09:06, kalpakkarnik notifications@github.com wrote:

In Modbus MtConnect adapter unable to read swapped float values . Need one more data type along with ieee_float to read swapped float values from modbus device.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mtconnect/adapter/issues/20, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ6BCJNCMSDDQSIXX4J7SLRKSZWXANCNFSM4L2TY4XQ.

kalpakkarnik commented 4 years ago

Hi

I Figures out . In modbus_adapter.hpp file under the structure ModbusFloat change the writeValue() function as below to read form swapped float register values: virtual void writeValues() { int offset = mDataItems.size(); for (int i = 0; i < mDataItems.size(); i++) { uint32_t value; value = (static_cast(mData[offset]) << 16) + mData[offset + 1]; (static_cast<Sample>(mDataItems[i]))->setValue(((float*)&value)); offset -= mSize[i]; } }

Closing the thread for now ,will create and send pull request soon

Thanks.