@@ -96,11 +96,11 @@ def request_response(self, sdo_request):
9696 except SdoCommunicationError as e :
9797 retries_left -= 1
9898 if not retries_left :
99- self .abort (0x0504_0000 )
99+ self .abort (ABORT_TIMED_OUT )
100100 raise
101101 logger .warning (str (e ))
102102
103- def abort (self , abort_code = 0x0800_0000 ):
103+ def abort (self , abort_code = ABORT_GENERAL_ERROR ):
104104 """Abort current transfer."""
105105 request = bytearray (8 )
106106 request [0 ] = REQUEST_ABORTED
@@ -309,10 +309,10 @@ def read(self, size=-1):
309309 response = self .sdo_client .request_response (request )
310310 res_command , = struct .unpack_from ("B" , response )
311311 if res_command & 0xE0 != RESPONSE_SEGMENT_UPLOAD :
312- self .sdo_client .abort (0x0504_0001 )
312+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
313313 raise SdoCommunicationError (f"Unexpected response 0x{ res_command :02X} " )
314314 if res_command & TOGGLE_BIT != self ._toggle :
315- self .sdo_client .abort (0x0503_0000 )
315+ self .sdo_client .abort (ABORT_TOGGLE_NOT_ALTERNATED )
316316 raise SdoCommunicationError ("Toggle bit mismatch" )
317317 length = 7 - ((res_command >> 1 ) & 0x7 )
318318 if res_command & NO_MORE_DATA :
@@ -371,7 +371,7 @@ def __init__(self, sdo_client, index, subindex=0, size=None, force_segment=False
371371 response = sdo_client .request_response (request )
372372 res_command , = struct .unpack_from ("B" , response )
373373 if res_command != RESPONSE_DOWNLOAD :
374- self .sdo_client .abort (0x0504_0001 )
374+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
375375 raise SdoCommunicationError (
376376 f"Unexpected response 0x{ res_command :02X} " )
377377 else :
@@ -400,7 +400,7 @@ def write(self, b):
400400 response = self .sdo_client .request_response (request )
401401 res_command , = struct .unpack_from ("B" , response )
402402 if res_command & 0xE0 != RESPONSE_DOWNLOAD :
403- self .sdo_client .abort (0x0504_0001 )
403+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
404404 raise SdoCommunicationError (
405405 f"Unexpected response 0x{ res_command :02X} " )
406406 bytes_sent = len (b )
@@ -425,7 +425,7 @@ def write(self, b):
425425 response = self .sdo_client .request_response (request )
426426 res_command , = struct .unpack ("B" , response [0 :1 ])
427427 if res_command & 0xE0 != RESPONSE_SEGMENT_DOWNLOAD :
428- self .sdo_client .abort (0x0504_0001 )
428+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
429429 raise SdoCommunicationError (
430430 f"Unexpected response 0x{ res_command :02X} "
431431 f"(expected 0x{ RESPONSE_SEGMENT_DOWNLOAD :02X} )" )
@@ -499,7 +499,7 @@ def __init__(self, sdo_client, index, subindex=0, request_crc_support=True):
499499 res_command , res_index , res_subindex = SDO_STRUCT .unpack_from (response )
500500 if res_command & 0xE0 != RESPONSE_BLOCK_UPLOAD :
501501 self ._error = True
502- self .sdo_client .abort (0x0504_0001 )
502+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
503503 raise SdoCommunicationError (f"Unexpected response 0x{ res_command :02X} " )
504504 # Check that the message is for us
505505 if res_index != index or res_subindex != subindex :
@@ -556,7 +556,7 @@ def read(self, size=-1):
556556 if self ._done :
557557 if self ._server_crc != self ._crc .final ():
558558 self ._error = True
559- self .sdo_client .abort (0x0504_0004 )
559+ self .sdo_client .abort (ABORT_CRC_ERROR )
560560 raise SdoCommunicationError ("CRC is not OK" )
561561 logger .info ("CRC is OK" )
562562 self .pos += len (data )
@@ -576,7 +576,7 @@ def _retransmit(self):
576576 self ._ackseq = seqno
577577 return response
578578 self ._error = True
579- self .sdo_client .abort (0x0504_0000 )
579+ self .sdo_client .abort (ABORT_TIMED_OUT )
580580 raise SdoCommunicationError ("Some data was lost and could not be retransmitted" )
581581
582582 def _ack_block (self ):
@@ -591,16 +591,16 @@ def _end_upload(self):
591591 try :
592592 response = self .sdo_client .read_response ()
593593 except SdoCommunicationError :
594- self .abort (0x0504_0000 )
594+ self .abort (ABORT_TIMED_OUT )
595595 raise
596596 res_command , self ._server_crc = struct .unpack_from ("<BH" , response )
597597 if res_command & 0xE0 != RESPONSE_BLOCK_UPLOAD :
598598 self ._error = True
599- self .sdo_client .abort (0x0504_0001 )
599+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
600600 raise SdoCommunicationError (f"Unexpected response 0x{ res_command :02X} " )
601601 if res_command & 0x3 != END_BLOCK_TRANSFER :
602602 self ._error = True
603- self .sdo_client .abort (0x0504_0001 )
603+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
604604 raise SdoCommunicationError ("Server did not end transfer as expected" )
605605 # Return number of bytes not used in last message
606606 return (res_command >> 2 ) & 0x7
@@ -670,7 +670,7 @@ def __init__(self, sdo_client, index, subindex=0, size=None, request_crc_support
670670 response = sdo_client .request_response (request )
671671 res_command , res_index , res_subindex = SDO_STRUCT .unpack_from (response )
672672 if res_command & 0xE0 != RESPONSE_BLOCK_DOWNLOAD :
673- self .sdo_client .abort (0x0504_0001 )
673+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
674674 raise SdoCommunicationError (
675675 f"Unexpected response 0x{ res_command :02X} " )
676676 # Check that the message is for us
@@ -755,15 +755,15 @@ def _block_ack(self):
755755 try :
756756 response = self .sdo_client .read_response ()
757757 except SdoCommunicationError :
758- self .sdo_client .abort (0x0504_0000 )
758+ self .sdo_client .abort (ABORT_TIMED_OUT )
759759 raise
760760 res_command , ackseq , blksize = struct .unpack_from ("BBB" , response )
761761 if res_command & 0xE0 != RESPONSE_BLOCK_DOWNLOAD :
762- self .sdo_client .abort (0x0504_0001 )
762+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
763763 raise SdoCommunicationError (
764764 f"Unexpected response 0x{ res_command :02X} " )
765765 if res_command & 0x3 != BLOCK_TRANSFER_RESPONSE :
766- self .sdo_client .abort (0x0504_0001 )
766+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
767767 raise SdoCommunicationError ("Server did not respond with a "
768768 "block download response" )
769769 if ackseq != self ._blksize :
0 commit comments