Skip to content

Commit 0db1aee

Browse files
authored
Support alfid 64bits (#142)
* Modified ALFID to support 64bits addresses
1 parent 85fdb4e commit 0db1aee

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

test/client/test_security_access.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ def _test_send_key_wrongservice_exception(self):
201201
with self.assertRaises(UnexpectedResponseException) as handle:
202202
self.udsclient.send_key(0x06, b"\x11\x22\x33\x44")
203203

204-
def test_send_key_wrongservice_exception(self):
204+
def test_send_key_wrongservice_no_exception(self):
205205
self.wait_request_and_respond(b"\x7E\x00") # Valid but wrong service (Tester Present)
206206

207-
def _test_send_key_wrongservice_exception(self):
207+
def _test_send_key_wrongservice_no_exception(self):
208208
self.udsclient.config['exception_on_unexpected_response'] = False
209209
response = self.udsclient.send_key(0x06, b"\x11\x22\x33\x44")
210210
self.assertTrue(response.valid)

test/test_helper_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_ali_oob_values(self): # Out Of Bounds Value
2525
AddressAndLengthFormatIdentifier(memorysize_format=40, address_format=0)
2626

2727
with self.assertRaises(ValueError):
28-
AddressAndLengthFormatIdentifier(memorysize_format=8, address_format=48)
28+
AddressAndLengthFormatIdentifier(memorysize_format=8, address_format=65)
2929

3030
with self.assertRaises(ValueError):
3131
AddressAndLengthFormatIdentifier(memorysize_format='8', address_format=8)

udsoncan/__init__.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ class AddressAndLengthFormatIdentifier:
294294
This class defines how many bytes of a memorylocation, composed of an address and a memorysize, should be encoded when sent over the underlying protocol.
295295
Mainly used by :ref:`ReadMemoryByAddress<ReadMemoryByAddress>`, :ref:`WriteMemoryByAddress<WriteMemoryByAddress>`, :ref:`RequestDownload<RequestDownload>` and :ref:`RequestUpload<RequestUpload>` services
296296
297-
Defined by ISO-14229:2006, Annex G
297+
Defined by ISO-14229:2020, Annex H
298298
299-
:param address_format: The number of bits on which an address should be encoded. Possible values are 8, 16, 24, 32, 40
299+
:param address_format: The number of bits on which an address should be encoded. Possible values are 8, 16, 24, 32, 40, 48, 56, 64
300300
:type address_format: int
301301
302-
:param memorysize_format: The number of bits on which a memory size should be encoded. Possible values are 8, 16, 24, 32
302+
:param memorysize_format: The number of bits on which a memory size should be encoded. Possible values are 8, 16, 24, 32, 40, 48, 56, 64
303303
:type memorysize_format: int
304304
305305
"""
@@ -308,14 +308,21 @@ class AddressAndLengthFormatIdentifier:
308308
16 : 2,
309309
24 : 3,
310310
32 : 4,
311-
40 : 5
311+
40 : 5,
312+
48 : 6,
313+
56 : 7,
314+
64 : 8
312315
}
313316

314317
memsize_map = {
315-
8 : 1,
316-
16 : 2,
317-
24 : 3,
318-
32 : 4
318+
8 : 1,
319+
16 : 2,
320+
24 : 3,
321+
32 : 4,
322+
40 : 5,
323+
48 : 6,
324+
56 : 7,
325+
64 : 8
319326
}
320327

321328
def __init__(self, address_format, memorysize_format):
@@ -397,15 +404,15 @@ def set_format_if_none(self, address_format=None, memorysize_format=None):
397404
# Finds the smallest size that fits the address
398405
def autosize_address(self, val):
399406
fmt = math.ceil(val.bit_length()/8)*8
400-
if fmt > 40:
401-
raise ValueError("address size must be smaller or equal than 40 bits")
407+
if fmt > 64:
408+
raise ValueError("address size must be smaller or equal than 64 bits")
402409
return fmt
403410

404411
# Finds the smallest size that fits the memory size
405412
def autosize_memorysize(self, val):
406413
fmt = math.ceil(val.bit_length()/8)*8
407-
if fmt > 32:
408-
raise ValueError("memory size must be smaller or equal than 32 bits")
414+
if fmt > 64:
415+
raise ValueError("memory size must be smaller or equal than 64 bits")
409416
return fmt
410417

411418
# Gets the address byte in the requested format

0 commit comments

Comments
 (0)