Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #87 from NordicSemiconductor/fix/serial-dfu-ping
Browse files Browse the repository at this point in the history
Fix potential issues with ping during serial DFU
  • Loading branch information
mrodem authored Sep 4, 2017
2 parents 9fb366e + 6149803 commit 9b2f8ff
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions nordicsemi/dfu/dfu_transport_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ def open(self):
raise NordicSemiException("Serial port could not be opened on {0}"
+ ". Reason: {1}".format(self.com_port, e.message))

if self.__ping() == False:
raise NordicSemiException("No ping response after opening COM port")

ping_success = False
start = datetime.now()
while datetime.now() - start < timedelta(seconds=self.timeout):
Expand Down Expand Up @@ -311,14 +308,17 @@ def __ping(self):
resp = self.dfu_adapter.get_message() # Receive raw reponse to check return code

if (resp == None):
raise NordicSemiException('No ping response')
logger.debug('Serial: No ping response')
return False

if resp[0] != DfuTransportSerial.OP_CODE['Response']:
raise NordicSemiException('No Response: 0x{:02X}'.format(resp[0]))
logger.debug('Serial: No Response: 0x{:02X}'.format(resp[0]))
return False

if resp[1] != DfuTransportSerial.OP_CODE['Ping']:
raise NordicSemiException('Unexpected Executed OP_CODE.\n' \
+ 'Expected: 0x{:02X} Received: 0x{:02X}'.format(operation, resp[1]))
logger.debug('Serial: Unexpected Executed OP_CODE.\n' \
+ 'Expected: 0x{:02X} Received: 0x{:02X}'.format(DfuTransportSerial.OP_CODE['Ping'], resp[1]))
return False

if resp[2] != DfuTransport.RES_CODE['Success']:
# Returning an error code is seen as good enough. The bootloader is up and running
Expand Down

0 comments on commit 9b2f8ff

Please sign in to comment.