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

AGMultiRead Bit query #65

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type S7DataItem struct {
WordLen int
DBNumber int
Start int
Bit int
Amount int
Data []byte
Error string
Expand Down Expand Up @@ -162,8 +163,11 @@ func (mb *client) AGReadMulti(dataItems []S7DataItem, itemsCount int) (err error

// Adjusts the offset
var addr int
if dataItems[i].WordLen == s7wlbit || dataItems[i].WordLen == s7wlcounter || dataItems[i].WordLen == s7wltimer {
if dataItems[i].WordLen == s7wlcounter || dataItems[i].WordLen == s7wltimer {
addr = dataItems[i].Start
} else if dataItems[i].WordLen == s7wlbit {
addr = dataItems[i].Start << 3
addr += dataItems[i].Bit // Add Bit addr
} else {
addr = dataItems[i].Start * 8
}
Expand Down