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

fixed zero index problem where _u8ResponseBufferLength is set. #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

intelligentandgoodlooking

Description

when a 1 word (2 byte) response is received _u8ResponseBufferLength is erroneously set to 0 instead of 1
similarly, a 16 word (32 byte) response is received, _u8ResponseBufferLength is set to 15 instead of 16.
This causes available() to return 1 less than it should.

Issues Resolved

It seems like not many people use the available() function.

Check List

General

  • Code follows coding style defined in STYLE.md
  • Doxygen comments are included inline with code
  • No unnecessary whitespace; check with git diff --check before committing.

The following have been modified to reflect new features, if warranted

  • README.md
  • keywords.txt (use tabs as whitespace separators)
  • library.properties
  • examples/ - update or create new ones, as warranted

The following have NOT been modified

  • doc/ - will be updated upon versioned release
  • .ruby-gemset
  • .ruby-version
  • CHANGELOG.md - will be updated upon versioned release (HISTORY.md is deprecated)
  • Gemfile
  • LICENSE
  • VERSION - will be updated upon versioned release

_u8ResponseBufferLength is set.
This was causing available()
to return 1 less word than it should
@PBudmark
Copy link

PBudmark commented Jun 3, 2021

Yes,
the _u8ResponseBufferLength needs the stepup, but to avoid buffer overrun,
the assignment should be moved inside brackets at 'if (i < ku8MaxBufferSize)'
or else _u8ResponseBufferLength is increased even if no register is stored.

In the case with odd number of bytes, 'if (u8ModbusADU[2] % 2)',
_u8ResponseBufferLength = i + 1; should be done inside the brackets,
as i is already stepped from the for-statement.

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

Successfully merging this pull request may close these issues.

2 participants