Skip to content

Commit

Permalink
JLINKARM_BeginDownload is void, not int. (#181)
Browse files Browse the repository at this point in the history
Reading a return value results in a nonsensical value and frequently an
invalid exception.
  • Loading branch information
cpattenden-sq authored Jul 28, 2023
1 parent f98d7e2 commit 4364eb9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
4 changes: 1 addition & 3 deletions pylink/jlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -2194,9 +2194,7 @@ def flash(self, data, addr, on_progress=None, power_on=False, flags=0):
pass

# Perform read-modify-write operation.
res = self._dll.JLINKARM_BeginDownload(flags=flags)
if res < 0:
raise errors.JLinkEraseException(res)
self._dll.JLINKARM_BeginDownload(flags=flags)

if isinstance(data, list):
data = bytes(data)
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/test_jlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -2724,14 +2724,7 @@ def test_jlink_flash_fail_to_flash(self):
self.jlink.halted = mock.Mock()
self.jlink.halted.return_value = True

# BeginDownload failing
self.dll.JLINKARM_BeginDownload.return_value = -1
self.dll.JLINKARM_EndDownload.return_value = 0
with self.assertRaises(JLinkException):
self.jlink.flash([0], 0)

# EndDownload failing
self.dll.JLINKARM_BeginDownload.return_value = 0
self.dll.JLINKARM_EndDownload.return_value = -1
with self.assertRaises(JLinkException):
self.jlink.flash([0], 0)
Expand All @@ -2745,7 +2738,6 @@ def test_jlink_flash_success(self):
Returns:
``None``
"""
self.dll.JLINKARM_BeginDownload.return_value = 0
self.dll.JLINKARM_WriteMem.return_value = 0
self.dll.JLINKARM_EndDownload.return_value = 0

Expand Down

0 comments on commit 4364eb9

Please sign in to comment.