Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions canopen/sdo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ def __init__(self, sdo_client, index, subindex=0, size=None, request_crc_support
self._blksize, = struct.unpack_from("B", response, 4)
logger.debug("Server requested a block size of %d", self._blksize)
self.crc_supported = bool(res_command & CRC_SUPPORTED)
# Run this last, used later to determine if initialization was successful
self._initialized = True

def write(self, b):
"""
Expand Down Expand Up @@ -784,6 +786,9 @@ def close(self):
if self.closed:
return
super(BlockDownloadStream, self).close()
if not getattr(self, "_initialized", False):
# Don't do finalization if initialization was not successful
return
if not self._done:
logger.error("Block transfer was not finished")
command = REQUEST_BLOCK_DOWNLOAD | END_BLOCK_TRANSFER
Expand Down
4 changes: 4 additions & 0 deletions canopen/sdo/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def request_aborted(self, data):

def block_download(self, data):
# We currently don't support BLOCK DOWNLOAD
# Unpack the index and subindex in order to send appropriate abort
command, index, subindex = SDO_STRUCT.unpack_from(data)
self._index = index
self._subindex = subindex
logger.error("Block download is not supported")
self.abort(0x05040001)

Expand Down
Loading