robinson / gos7

Implementation of Siemens S7 protocol in golang
BSD 3-Clause "New" or "Revised" License
315 stars 124 forks source link

Query Bits in AGMultiRead #63

Closed phagemann closed 12 months ago

phagemann commented 1 year ago

When querying a single bool in a batch (AGMultiRead), gos7 builds a different address opposed to a byte. Provided the following S7DataItemStructs

dataItems := []gos7.S7DataItem{
    {s7areape, 0x01, 0, 32, 1, make([]byte, 2), ""},
    {s7areape, 0x02, 0, 32, 1, make([]byte, 2), ""},
}

I would expect gos7 to query address 32. But instead it queries the following (inspected by wireshark): image

The issue seems to be https://github.com/robinson/gos7/blob/ebce1a99aa32e62adad61e5dffc5a8e316cd5f18/multi.go#L165-L169 Where bit, counter and timer addresses are parsed different. For bits this seems to be wrong, counters and timers I can't test as of right now. Based on the screenshot above bits addresses should be parsed like the other types. As we can not specify which bit to query I suggest to add a field for bit address and ignore it for any type except bits.