Skip to content

Commit

Permalink
Merge pull request #160 from danielhrisca/master
Browse files Browse the repository at this point in the history
fix cond_unlock for keys that do not fit in a single unlock message
  • Loading branch information
christoph2 committed Feb 29, 2024
2 parents 60a38cb + f6d68e2 commit 89add6b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.21.9
current_version = 0.21.10
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -34,7 +34,7 @@ dependencies = [
"traitlets>=5.9.0",
]
name = "pyxcp"
version = "0.21.9"
version = "0.21.10"
readme = "README.md"
description = "Universal Calibration Protocol for Python"
keywords = ["automotive", "ecu", "xcp", "asam", "autosar"]
Expand Down
2 changes: 1 addition & 1 deletion pyxcp/__init__.py
Expand Up @@ -25,4 +25,4 @@
from .transport import Usb

# if you update this manually, do not forget to update .bumpversion.cfg and pyproject.toml
__version__ = "0.21.9"
__version__ = "0.21.10"
18 changes: 9 additions & 9 deletions pyxcp/master/master.py
Expand Up @@ -1790,12 +1790,13 @@ def cond_unlock(self, resources=None):
length = result.length
if length == 0:
continue
if length > MAX_PAYLOAD:
remaining = length - len(seed)
while remaining > 0:
result = self.getSeed(types.XcpGetSeedMode.REMAINING, resource_value)
seed.extend(list(result.seed))
remaining = result.length

while length - len(seed) > 0:
result = self.getSeed(types.XcpGetSeedMode.REMAINING, resource_value)
seed.extend(list(result.seed))

seed = seed[: length] # maybe there are some padding bytes

result, key = getKey(
self.logger,
self.seedNKeyDLL,
Expand All @@ -1809,9 +1810,8 @@ def cond_unlock(self, resources=None):
offset = 0
while offset < total_length:
data = key[offset : offset + MAX_PAYLOAD]
key_length = len(data)
offset += key_length
self.unlock(key_length, data)
self.unlock(total_length-offset, data)
offset += len(data)
else:
raise SeedNKeyError("SeedAndKey DLL returned: {}".format(SeedNKeyResult(result).name))

Expand Down

0 comments on commit 89add6b

Please sign in to comment.