Skip to content

Commit

Permalink
Update number of unused bytes in last SDO segment.
Browse files Browse the repository at this point in the history
Fixes #4.
  • Loading branch information
christiansandberg committed Nov 3, 2016
1 parent 7a1325c commit 0a1b0f7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions canopen/sdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ def download(self, index, subindex, data):
for pos in range(0, length, 7):
request[1:8] = data[pos:pos + 7]
if pos + 7 >= length:
# No more data after this message
request[0] |= 1
# Specify number of bytes in that do not contain segment data
request[0] |= (8 - len(request)) << 1
response = self.send_request(request.ljust(8, b'\x00'))
# Toggle bit for next request
request[0] ^= 0x10
if response[0] & 0xE0 != RESPONSE_SEGMENT_DOWNLOAD:
raise SdoCommunicationError("Unexpected response")
Expand Down

0 comments on commit 0a1b0f7

Please sign in to comment.