-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatusCodeValues
More file actions
55 lines (48 loc) · 2.25 KB
/
Copy pathStatusCodeValues
File metadata and controls
55 lines (48 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def parse_and_convert(hex_string):
# Convert the hex string into bytes
hex_bytes = bytes.fromhex(hex_string)
# Parsing the values
local_ac_list_size = int.from_bytes(hex_bytes[0:2], 'big')
queue_count = int.from_bytes(hex_bytes[2:4], 'big')
retry_count = hex_bytes[4]
property_counter = hex_bytes[5]
ac_list_counter = hex_bytes[6]
firmware_counter = hex_bytes[7]
counter = hex_bytes[8]
kernel = hex_bytes[9]
application_version = hex_bytes[10]
sub_slave = hex_bytes[11]
xnode_major_firmware_version = hex_bytes[13]
xnode_minor_firmware_version = int.from_bytes(hex_bytes[14:16], 'big')
# Combine kernel and application version as reader firmware
reader_firmware = f"{kernel}.{application_version}"
# Combine XNode Major and Minor Firmware Version
xnode_firmware_version = f"{xnode_major_firmware_version}.{xnode_minor_firmware_version}"
# Convert sub-slave to firmware format
sub_slave_firmware = f"{(sub_slave >> 4)}.{(sub_slave & 0x0F)}"
# Determine authentication type based on XNode major firmware version
if xnode_major_firmware_version == 20:
auth_type = "Symmetric authentication only"
elif xnode_major_firmware_version == 22:
auth_type = "Symmetric and Asymmetric authentication"
elif xnode_major_firmware_version == 23:
auth_type = "Asymmetric authentication only (APL)"
elif xnode_major_firmware_version == 28:
auth_type = "Asymmetric Authentication (APL) and grant access regardless of permission (All ACCESS)"
else:
auth_type = "Unknown authentication type"
# Printing the results
print(f"Local AC List Size: {local_ac_list_size}")
print(f"Queue Count: {queue_count}")
print(f"Retry Count: {retry_count}")
print(f"Property Counter: {property_counter}")
print(f"AC List Counter: {ac_list_counter}")
print(f"Firmware Counter: {firmware_counter}")
print(f"Counter: {counter}")
print(f"Reader Firmware: {reader_firmware}")
print(f"Sub-Slave Firmware: {sub_slave_firmware}")
print(f"XNode Firmware Version: {xnode_firmware_version}")
print(f"Authentication Type: {auth_type}")
# Example hex string
demo_hex = "000900000102020300040121901C00DD"
parse_and_convert(demo_hex)