Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modbus Adapter no facility to read swapped float values #20

Closed
kalpakkarnik opened this issue Apr 2, 2020 · 2 comments
Closed

Modbus Adapter no facility to read swapped float values #20

kalpakkarnik opened this issue Apr 2, 2020 · 2 comments

Comments

@kalpakkarnik
Copy link

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
Copy link
Member

wsobel commented Apr 2, 2020 via email

@kalpakkarnik
Copy link
Author

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<uint32_t>(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants