diff --git a/changelog b/changelog index fa1c654..d117f41 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +07/21/18 + -Fixed bools that are part of an array with MultiRead. Ex MyBool[0] + 07/18/18 -Fixed reading bits of a word with MultiRead. Ex: DintTag.0 diff --git a/eip.py b/eip.py index 6d8ec7d..e249559 100644 --- a/eip.py +++ b/eip.py @@ -257,10 +257,14 @@ def _multiRead(self, args): if not _connect(self): return None for i in xrange(tagCount): - t,b,i = TagNameParser(args[i], 0) - InitialRead(self, t, b) + tag,base,ind = TagNameParser(args[i], 0) + InitialRead(self, tag, base) - tagIOI = _buildTagIOI(self, t, isBoolArray=False) + dataType = self.KnownTags[base][0] + if dataType == 211: + tagIOI = _buildTagIOI(self, tag, isBoolArray=True) + else: + tagIOI = _buildTagIOI(self, tag, isBoolArray=False) readIOI = _addReadIOI(self, tagIOI, 1) serviceSegments.append(readIOI) @@ -1093,14 +1097,21 @@ def _getBitOfWord(tag, value): it, then returns that bits value ''' split_tag = tag.split('.') - bitPos = split_tag[len(split_tag)-1] - bitPos = int(bitPos) - try: - if int(bitPos)<=31: - returnvalue = BitValue(value, bitPos) - except: - pass - return returnvalue + stripped = split_tag[len(split_tag)-1] + + if stripped.endswith(']'): + val = stripped[stripped.find("[")+1:stripped.find("]")] + val = int(val) + bitPos = val & 0x1f + returnValue = BitValue(value, bitPos) + else: + try: + bitPos = int(stripped) + if bitPos <= 31: + returnValue = BitValue(value, bitPos) + except: + pass + return returnValue def _wordsToBits(self, tag, value, count=0): ''' @@ -1205,25 +1216,30 @@ def MultiParser(self, tags, data): # get the offset values for each of the tags in the packet reply = [] for i in xrange(tagCount): - loc = 2+(i*2) # pointer to offset - offset = unpack_from('