pyxcp 0.25.0__cp313-cp313-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyxcp might be problematic. Click here for more details.
- pyxcp/__init__.py +20 -0
- pyxcp/aml/EtasCANMonitoring.a2l +82 -0
- pyxcp/aml/EtasCANMonitoring.aml +67 -0
- pyxcp/aml/XCP_Common.aml +408 -0
- pyxcp/aml/XCPonCAN.aml +78 -0
- pyxcp/aml/XCPonEth.aml +33 -0
- pyxcp/aml/XCPonFlx.aml +113 -0
- pyxcp/aml/XCPonSxI.aml +66 -0
- pyxcp/aml/XCPonUSB.aml +106 -0
- pyxcp/aml/ifdata_CAN.a2l +20 -0
- pyxcp/aml/ifdata_Eth.a2l +11 -0
- pyxcp/aml/ifdata_Flx.a2l +94 -0
- pyxcp/aml/ifdata_SxI.a2l +13 -0
- pyxcp/aml/ifdata_USB.a2l +81 -0
- pyxcp/asam/__init__.py +0 -0
- pyxcp/asam/types.py +131 -0
- pyxcp/asamkeydll.c +116 -0
- pyxcp/asamkeydll.exe +0 -0
- pyxcp/asamkeydll.sh +2 -0
- pyxcp/checksum.py +732 -0
- pyxcp/cmdline.py +84 -0
- pyxcp/config/__init__.py +1257 -0
- pyxcp/config/legacy.py +120 -0
- pyxcp/constants.py +47 -0
- pyxcp/cpp_ext/__init__.py +0 -0
- pyxcp/cpp_ext/aligned_buffer.hpp +168 -0
- pyxcp/cpp_ext/bin.hpp +105 -0
- pyxcp/cpp_ext/blockmem.hpp +58 -0
- pyxcp/cpp_ext/cpp_ext.cp310-win_arm64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp311-win_arm64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp312-win_arm64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp313-win_arm64.pyd +0 -0
- pyxcp/cpp_ext/daqlist.hpp +374 -0
- pyxcp/cpp_ext/event.hpp +67 -0
- pyxcp/cpp_ext/extension_wrapper.cpp +131 -0
- pyxcp/cpp_ext/framing.hpp +360 -0
- pyxcp/cpp_ext/helper.hpp +280 -0
- pyxcp/cpp_ext/mcobject.hpp +248 -0
- pyxcp/cpp_ext/sxi_framing.hpp +332 -0
- pyxcp/cpp_ext/tsqueue.hpp +46 -0
- pyxcp/daq_stim/__init__.py +306 -0
- pyxcp/daq_stim/optimize/__init__.py +67 -0
- pyxcp/daq_stim/optimize/binpacking.py +41 -0
- pyxcp/daq_stim/scheduler.cpp +62 -0
- pyxcp/daq_stim/scheduler.hpp +75 -0
- pyxcp/daq_stim/stim.cp310-win_arm64.pyd +0 -0
- pyxcp/daq_stim/stim.cp311-win_arm64.pyd +0 -0
- pyxcp/daq_stim/stim.cp312-win_arm64.pyd +0 -0
- pyxcp/daq_stim/stim.cp313-win_arm64.pyd +0 -0
- pyxcp/daq_stim/stim.cpp +13 -0
- pyxcp/daq_stim/stim.hpp +604 -0
- pyxcp/daq_stim/stim_wrapper.cpp +50 -0
- pyxcp/dllif.py +100 -0
- pyxcp/errormatrix.py +878 -0
- pyxcp/examples/conf_can.toml +19 -0
- pyxcp/examples/conf_can_user.toml +16 -0
- pyxcp/examples/conf_can_vector.json +11 -0
- pyxcp/examples/conf_can_vector.toml +11 -0
- pyxcp/examples/conf_eth.toml +9 -0
- pyxcp/examples/conf_nixnet.json +20 -0
- pyxcp/examples/conf_socket_can.toml +12 -0
- pyxcp/examples/run_daq.py +165 -0
- pyxcp/examples/xcp_policy.py +60 -0
- pyxcp/examples/xcp_read_benchmark.py +38 -0
- pyxcp/examples/xcp_skel.py +49 -0
- pyxcp/examples/xcp_unlock.py +38 -0
- pyxcp/examples/xcp_user_supplied_driver.py +44 -0
- pyxcp/examples/xcphello.py +78 -0
- pyxcp/examples/xcphello_recorder.py +107 -0
- pyxcp/master/__init__.py +9 -0
- pyxcp/master/errorhandler.py +677 -0
- pyxcp/master/master.py +2641 -0
- pyxcp/py.typed +0 -0
- pyxcp/recorder/.idea/.gitignore +8 -0
- pyxcp/recorder/.idea/misc.xml +4 -0
- pyxcp/recorder/.idea/modules.xml +8 -0
- pyxcp/recorder/.idea/recorder.iml +6 -0
- pyxcp/recorder/.idea/sonarlint/issuestore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +7 -0
- pyxcp/recorder/.idea/sonarlint/issuestore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
- pyxcp/recorder/.idea/sonarlint/issuestore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
- pyxcp/recorder/.idea/sonarlint/issuestore/index.pb +7 -0
- pyxcp/recorder/.idea/sonarlint/securityhotspotstore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +0 -0
- pyxcp/recorder/.idea/sonarlint/securityhotspotstore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
- pyxcp/recorder/.idea/sonarlint/securityhotspotstore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
- pyxcp/recorder/.idea/sonarlint/securityhotspotstore/index.pb +7 -0
- pyxcp/recorder/.idea/vcs.xml +10 -0
- pyxcp/recorder/__init__.py +96 -0
- pyxcp/recorder/build_clang.cmd +1 -0
- pyxcp/recorder/build_clang.sh +2 -0
- pyxcp/recorder/build_gcc.cmd +1 -0
- pyxcp/recorder/build_gcc.sh +2 -0
- pyxcp/recorder/build_gcc_arm.sh +2 -0
- pyxcp/recorder/converter/__init__.py +450 -0
- pyxcp/recorder/lz4.c +2829 -0
- pyxcp/recorder/lz4.h +879 -0
- pyxcp/recorder/lz4hc.c +2041 -0
- pyxcp/recorder/lz4hc.h +413 -0
- pyxcp/recorder/mio.hpp +1714 -0
- pyxcp/recorder/reader.hpp +138 -0
- pyxcp/recorder/reco.py +277 -0
- pyxcp/recorder/recorder.rst +0 -0
- pyxcp/recorder/rekorder.cp310-win_arm64.pyd +0 -0
- pyxcp/recorder/rekorder.cp311-win_arm64.pyd +0 -0
- pyxcp/recorder/rekorder.cp312-win_arm64.pyd +0 -0
- pyxcp/recorder/rekorder.cp313-win_arm64.pyd +0 -0
- pyxcp/recorder/rekorder.cpp +59 -0
- pyxcp/recorder/rekorder.hpp +274 -0
- pyxcp/recorder/setup.py +41 -0
- pyxcp/recorder/test_reko.py +34 -0
- pyxcp/recorder/unfolder.hpp +1354 -0
- pyxcp/recorder/wrap.cpp +184 -0
- pyxcp/recorder/writer.hpp +302 -0
- pyxcp/scripts/__init__.py +0 -0
- pyxcp/scripts/pyxcp_probe_can_drivers.py +20 -0
- pyxcp/scripts/xcp_examples.py +64 -0
- pyxcp/scripts/xcp_fetch_a2l.py +40 -0
- pyxcp/scripts/xcp_id_scanner.py +19 -0
- pyxcp/scripts/xcp_info.py +144 -0
- pyxcp/scripts/xcp_profile.py +27 -0
- pyxcp/scripts/xmraw_converter.py +31 -0
- pyxcp/stim/__init__.py +0 -0
- pyxcp/tests/test_asam_types.py +24 -0
- pyxcp/tests/test_binpacking.py +186 -0
- pyxcp/tests/test_can.py +1324 -0
- pyxcp/tests/test_checksum.py +95 -0
- pyxcp/tests/test_daq.py +193 -0
- pyxcp/tests/test_daq_opt.py +426 -0
- pyxcp/tests/test_frame_padding.py +156 -0
- pyxcp/tests/test_framing.py +262 -0
- pyxcp/tests/test_master.py +2117 -0
- pyxcp/tests/test_transport.py +178 -0
- pyxcp/tests/test_utils.py +30 -0
- pyxcp/timing.py +60 -0
- pyxcp/transport/__init__.py +13 -0
- pyxcp/transport/base.py +484 -0
- pyxcp/transport/base_transport.hpp +0 -0
- pyxcp/transport/can.py +660 -0
- pyxcp/transport/eth.py +254 -0
- pyxcp/transport/sxi.py +209 -0
- pyxcp/transport/transport_ext.hpp +214 -0
- pyxcp/transport/transport_wrapper.cpp +244 -0
- pyxcp/transport/usb_transport.py +229 -0
- pyxcp/types.py +987 -0
- pyxcp/utils.py +128 -0
- pyxcp/vector/__init__.py +0 -0
- pyxcp/vector/map.py +82 -0
- pyxcp-0.25.0.dist-info/METADATA +341 -0
- pyxcp-0.25.0.dist-info/RECORD +151 -0
- pyxcp-0.25.0.dist-info/WHEEL +4 -0
- pyxcp-0.25.0.dist-info/entry_points.txt +9 -0
- pyxcp-0.25.0.dist-info/licenses/LICENSE +165 -0
pyxcp/dllif.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
import binascii
|
|
3
|
+
import ctypes
|
|
4
|
+
import enum
|
|
5
|
+
import platform
|
|
6
|
+
import re
|
|
7
|
+
import subprocess # nosec
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SeedNKeyResult(enum.IntEnum):
|
|
13
|
+
ACK = 0 # o.k.
|
|
14
|
+
ERR_PRIVILEGE_NOT_AVAILABLE = 1 # the requested privilege can not be unlocked with this DLL
|
|
15
|
+
ERR_INVALID_SEED_LENGTH = 2 # the seed length is wrong, key could not be computed
|
|
16
|
+
ERR_UNSUFFICIENT_KEY_LENGTH = 3 # the space for the key is too small
|
|
17
|
+
|
|
18
|
+
ERR_COULD_NOT_LOAD_DLL = 16
|
|
19
|
+
ERR_COULD_NOT_LOAD_FUNC = 17
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class SeedNKeyError(Exception):
|
|
23
|
+
""""""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
LOADER = Path(str(sys.modules["pyxcp"].__file__)).parent / "asamkeydll" # Absolute path to DLL loader.
|
|
27
|
+
|
|
28
|
+
bwidth, _ = platform.architecture()
|
|
29
|
+
|
|
30
|
+
if sys.platform in ("win32", "linux", "darwin"):
|
|
31
|
+
if bwidth == "64bit":
|
|
32
|
+
use_ctypes = False
|
|
33
|
+
elif bwidth == "32bit":
|
|
34
|
+
use_ctypes = True
|
|
35
|
+
else:
|
|
36
|
+
raise RuntimeError(f"Platform {sys.platform!r} currently not supported.")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def getKey(logger, loader_cfg: str, dllName: str, privilege: int, seed: bytes, assume_same_bit_width: bool):
|
|
40
|
+
dllName = str(Path(dllName).absolute()) # Fix loader issues.
|
|
41
|
+
|
|
42
|
+
if loader_cfg is not None:
|
|
43
|
+
loader_exe = loader_cfg
|
|
44
|
+
else:
|
|
45
|
+
loader_exe = LOADER
|
|
46
|
+
|
|
47
|
+
use_ctypes: bool = False
|
|
48
|
+
if assume_same_bit_width:
|
|
49
|
+
use_ctypes = True
|
|
50
|
+
if use_ctypes:
|
|
51
|
+
try:
|
|
52
|
+
lib: ctypes.CDLL = ctypes.cdll.LoadLibrary(dllName)
|
|
53
|
+
except OSError:
|
|
54
|
+
logger.error(f"Could not load DLL {dllName!r} -- Probably an 64bit vs 32bit issue?")
|
|
55
|
+
return (SeedNKeyResult.ERR_COULD_NOT_LOAD_DLL, None)
|
|
56
|
+
func = lib.XCP_ComputeKeyFromSeed
|
|
57
|
+
func.restype = ctypes.c_uint32
|
|
58
|
+
func.argtypes = [
|
|
59
|
+
ctypes.c_uint8,
|
|
60
|
+
ctypes.c_uint8,
|
|
61
|
+
ctypes.c_char_p,
|
|
62
|
+
ctypes.POINTER(ctypes.c_uint8),
|
|
63
|
+
ctypes.c_char_p,
|
|
64
|
+
]
|
|
65
|
+
key_buffer: ctypes.Array[ctypes.c_char] = ctypes.create_string_buffer(b"\000" * 128)
|
|
66
|
+
key_length: ctypes.c_uint8 = ctypes.c_uint8(128)
|
|
67
|
+
ret_code: int = func(
|
|
68
|
+
privilege,
|
|
69
|
+
len(seed),
|
|
70
|
+
ctypes.c_char_p(seed),
|
|
71
|
+
ctypes.byref(key_length),
|
|
72
|
+
key_buffer,
|
|
73
|
+
)
|
|
74
|
+
return (ret_code, key_buffer.raw[0 : key_length.value])
|
|
75
|
+
else:
|
|
76
|
+
try:
|
|
77
|
+
p0 = subprocess.Popen(
|
|
78
|
+
[loader_exe, dllName, str(privilege), binascii.hexlify(seed).decode("ascii")],
|
|
79
|
+
stdout=subprocess.PIPE,
|
|
80
|
+
shell=False,
|
|
81
|
+
) # nosec
|
|
82
|
+
except FileNotFoundError as exc:
|
|
83
|
+
logger.error(f"Could not find executable {loader_exe!r} -- {exc}")
|
|
84
|
+
return (SeedNKeyResult.ERR_COULD_NOT_LOAD_DLL, None)
|
|
85
|
+
except OSError as exc:
|
|
86
|
+
logger.error(f"Cannot execute {loader_exe!r} -- {exc}")
|
|
87
|
+
return (SeedNKeyResult.ERR_COULD_NOT_LOAD_DLL, None)
|
|
88
|
+
key: bytes = b""
|
|
89
|
+
if p0.stdout:
|
|
90
|
+
key = p0.stdout.read()
|
|
91
|
+
p0.stdout.close()
|
|
92
|
+
p0.kill()
|
|
93
|
+
p0.wait()
|
|
94
|
+
if not key:
|
|
95
|
+
logger.error(f"Something went wrong while calling seed-and-key-DLL {dllName!r}")
|
|
96
|
+
return (SeedNKeyResult.ERR_COULD_NOT_LOAD_DLL, None)
|
|
97
|
+
res = re.split(b"\r?\n", key)
|
|
98
|
+
returnCode = int(res[0])
|
|
99
|
+
key = binascii.unhexlify(res[1])
|
|
100
|
+
return (returnCode, key)
|