@@ -96,11 +96,11 @@ def request_response(self, sdo_request):
96
96
except SdoCommunicationError as e :
97
97
retries_left -= 1
98
98
if not retries_left :
99
- self .abort (0x0504_0000 )
99
+ self .abort (ABORT_TIMED_OUT )
100
100
raise
101
101
logger .warning (str (e ))
102
102
103
- def abort (self , abort_code = 0x0800_0000 ):
103
+ def abort (self , abort_code = ABORT_GENERAL_ERROR ):
104
104
"""Abort current transfer."""
105
105
request = bytearray (8 )
106
106
request [0 ] = REQUEST_ABORTED
@@ -309,10 +309,10 @@ def read(self, size=-1):
309
309
response = self .sdo_client .request_response (request )
310
310
res_command , = struct .unpack_from ("B" , response )
311
311
if res_command & 0xE0 != RESPONSE_SEGMENT_UPLOAD :
312
- self .sdo_client .abort (0x0504_0001 )
312
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
313
313
raise SdoCommunicationError (f"Unexpected response 0x{ res_command :02X} " )
314
314
if res_command & TOGGLE_BIT != self ._toggle :
315
- self .sdo_client .abort (0x0503_0000 )
315
+ self .sdo_client .abort (ABORT_TOGGLE_NOT_ALTERNATED )
316
316
raise SdoCommunicationError ("Toggle bit mismatch" )
317
317
length = 7 - ((res_command >> 1 ) & 0x7 )
318
318
if res_command & NO_MORE_DATA :
@@ -371,7 +371,7 @@ def __init__(self, sdo_client, index, subindex=0, size=None, force_segment=False
371
371
response = sdo_client .request_response (request )
372
372
res_command , = struct .unpack_from ("B" , response )
373
373
if res_command != RESPONSE_DOWNLOAD :
374
- self .sdo_client .abort (0x0504_0001 )
374
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
375
375
raise SdoCommunicationError (
376
376
f"Unexpected response 0x{ res_command :02X} " )
377
377
else :
@@ -400,7 +400,7 @@ def write(self, b):
400
400
response = self .sdo_client .request_response (request )
401
401
res_command , = struct .unpack_from ("B" , response )
402
402
if res_command & 0xE0 != RESPONSE_DOWNLOAD :
403
- self .sdo_client .abort (0x0504_0001 )
403
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
404
404
raise SdoCommunicationError (
405
405
f"Unexpected response 0x{ res_command :02X} " )
406
406
bytes_sent = len (b )
@@ -425,7 +425,7 @@ def write(self, b):
425
425
response = self .sdo_client .request_response (request )
426
426
res_command , = struct .unpack ("B" , response [0 :1 ])
427
427
if res_command & 0xE0 != RESPONSE_SEGMENT_DOWNLOAD :
428
- self .sdo_client .abort (0x0504_0001 )
428
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
429
429
raise SdoCommunicationError (
430
430
f"Unexpected response 0x{ res_command :02X} "
431
431
f"(expected 0x{ RESPONSE_SEGMENT_DOWNLOAD :02X} )" )
@@ -499,7 +499,7 @@ def __init__(self, sdo_client, index, subindex=0, request_crc_support=True):
499
499
res_command , res_index , res_subindex = SDO_STRUCT .unpack_from (response )
500
500
if res_command & 0xE0 != RESPONSE_BLOCK_UPLOAD :
501
501
self ._error = True
502
- self .sdo_client .abort (0x0504_0001 )
502
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
503
503
raise SdoCommunicationError (f"Unexpected response 0x{ res_command :02X} " )
504
504
# Check that the message is for us
505
505
if res_index != index or res_subindex != subindex :
@@ -556,7 +556,7 @@ def read(self, size=-1):
556
556
if self ._done :
557
557
if self ._server_crc != self ._crc .final ():
558
558
self ._error = True
559
- self .sdo_client .abort (0x0504_0004 )
559
+ self .sdo_client .abort (ABORT_CRC_ERROR )
560
560
raise SdoCommunicationError ("CRC is not OK" )
561
561
logger .info ("CRC is OK" )
562
562
self .pos += len (data )
@@ -576,7 +576,7 @@ def _retransmit(self):
576
576
self ._ackseq = seqno
577
577
return response
578
578
self ._error = True
579
- self .sdo_client .abort (0x0504_0000 )
579
+ self .sdo_client .abort (ABORT_TIMED_OUT )
580
580
raise SdoCommunicationError ("Some data was lost and could not be retransmitted" )
581
581
582
582
def _ack_block (self ):
@@ -591,16 +591,16 @@ def _end_upload(self):
591
591
try :
592
592
response = self .sdo_client .read_response ()
593
593
except SdoCommunicationError :
594
- self .abort (0x0504_0000 )
594
+ self .abort (ABORT_TIMED_OUT )
595
595
raise
596
596
res_command , self ._server_crc = struct .unpack_from ("<BH" , response )
597
597
if res_command & 0xE0 != RESPONSE_BLOCK_UPLOAD :
598
598
self ._error = True
599
- self .sdo_client .abort (0x0504_0001 )
599
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
600
600
raise SdoCommunicationError (f"Unexpected response 0x{ res_command :02X} " )
601
601
if res_command & 0x3 != END_BLOCK_TRANSFER :
602
602
self ._error = True
603
- self .sdo_client .abort (0x0504_0001 )
603
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
604
604
raise SdoCommunicationError ("Server did not end transfer as expected" )
605
605
# Return number of bytes not used in last message
606
606
return (res_command >> 2 ) & 0x7
@@ -670,7 +670,7 @@ def __init__(self, sdo_client, index, subindex=0, size=None, request_crc_support
670
670
response = sdo_client .request_response (request )
671
671
res_command , res_index , res_subindex = SDO_STRUCT .unpack_from (response )
672
672
if res_command & 0xE0 != RESPONSE_BLOCK_DOWNLOAD :
673
- self .sdo_client .abort (0x0504_0001 )
673
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
674
674
raise SdoCommunicationError (
675
675
f"Unexpected response 0x{ res_command :02X} " )
676
676
# Check that the message is for us
@@ -755,15 +755,15 @@ def _block_ack(self):
755
755
try :
756
756
response = self .sdo_client .read_response ()
757
757
except SdoCommunicationError :
758
- self .sdo_client .abort (0x0504_0000 )
758
+ self .sdo_client .abort (ABORT_TIMED_OUT )
759
759
raise
760
760
res_command , ackseq , blksize = struct .unpack_from ("BBB" , response )
761
761
if res_command & 0xE0 != RESPONSE_BLOCK_DOWNLOAD :
762
- self .sdo_client .abort (0x0504_0001 )
762
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
763
763
raise SdoCommunicationError (
764
764
f"Unexpected response 0x{ res_command :02X} " )
765
765
if res_command & 0x3 != BLOCK_TRANSFER_RESPONSE :
766
- self .sdo_client .abort (0x0504_0001 )
766
+ self .sdo_client .abort (ABORT_INVALID_COMMAND_SPECIFIER )
767
767
raise SdoCommunicationError ("Server did not respond with a "
768
768
"block download response" )
769
769
if ackseq != self ._blksize :
0 commit comments