Skip to content

Commit

Permalink
Fixed reading bits of a word with MultiRead()
Browse files Browse the repository at this point in the history
  • Loading branch information
dmroeder committed Jul 19, 2018
1 parent d640a27 commit f422eeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
07/18/18
-Fixed reading bits of a word with MultiRead. Ex: DintTag.0

06/03/18
-Fixed issues handling CIP error codes
-Fixed issue when mixing Read with MultiRead
Expand Down
13 changes: 10 additions & 3 deletions eip.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _multiRead(self, args):
status = unpack_from('<B', retData, 48)[0]

if status == 0:
return MultiParser(self, retData)
return MultiParser(self, args, retData)
else:
if status in cipErrorCodes.keys():
err = cipErrorCodes[status]
Expand Down Expand Up @@ -1194,7 +1194,7 @@ def TagNameParser(tag, offset):
except:
return tag, bt, 0

def MultiParser(self, data):
def MultiParser(self, tags, data):
'''
Takes multi read reply data and returns an array of the values
'''
Expand All @@ -1213,7 +1213,13 @@ def MultiParser(self, data):
# successful reply, add the value to our list
if replyStatus == 0 and replyExtended == 0:
dataTypeValue = unpack_from('<B', stripped, offset+4)[0] # data type
if dataTypeValue == 160:
# if bit of word was requested
if BitofWord(tags[i]):
dataTypeFormat = self.CIPTypes[dataTypeValue][2]
val = unpack_from(dataTypeFormat, stripped, offset+6)[0]
bitState = _getBitOfWord(tags[i], val)
reply.append(bitState)
elif dataTypeValue == 160:
strlen = unpack_from('<B', stripped, offset+8)[0]
reply.append(stripped[offset+12:offset+12+strlen])
else:
Expand All @@ -1238,6 +1244,7 @@ def MakeString(self, string):
for x in xrange(len(string), 84):
work.append(0x00)
return work

def BitofWord(tag):
'''
Test if the user is trying to write to a bit of a word
Expand Down

0 comments on commit f422eeb

Please sign in to comment.