@@ -316,20 +316,21 @@ def read(self, size=-1):
316316 self .pos += length
317317 return response [1 :length + 1 ]
318318
319- def readinto (self , b ):
320- """
321- Read bytes into a pre-allocated, writable bytes-like object b,
322- and return the number of bytes read.
323- """
324- data = self .read (7 )
325- b [:len (data )] = data
326- return len (data )
319+ # For now not used, but if needed, a test is also required:
320+ # def readinto(self, b):
321+ # """
322+ # Read bytes into a pre-allocated, writable bytes-like object b,
323+ # and return the number of bytes read.
324+ # """
325+ # data = self.read(7)
326+ # b[:len(data)] = data
327+ # return len(data)
327328
328- def readable (self ):
329- return True
329+ # def readable(self):
330+ # return True
330331
331- def tell (self ):
332- return self .pos
332+ # def tell(self):
333+ # return self.pos
333334
334335
335336class WritableStream (io .RawIOBase ):
@@ -366,6 +367,7 @@ def __init__(self, sdo_client, index, subindex=0, size=None, force_segment=False
366367 response = sdo_client .request_response (request )
367368 res_command , = struct .unpack_from ("B" , response )
368369 if res_command != RESPONSE_DOWNLOAD :
370+ self ._done = True # prevent close() from sending a stray close segment
369371 self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
370372 raise SdoCommunicationError (
371373 f"Unexpected response 0x{ res_command :02X} " )
@@ -420,6 +422,7 @@ def write(self, b):
420422 response = self .sdo_client .request_response (request )
421423 res_command , = struct .unpack ("B" , response [0 :1 ])
422424 if res_command & 0xE0 != RESPONSE_SEGMENT_DOWNLOAD :
425+ self ._done = True # prevent close() from sending a stray close segment
423426 self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
424427 raise SdoCommunicationError (
425428 f"Unexpected response 0x{ res_command :02X} "
@@ -613,14 +616,15 @@ def close(self):
613616 def tell (self ):
614617 return self .pos
615618
616- def readinto (self , b ):
617- """
618- Read bytes into a pre-allocated, writable bytes-like object b,
619- and return the number of bytes read.
620- """
621- data = self .read (7 )
622- b [:len (data )] = data
623- return len (data )
619+ # For now not used, but if needed, a test is also required:
620+ # def readinto(self, b):
621+ # """
622+ # Read bytes into a pre-allocated, writable bytes-like object b,
623+ # and return the number of bytes read.
624+ # """
625+ # data = self.read(7)
626+ # b[:len(data)] = data
627+ # return len(data)
624628
625629 def readable (self ):
626630 return True
0 commit comments