Add write methods for input buffers to SafeBufferAccess#43
Merged
Conversation
Add write_byte_input, write_int_input, write_dint_input, and write_lint_input methods to allow Modbus master plugin to update PLC input buffers with data read from remote slave devices. This fixes the 'SafeBufferAccess object has no attribute write_int_input' error that was causing the Modbus master to fail when updating IEC input buffers for word/dword/ldword types. Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds four write methods (write_byte_input, write_int_input, write_dint_input, write_lint_input) to the SafeBufferAccess facade class to enable Modbus master plugins to write data into PLC input buffers, resolving the 'SafeBufferAccess' object has no attribute 'write_int_input' error.
Key Changes:
- Added four new write methods for input buffers (byte, int, dint, lint)
- Applied code formatting changes (import reordering, line length adjustments)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add write methods for input buffers to SafeBufferAccess
Summary
This PR adds four missing write methods to the SafeBufferAccess facade class that allow writing to PLC input buffers:
write_byte_input(buffer_idx, value, thread_safe=True)write_int_input(buffer_idx, value, thread_safe=True)write_dint_input(buffer_idx, value, thread_safe=True)write_lint_input(buffer_idx, value, thread_safe=True)These methods are required by the Modbus master plugin, which needs to write data it reads from remote slave devices INTO the PLC's input buffers. While inputs are traditionally read-only from a PLC program's perspective, external communication plugins like Modbus master legitimately need to populate these buffers.
This fixes the error:
'SafeBufferAccess' object has no attribute 'write_int_input'The implementation delegates to the existing
buffer_accessor.write_buffer()method, which already supports input buffer writes. The diff also includes formatting changes applied by pre-commit hooks (black, isort, ruff).Review & Testing Checklist for Human
Notes
The new methods follow the exact same pattern as existing
write_*_outputandwrite_*_memorymethods, making this a low-risk change. The underlying buffer accessor already supported this functionality - only the facade was missing the methods.Link to Devin run: https://app.devin.ai/sessions/c0ab2357ad504b7ba3826ec9e9a16955
Requested by: Thiago Alves (@thiagoralves)