pyxcp 0.25.4__cp313-cp313-win_amd64.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.
Files changed (157) hide show
  1. pyxcp/__init__.py +20 -0
  2. pyxcp/aml/EtasCANMonitoring.a2l +82 -0
  3. pyxcp/aml/EtasCANMonitoring.aml +67 -0
  4. pyxcp/aml/XCP_Common.aml +408 -0
  5. pyxcp/aml/XCPonCAN.aml +78 -0
  6. pyxcp/aml/XCPonEth.aml +33 -0
  7. pyxcp/aml/XCPonFlx.aml +113 -0
  8. pyxcp/aml/XCPonSxI.aml +66 -0
  9. pyxcp/aml/XCPonUSB.aml +106 -0
  10. pyxcp/aml/ifdata_CAN.a2l +20 -0
  11. pyxcp/aml/ifdata_Eth.a2l +11 -0
  12. pyxcp/aml/ifdata_Flx.a2l +94 -0
  13. pyxcp/aml/ifdata_SxI.a2l +13 -0
  14. pyxcp/aml/ifdata_USB.a2l +81 -0
  15. pyxcp/asam/__init__.py +0 -0
  16. pyxcp/asam/types.py +131 -0
  17. pyxcp/asamkeydll.c +116 -0
  18. pyxcp/asamkeydll.exe +0 -0
  19. pyxcp/asamkeydll.sh +2 -0
  20. pyxcp/checksum.py +732 -0
  21. pyxcp/cmdline.py +71 -0
  22. pyxcp/config/__init__.py +1257 -0
  23. pyxcp/config/legacy.py +120 -0
  24. pyxcp/constants.py +47 -0
  25. pyxcp/cpp_ext/__init__.py +0 -0
  26. pyxcp/cpp_ext/aligned_buffer.hpp +168 -0
  27. pyxcp/cpp_ext/bin.hpp +105 -0
  28. pyxcp/cpp_ext/blockmem.hpp +58 -0
  29. pyxcp/cpp_ext/cpp_ext.cp310-win_amd64.pyd +0 -0
  30. pyxcp/cpp_ext/cpp_ext.cp311-win_amd64.pyd +0 -0
  31. pyxcp/cpp_ext/cpp_ext.cp312-win_amd64.pyd +0 -0
  32. pyxcp/cpp_ext/cpp_ext.cp313-win_amd64.pyd +0 -0
  33. pyxcp/cpp_ext/daqlist.hpp +374 -0
  34. pyxcp/cpp_ext/event.hpp +67 -0
  35. pyxcp/cpp_ext/extension_wrapper.cpp +131 -0
  36. pyxcp/cpp_ext/framing.hpp +360 -0
  37. pyxcp/cpp_ext/helper.hpp +280 -0
  38. pyxcp/cpp_ext/mcobject.hpp +248 -0
  39. pyxcp/cpp_ext/sxi_framing.hpp +332 -0
  40. pyxcp/cpp_ext/tsqueue.hpp +46 -0
  41. pyxcp/daq_stim/__init__.py +291 -0
  42. pyxcp/daq_stim/optimize/__init__.py +67 -0
  43. pyxcp/daq_stim/optimize/binpacking.py +41 -0
  44. pyxcp/daq_stim/scheduler.cpp +62 -0
  45. pyxcp/daq_stim/scheduler.hpp +75 -0
  46. pyxcp/daq_stim/stim.cp310-win_amd64.pyd +0 -0
  47. pyxcp/daq_stim/stim.cp311-win_amd64.pyd +0 -0
  48. pyxcp/daq_stim/stim.cp312-win_amd64.pyd +0 -0
  49. pyxcp/daq_stim/stim.cp313-win_amd64.pyd +0 -0
  50. pyxcp/daq_stim/stim.cpp +13 -0
  51. pyxcp/daq_stim/stim.hpp +604 -0
  52. pyxcp/daq_stim/stim_wrapper.cpp +50 -0
  53. pyxcp/dllif.py +100 -0
  54. pyxcp/errormatrix.py +878 -0
  55. pyxcp/examples/conf_can.toml +19 -0
  56. pyxcp/examples/conf_can_user.toml +16 -0
  57. pyxcp/examples/conf_can_vector.json +11 -0
  58. pyxcp/examples/conf_can_vector.toml +11 -0
  59. pyxcp/examples/conf_eth.toml +9 -0
  60. pyxcp/examples/conf_nixnet.json +20 -0
  61. pyxcp/examples/conf_socket_can.toml +12 -0
  62. pyxcp/examples/run_daq.py +165 -0
  63. pyxcp/examples/xcp_policy.py +60 -0
  64. pyxcp/examples/xcp_read_benchmark.py +38 -0
  65. pyxcp/examples/xcp_skel.py +48 -0
  66. pyxcp/examples/xcp_unlock.py +36 -0
  67. pyxcp/examples/xcp_user_supplied_driver.py +43 -0
  68. pyxcp/examples/xcphello.py +65 -0
  69. pyxcp/examples/xcphello_recorder.py +107 -0
  70. pyxcp/master/__init__.py +10 -0
  71. pyxcp/master/errorhandler.py +677 -0
  72. pyxcp/master/master.py +2641 -0
  73. pyxcp/py.typed +0 -0
  74. pyxcp/recorder/.idea/.gitignore +8 -0
  75. pyxcp/recorder/.idea/misc.xml +4 -0
  76. pyxcp/recorder/.idea/modules.xml +8 -0
  77. pyxcp/recorder/.idea/recorder.iml +6 -0
  78. pyxcp/recorder/.idea/sonarlint/issuestore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +7 -0
  79. pyxcp/recorder/.idea/sonarlint/issuestore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
  80. pyxcp/recorder/.idea/sonarlint/issuestore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
  81. pyxcp/recorder/.idea/sonarlint/issuestore/index.pb +7 -0
  82. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +0 -0
  83. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
  84. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
  85. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/index.pb +7 -0
  86. pyxcp/recorder/.idea/vcs.xml +10 -0
  87. pyxcp/recorder/__init__.py +96 -0
  88. pyxcp/recorder/build_clang.cmd +1 -0
  89. pyxcp/recorder/build_clang.sh +2 -0
  90. pyxcp/recorder/build_gcc.cmd +1 -0
  91. pyxcp/recorder/build_gcc.sh +2 -0
  92. pyxcp/recorder/build_gcc_arm.sh +2 -0
  93. pyxcp/recorder/converter/__init__.py +444 -0
  94. pyxcp/recorder/lz4.c +2829 -0
  95. pyxcp/recorder/lz4.h +879 -0
  96. pyxcp/recorder/lz4hc.c +2041 -0
  97. pyxcp/recorder/lz4hc.h +413 -0
  98. pyxcp/recorder/mio.hpp +1714 -0
  99. pyxcp/recorder/reader.hpp +138 -0
  100. pyxcp/recorder/reco.py +278 -0
  101. pyxcp/recorder/recorder.rst +0 -0
  102. pyxcp/recorder/rekorder.cp310-win_amd64.pyd +0 -0
  103. pyxcp/recorder/rekorder.cp311-win_amd64.pyd +0 -0
  104. pyxcp/recorder/rekorder.cp312-win_amd64.pyd +0 -0
  105. pyxcp/recorder/rekorder.cp313-win_amd64.pyd +0 -0
  106. pyxcp/recorder/rekorder.cpp +59 -0
  107. pyxcp/recorder/rekorder.hpp +274 -0
  108. pyxcp/recorder/setup.py +41 -0
  109. pyxcp/recorder/test_reko.py +34 -0
  110. pyxcp/recorder/unfolder.hpp +1354 -0
  111. pyxcp/recorder/wrap.cpp +184 -0
  112. pyxcp/recorder/writer.hpp +302 -0
  113. pyxcp/scripts/__init__.py +0 -0
  114. pyxcp/scripts/pyxcp_probe_can_drivers.py +20 -0
  115. pyxcp/scripts/xcp_examples.py +64 -0
  116. pyxcp/scripts/xcp_fetch_a2l.py +40 -0
  117. pyxcp/scripts/xcp_id_scanner.py +18 -0
  118. pyxcp/scripts/xcp_info.py +159 -0
  119. pyxcp/scripts/xcp_profile.py +26 -0
  120. pyxcp/scripts/xmraw_converter.py +31 -0
  121. pyxcp/stim/__init__.py +0 -0
  122. pyxcp/tests/test_asam_types.py +24 -0
  123. pyxcp/tests/test_binpacking.py +186 -0
  124. pyxcp/tests/test_can.py +1324 -0
  125. pyxcp/tests/test_checksum.py +95 -0
  126. pyxcp/tests/test_daq.py +193 -0
  127. pyxcp/tests/test_daq_opt.py +426 -0
  128. pyxcp/tests/test_frame_padding.py +156 -0
  129. pyxcp/tests/test_framing.py +262 -0
  130. pyxcp/tests/test_master.py +2116 -0
  131. pyxcp/tests/test_transport.py +177 -0
  132. pyxcp/tests/test_utils.py +30 -0
  133. pyxcp/timing.py +60 -0
  134. pyxcp/transport/__init__.py +13 -0
  135. pyxcp/transport/base.py +484 -0
  136. pyxcp/transport/base_transport.hpp +0 -0
  137. pyxcp/transport/can.py +660 -0
  138. pyxcp/transport/eth.py +254 -0
  139. pyxcp/transport/hdf5_policy.py +129 -0
  140. pyxcp/transport/sxi.py +209 -0
  141. pyxcp/transport/transport_ext.cp310-win_amd64.pyd +0 -0
  142. pyxcp/transport/transport_ext.cp311-win_amd64.pyd +0 -0
  143. pyxcp/transport/transport_ext.cp312-win_amd64.pyd +0 -0
  144. pyxcp/transport/transport_ext.cp313-win_amd64.pyd +0 -0
  145. pyxcp/transport/transport_ext.hpp +214 -0
  146. pyxcp/transport/transport_wrapper.cpp +249 -0
  147. pyxcp/transport/usb_transport.py +229 -0
  148. pyxcp/types.py +987 -0
  149. pyxcp/utils/__init__.py +127 -0
  150. pyxcp/utils/cli.py +78 -0
  151. pyxcp/vector/__init__.py +0 -0
  152. pyxcp/vector/map.py +82 -0
  153. pyxcp-0.25.4.dist-info/METADATA +341 -0
  154. pyxcp-0.25.4.dist-info/RECORD +157 -0
  155. pyxcp-0.25.4.dist-info/WHEEL +4 -0
  156. pyxcp-0.25.4.dist-info/entry_points.txt +9 -0
  157. pyxcp-0.25.4.dist-info/licenses/LICENSE +165 -0
@@ -0,0 +1,19 @@
1
+ TRANSPORT = "CAN"
2
+ CAN_DRIVER = "KVaser"
3
+ CAN_USE_DEFAULT_LISTENER = true
4
+ CHANNEL = "0"
5
+ ACCEPT_VIRTUAL = true
6
+ CAN_ID_MASTER = 257
7
+ CAN_ID_SLAVE = 258
8
+ CAN_ID_BROADCAST = 256
9
+ MAX_DLC_REQUIRED = false
10
+ BITRATE = 50000
11
+ DATA_BITRATE = 50000
12
+ FD=false
13
+ BTL_CYCLES = 16
14
+ SAMPLE_RATE = 1
15
+ SAMPLE_POINT = 87.5
16
+ SJW = 2
17
+ TSEG1 = 5
18
+ TSEG2 = 2
19
+ CREATE_DAQ_TIMESTAMPS = false
@@ -0,0 +1,16 @@
1
+ TRANSPORT = "CAN"
2
+ CAN_DRIVER = "MyCI"
3
+ CAN_USE_DEFAULT_LISTENER = true
4
+ CHANNEL = "0"
5
+ CAN_ID_MASTER = 257
6
+ CAN_ID_SLAVE = 258
7
+ CAN_ID_BROADCAST = 256
8
+ MAX_DLC_REQUIRED = false
9
+ BITRATE = 250000
10
+ BTL_CYCLES = 16
11
+ SAMPLE_RATE = 1
12
+ SAMPLE_POINT = 87.5
13
+ SJW = 2
14
+ TSEG1 = 5
15
+ TSEG2 = 2
16
+ CREATE_DAQ_TIMESTAMPS = false
@@ -0,0 +1,11 @@
1
+ {
2
+ "TRANSPORT": "CAN",
3
+ "CAN_DRIVER": "Vector",
4
+ "CAN_USE_DEFAULT_LISTENER": true,
5
+ "CHANNEL": "1",
6
+ "CAN_ID_MASTER": 2,
7
+ "CAN_ID_SLAVE": 1,
8
+ "CAN_ID_BROADCAST": 256,
9
+ "MAX_DLC_REQUIRED": false,
10
+ "CREATE_DAQ_TIMESTAMPS": false
11
+ }
@@ -0,0 +1,11 @@
1
+ TRANSPORT = "CAN"
2
+ CAN_DRIVER = "Vector"
3
+ CAN_USE_DEFAULT_LISTENER = true
4
+ CHANNEL = "0"
5
+ CAN_ID_MASTER = 2
6
+ CAN_ID_SLAVE = 1
7
+ CAN_ID_BROADCAST = 256
8
+ # MAX_DLC_REQUIRED = true
9
+ CREATE_DAQ_TIMESTAMPS = false
10
+ BITRATE=1000000
11
+ SEED_N_KEY_DLL = "SeedNKeyXcp.dll"
@@ -0,0 +1,9 @@
1
+ TRANSPORT = "ETH"
2
+ #HOST = "192.168.197.40"
3
+ #HOST = "192.168.198.175"
4
+ HOST="localhost"
5
+ PORT = 5555
6
+ PROTOCOL = "UDP"
7
+ IPV6 = false
8
+ CREATE_DAQ_TIMESTAMPS = true
9
+ SEED_N_KEY_DLL="SeedNKeyXcp.dll"
@@ -0,0 +1,20 @@
1
+ {
2
+ "TRANSPORT": "CAN",
3
+ "CAN_DRIVER": "NiXnet",
4
+ "CAN_USE_DEFAULT_LISTENER": true,
5
+ "CHANNEL": "CAN4",
6
+ "ACCEPT_VIRTUAL": true,
7
+ "BAUDRATE_PRESET": true,
8
+ "CAN_ID_MASTER": 1911,
9
+ "CAN_ID_SLAVE": 819,
10
+ "CAN_ID_BROADCAST": 256,
11
+ "MAX_DLC_REQUIRED": false,
12
+ "BITRATE": 500000,
13
+ "BTL_CYCLES": 16,
14
+ "SAMPLE_RATE": 1,
15
+ "SAMPLE_POINT": 87.5,
16
+ "SJW": 2,
17
+ "TSEG1": 5,
18
+ "TSEG2": 2,
19
+ "CREATE_DAQ_TIMESTAMPS": false
20
+ }
@@ -0,0 +1,12 @@
1
+ TRANSPORT = "CAN"
2
+ CAN_DRIVER = "SocketCAN"
3
+ CAN_USE_DEFAULT_LISTENER = true
4
+ CHANNEL = "can0"
5
+ CAN_ID_MASTER = 257
6
+ CAN_ID_SLAVE = 258
7
+ CAN_ID_BROADCAST = 256
8
+ CREATE_DAQ_TIMESTAMPS = false
9
+ FD = false
10
+ MAX_DLC_REQUIRED = true
11
+ MAX_CAN_FD_DLC = 32
12
+ PADDING_VALUE = 0
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env python
2
+
3
+ import sys
4
+ import time
5
+
6
+ from pyxcp.cmdline import ArgumentParser
7
+ from pyxcp.daq_stim import DaqList, DaqRecorder, DaqToCsv # noqa: F401
8
+ from pyxcp.types import XcpTimeoutError
9
+
10
+
11
+ ap = ArgumentParser(description="DAQ test")
12
+
13
+ XCP_LITE = False
14
+
15
+ #
16
+ # NOTE: UPDATE TO CORRECT ADDRESSES BEFORE RUNNING!!!
17
+ #
18
+ if XCP_LITE:
19
+ # Vectorgrp XCPlite.
20
+ DAQ_LISTS = [
21
+ DaqList(
22
+ name="part_1",
23
+ event_num=0,
24
+ stim=False,
25
+ enable_timestamps=False,
26
+ measurements=[
27
+ ("byteCounter", 0x00023648, 0, "U8"),
28
+ ("wordCounter", 0x0002364C, 0, "U16"),
29
+ ("dwordCounter", 0x00023650, 0, "U32"),
30
+ ("sbyteCounter", 0x00023649, 0, "I8"),
31
+ ],
32
+ priority=0,
33
+ prescaler=1,
34
+ ),
35
+ DaqList(
36
+ name="part_2",
37
+ event_num=7,
38
+ stim=False,
39
+ enable_timestamps=False,
40
+ measurements=[
41
+ ("swordCounter", 0x00023654, 0, "I16"),
42
+ ("sdwordCounter", 0x00023658, 0, "I32"),
43
+ ("channel1", 0x00023630, 0, "F64"),
44
+ ("channel2", 0x00023638, 0, "F64"),
45
+ ("channel3", 0x00023640, 0, "F64"),
46
+ ],
47
+ priority=0,
48
+ prescaler=1,
49
+ ),
50
+ ]
51
+ else:
52
+ # XCPsim from CANape.
53
+ DAQ_LISTS = [
54
+ DaqList(
55
+ name="pwm_stuff",
56
+ event_num=2,
57
+ stim=False,
58
+ enable_timestamps=True,
59
+ measurements=[
60
+ ("channel1", 0x1BD004, 0, "F32"),
61
+ ("period", 0x001C0028, 0, "F32"),
62
+ ("channel2", 0x1BD008, 0, "F32"),
63
+ ("PWMFiltered", 0x1BDDE2, 0, "U8"),
64
+ ("PWM", 0x1BDDDF, 0, "U8"),
65
+ ("Triangle", 0x1BDDDE, 0, "I8"),
66
+ ],
67
+ priority=0,
68
+ prescaler=1,
69
+ ),
70
+ DaqList(
71
+ name="bytes",
72
+ event_num=1,
73
+ stim=False,
74
+ enable_timestamps=True,
75
+ measurements=[
76
+ ("TestByte_000", 0x1BE11C, 0, "U8"),
77
+ ("TestByte_015", 0x1BE158, 0, "U8"),
78
+ ("TestByte_016", 0x1BE15C, 0, "U8"),
79
+ ("TestByte_023", 0x1BE178, 0, "U8"),
80
+ ("TestByte_024", 0x1BE17C, 0, "U8"),
81
+ ("TestByte_034", 0x1BE1A4, 0, "U8"),
82
+ ("TestByte_059", 0x1BE208, 0, "U8"),
83
+ ("TestByte_061", 0x1BE210, 0, "U8"),
84
+ ("TestByte_063", 0x1BE218, 0, "U8"),
85
+ ("TestByte_064", 0x1BE21C, 0, "U8"),
86
+ ("TestByte_097", 0x1BE2A0, 0, "U8"),
87
+ ("TestByte_107", 0x1BE2C8, 0, "U8"),
88
+ ("TestByte_131", 0x1BE328, 0, "U8"),
89
+ ("TestByte_156", 0x1BE38C, 0, "U8"),
90
+ ("TestByte_159", 0x1BE398, 0, "U8"),
91
+ ("TestByte_182", 0x1BE3F4, 0, "U8"),
92
+ ("TestByte_183", 0x1BE3F8, 0, "U8"),
93
+ ("TestByte_189", 0x1BE410, 0, "U8"),
94
+ ("TestByte_195", 0x1BE428, 0, "U8"),
95
+ ("TestByte_216", 0x1BE47C, 0, "U8"),
96
+ ("TestByte_218", 0x1BE484, 0, "U8"),
97
+ ("TestByte_221", 0x1BE490, 0, "U8"),
98
+ ("TestByte_251", 0x1BE508, 0, "U8"),
99
+ ("TestByte_263", 0x1BE538, 0, "U8"),
100
+ ("TestByte_276", 0x1BE56C, 0, "U8"),
101
+ ("TestByte_277", 0x1BE570, 0, "U8"),
102
+ ("TestByte_297", 0x1BE5C0, 0, "U8"),
103
+ ("TestByte_302", 0x1BE5D4, 0, "U8"),
104
+ ("TestByte_324", 0x1BE62C, 0, "U8"),
105
+ ("TestByte_344", 0x1BE67C, 0, "U8"),
106
+ ("TestByte_346", 0x1BE684, 0, "U8"),
107
+ ],
108
+ priority=0,
109
+ prescaler=1,
110
+ ),
111
+ DaqList(
112
+ name="words",
113
+ event_num=3,
114
+ stim=False,
115
+ enable_timestamps=True,
116
+ measurements=[
117
+ ("TestWord_001", 0x1BE120, 0, "U16"),
118
+ ("TestWord_003", 0x1BE128, 0, "U16"),
119
+ ("TestWord_004", 0x1BE12C, 0, "U16"),
120
+ ("TestWord_005", 0x1BE134, 0, "U16"),
121
+ ("TestWord_006", 0x1BE134, 0, "U16"),
122
+ ("TestWord_007", 0x1BE138, 0, "U16"),
123
+ ("TestWord_008", 0x1BE13C, 0, "U16"),
124
+ ("TestWord_009", 0x1BE140, 0, "U16"),
125
+ ("TestWord_011", 0x1BE148, 0, "U16"),
126
+ ],
127
+ priority=0,
128
+ prescaler=1,
129
+ ),
130
+ ]
131
+
132
+
133
+ # daq_parser = DaqToCsv(DAQ_LISTS) # Record to CSV file(s).
134
+ daq_parser = DaqRecorder(DAQ_LISTS, "run_daq_21092025_01", 8) # Record to ".xmraw" file.
135
+
136
+ with ap.run(policy=daq_parser) as x:
137
+ try:
138
+ x.connect()
139
+ except XcpTimeoutError:
140
+ print("TO")
141
+ sys.exit(2)
142
+
143
+ if x.slaveProperties.optionalCommMode:
144
+ x.getCommModeInfo()
145
+
146
+ x.cond_unlock("DAQ") # DAQ resource is locked in many cases.
147
+
148
+ print("setup DAQ lists.")
149
+ daq_parser.setup() # Execute setup procedures.
150
+ print("start DAQ lists.")
151
+ daq_parser.start() # Start DAQ lists.
152
+
153
+ # time.sleep(2.0 * 60.0)
154
+ time.sleep(0.25 * 60.0 * 60.0) # Run for 15 minutes.
155
+
156
+ print("Stop DAQ....")
157
+ daq_parser.stop() # Stop DAQ lists.
158
+ print("finalize DAQ lists.\n")
159
+ x.disconnect()
160
+
161
+ if hasattr(daq_parser, "files"): # `files` attribute is specific to `DaqToCsv`.
162
+ print("Data written to:")
163
+ print("================")
164
+ for fl in daq_parser.files.values():
165
+ print(fl.name)
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env python
2
+ """Demostrates how to use frame recording policies including recorder extension."""
3
+
4
+ from pprint import pprint
5
+
6
+ from pyxcp.cmdline import ArgumentParser
7
+ from pyxcp.transport.base import FrameRecorderPolicy, StdoutPolicy # noqa: F401
8
+
9
+
10
+ ap = ArgumentParser(description="pyXCP frame recording policy example.")
11
+
12
+ LOG_FILE = "pyxcp"
13
+
14
+ # policy = FrameRecorderPolicy(LOG_FILE)
15
+ # use_recorder = True
16
+
17
+ policy = StdoutPolicy() # You may also try this one.
18
+ use_recorder = False
19
+
20
+ with ap.run(policy=policy) as x:
21
+ x.connect()
22
+ if x.slaveProperties.optionalCommMode:
23
+ x.getCommModeInfo()
24
+ identifier = x.identifier(0x01)
25
+ print("\nSlave Properties:")
26
+ print("=================")
27
+ print(f"ID: {identifier!r}")
28
+ pprint(x.slaveProperties)
29
+ x.disconnect()
30
+
31
+ if use_recorder:
32
+ from pyxcp.recorder import XcpLogFileReader
33
+ from pyxcp.utils import hexDump
34
+
35
+ try:
36
+ import pandas # noqa: F401
37
+ except ImportError:
38
+ has_pandas = False
39
+ else:
40
+ has_pandas = True
41
+
42
+ reader = XcpLogFileReader(LOG_FILE)
43
+ hdr = reader.get_header() # Get file information.
44
+ print("\nRecording file header")
45
+ print("=====================\n")
46
+ print(hdr)
47
+ print("\nRecorded frames")
48
+ print("===============\n")
49
+ print("CAT CTR TS PAYLOAD")
50
+ print("-" * 80)
51
+ for category, counter, timestamp, payload in reader:
52
+ print(f"{category.name:8} {counter:6} {timestamp:7.7f} {hexDump(payload)}")
53
+ print("-" * 80)
54
+ reader.reset_iter() # reader acts as an Python iterator -- can be reseted with this non-standard method.
55
+ if has_pandas:
56
+ print("\nRecordings as Pandas stuff")
57
+ print("==========================\n")
58
+ df = reader.as_dataframe() # Return recordings as Pandas DataFrame.
59
+ print(df.info())
60
+ print(df.head(60))
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env python
2
+ """Very basic hello-world example."""
3
+
4
+ import time
5
+
6
+ import matplotlib.pyplot as plt
7
+ import seaborn as sns
8
+
9
+ from pyxcp.cmdline import ArgumentParser
10
+ from pyxcp.transport import FrameRecorderPolicy
11
+
12
+
13
+ sns.set()
14
+
15
+
16
+ ADDR = 0x4000
17
+ LENGTH = 0x1000
18
+ ITERATIONS = 100
19
+
20
+ recorder_policy = FrameRecorderPolicy() # Create frame recorder.
21
+ ap = ArgumentParser(description="pyXCP hello world.", policy=recorder_policy)
22
+ with ap.run() as x:
23
+ xs = []
24
+ ys = []
25
+ x.connect()
26
+ for ctoSize in range(8, 64 + 4, 4):
27
+ print(f"CTO-Size: {ctoSize}")
28
+ xs.append(ctoSize)
29
+ start = time.perf_counter()
30
+ for _ in range(ITERATIONS):
31
+ x.setMta(ADDR)
32
+ data = x.fetch(LENGTH, ctoSize)
33
+ et = time.perf_counter() - start
34
+ ys.append(et)
35
+ print(f"CTO size: {ctoSize:-3} -- elapsed time {et:-3.04}")
36
+ x.disconnect()
37
+ plt.plot(xs, ys)
38
+ plt.show()
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env python
2
+ """Use this as a copy-and-paste template for your own scripts."""
3
+
4
+ from pyxcp.cmdline import ArgumentParser
5
+
6
+
7
+ def callout(master, args):
8
+ if args.sk_dll:
9
+ master.seedNKeyDLL = args.sk_dll
10
+
11
+
12
+ ap = ArgumentParser(description="pyXCP skeleton.", callout=callout)
13
+
14
+ # Add command-line option for seed-and-key DLL.
15
+ ap.parser.add_argument(
16
+ "-s",
17
+ "--sk-dll",
18
+ dest="sk_dll",
19
+ help="Seed-and-Key .DLL name",
20
+ type=str,
21
+ default=None,
22
+ )
23
+
24
+ with ap.run() as x:
25
+ x.connect()
26
+ if x.slaveProperties.optionalCommMode:
27
+ # Collect additional properties.
28
+ x.getCommModeInfo()
29
+
30
+ # getId() is not strictly required.
31
+ slave_name = x.identifier(0x01)
32
+
33
+ # Unlock resources, if necessary.
34
+ # Could be more specific, like cond_unlock("DAQ")
35
+ # Note: Unlocking requires a seed-and-key DLL.
36
+ x.cond_unlock()
37
+
38
+ ##
39
+ # Your own code goes here.
40
+ ##
41
+
42
+ x.disconnect()
43
+
44
+ # Print some useful information.
45
+ # print("\nSlave properties:")
46
+ # print("=================")
47
+ # print("ID: '{}'".format(slave_name.decode("utf8")))
48
+ # pprint(x.slaveProperties)
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env python
2
+ """Very basic hello-world example."""
3
+
4
+ import argparse
5
+
6
+ from pyxcp.cmdline import ArgumentParser
7
+
8
+
9
+ parser = argparse.ArgumentParser(description="XCP unlock example")
10
+ parser.add_argument(
11
+ "-s",
12
+ "--sk-dll",
13
+ dest="sk_dll",
14
+ help="Seed-and-Key .DLL name",
15
+ type=str,
16
+ default=None,
17
+ )
18
+
19
+ ap = ArgumentParser(parser)
20
+
21
+ with ap.run() as x:
22
+ if ap.args.sk_dll:
23
+ x.seedNKeyDLL = ap.args.sk_dll
24
+
25
+ x.connect()
26
+
27
+ print("")
28
+ rps = x.getCurrentProtectionStatus()
29
+ print("Protection before unlocking:", rps, end="\n\n")
30
+
31
+ x.cond_unlock()
32
+
33
+ rps = x.getCurrentProtectionStatus()
34
+ print("Protection after unlocking:", rps)
35
+
36
+ x.disconnect()
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env python
2
+
3
+ from typing import Optional
4
+
5
+ import can
6
+
7
+ from pyxcp.cmdline import ArgumentParser
8
+ from pyxcp.transport.can import CanInterfaceBase
9
+
10
+
11
+ class CustomCANInterface(CanInterfaceBase):
12
+ def init(self):
13
+ """Initialize the CAN interface here."""
14
+
15
+ def set_filters(self, filters):
16
+ print(f"set_filters({filters})")
17
+ self._filters = filters
18
+
19
+ def recv(self, timeout: Optional[float] = None) -> Optional[can.message.Message]:
20
+ """Receive CAN frames."""
21
+ return can.message.Message()
22
+
23
+ def send(self, msg: can.message.Message):
24
+ """Send CAN frames."""
25
+ print(f"send({msg})")
26
+
27
+ @property
28
+ def filters(self):
29
+ """Return the current CAN filters."""
30
+ return self._filters
31
+
32
+ @property
33
+ def state(self):
34
+ """Return the current state of the CAN interface."""
35
+ return can.BusState.ACTIVE
36
+
37
+
38
+ custom_interface = CustomCANInterface()
39
+
40
+ ap = ArgumentParser(description="User supplied CAN driver.")
41
+ with ap.run(transport_layer_interface=custom_interface) as x:
42
+ x.connect()
43
+ x.disconnect()
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env python
2
+ """Very basic hello-world example."""
3
+
4
+ from pprint import pprint
5
+
6
+ from pyxcp.cmdline import ArgumentParser
7
+ from pyxcp.utils import decode_bytes
8
+
9
+
10
+ daq_info = False
11
+
12
+
13
+ ap = ArgumentParser(description="pyXCP hello world.")
14
+
15
+ with ap.run() as x:
16
+ x.connect()
17
+ if x.slaveProperties.optionalCommMode:
18
+ x.getCommModeInfo()
19
+ identifier = x.identifier(0x01)
20
+ print("\nSlave Properties:")
21
+ print("=================")
22
+ print(f"ID: {identifier!r}")
23
+ pprint(x.slaveProperties)
24
+ x.cond_unlock()
25
+ cps = x.getCurrentProtectionStatus()
26
+ print("\nProtection Status")
27
+ print("=================")
28
+ for k, v in cps.items():
29
+ print(f" {k:6s}: {v}")
30
+ daq = x.getDaqInfo()
31
+ pprint(daq)
32
+ if daq_info:
33
+ dqp = x.getDaqProcessorInfo()
34
+ print("\nDAQ Processor Info:")
35
+ print("===================")
36
+ print(dqp)
37
+ print("\nDAQ Events:")
38
+ print("===========")
39
+ for idx in range(dqp.maxEventChannel):
40
+ evt = x.getDaqEventInfo(idx)
41
+ length = evt.eventChannelNameLength
42
+ name = decode_bytes(x.pull(length))
43
+ dq = "DAQ" if evt.daqEventProperties.daq else ""
44
+ st = "STIM" if evt.daqEventProperties.stim else ""
45
+ dq_st = dq + " " + st
46
+ print(f" [{idx:04}] {name:r}")
47
+ print(f" dir: {dq_st}")
48
+ print(f" packed: {evt.daqEventProperties.packed}")
49
+ PFX_CONS = "CONSISTENCY_"
50
+ print(f" consistency: {evt.daqEventProperties.consistency.strip(PFX_CONS)}")
51
+ print(f" max. DAQ lists: {evt.maxDaqList}")
52
+ PFX_TU = "EVENT_CHANNEL_TIME_UNIT_"
53
+ print(f" unit: {evt.eventChannelTimeUnit.strip(PFX_TU)}")
54
+ print(f" cycle: {evt.eventChannelTimeCycle or 'SPORADIC'}")
55
+ print(f" priority {evt.eventChannelPriority}")
56
+
57
+ dqr = x.getDaqResolutionInfo()
58
+ print("\nDAQ Resolution Info:")
59
+ print("====================")
60
+ print(dqr)
61
+ for idx in range(dqp.maxDaq):
62
+ print(f"\nDAQ List Info #{idx}")
63
+ print("=================")
64
+ print(f"{x.getDaqListInfo(idx)}")
65
+ x.disconnect()
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env python
2
+ """Very basic hello-world example."""
3
+
4
+ from pprint import pprint
5
+
6
+ from pyxcp.cmdline import ArgumentParser
7
+ from pyxcp.recorder import XcpLogFileReader
8
+ from pyxcp.transport import FrameRecorderPolicy
9
+ from pyxcp.utils import decode_bytes
10
+
11
+
12
+ daq_info = False
13
+
14
+
15
+ def callout(master, args):
16
+ global daq_info
17
+ if args.daq_info:
18
+ daq_info = True
19
+
20
+
21
+ ap = ArgumentParser(description="pyXCP hello world.", callout=callout)
22
+ ap.parser.add_argument(
23
+ "-d",
24
+ "--daq-info",
25
+ dest="daq_info",
26
+ help="Display DAQ-info",
27
+ default=False,
28
+ action="store_true",
29
+ )
30
+
31
+ RECORDER_FILE_NAME = "xcphello"
32
+
33
+ recorder_policy = FrameRecorderPolicy(RECORDER_FILE_NAME) # Create frame recorder.
34
+
35
+ with ap.run(recorder_policy) as x: # parameter policy is new.
36
+ x.connect()
37
+ if x.slaveProperties.optionalCommMode:
38
+ x.getCommModeInfo()
39
+ identifier = x.identifier(0x01)
40
+ print("\nSlave Properties:")
41
+ print("=================")
42
+ print(f"ID: {identifier!r}")
43
+ pprint(x.slaveProperties)
44
+ cps = x.getCurrentProtectionStatus()
45
+ print("\nProtection Status")
46
+ print("=================")
47
+ for k, v in cps.items():
48
+ print(f" {k:6s}: {v}")
49
+ if daq_info:
50
+ dqp = x.getDaqProcessorInfo()
51
+ print("\nDAQ Processor Info:")
52
+ print("===================")
53
+ print(dqp)
54
+ print("\nDAQ Events:")
55
+ print("===========")
56
+ for idx in range(dqp.maxEventChannel):
57
+ evt = x.getDaqEventInfo(idx)
58
+ length = evt.eventChannelNameLength
59
+ name = decode_bytes(x.pull(length))
60
+ dq = "DAQ" if evt.daqEventProperties.daq else ""
61
+ st = "STIM" if evt.daqEventProperties.stim else ""
62
+ dq_st = dq + " " + st
63
+ print(f" [{idx:04}] {name:r}")
64
+ print(f" dir: {dq_st}")
65
+ print(f" packed: {evt.daqEventProperties.packed}")
66
+ PFX_CONS = "CONSISTENCY_"
67
+ print(f" consistency: {evt.daqEventProperties.consistency.strip(PFX_CONS)}")
68
+ print(f" max. DAQ lists: {evt.maxDaqList}")
69
+ PFX_TU = "EVENT_CHANNEL_TIME_UNIT_"
70
+ print(f" unit: {evt.eventChannelTimeUnit.strip(PFX_TU)}")
71
+ print(f" cycle: {evt.eventChannelTimeCycle or 'SPORADIC'}")
72
+ print(f" priority {evt.eventChannelPriority}")
73
+
74
+ dqr = x.getDaqResolutionInfo()
75
+ print("\nDAQ Resolution Info:")
76
+ print("====================")
77
+ print(dqr)
78
+ for idx in range(dqp.maxDaq):
79
+ print(f"\nDAQ List Info #{idx}")
80
+ print("=================")
81
+ print(f"{x.getDaqListInfo(idx)}")
82
+ x.disconnect()
83
+ print("After recording...")
84
+ ##
85
+ ## Now read and dump recorded frames.
86
+ ##
87
+ reader = XcpLogFileReader(RECORDER_FILE_NAME)
88
+
89
+ hdr = reader.get_header() # Get file information.
90
+ print("\n\n")
91
+ print("=" * 82)
92
+ pprint(hdr)
93
+ print("=" * 82)
94
+
95
+ print("\nIterating over frames")
96
+ print("=" * 82)
97
+ for _frame in reader:
98
+ print(_frame)
99
+ print("---")
100
+
101
+ reader.reset_iter() # Non-standard method to restart iteration.
102
+
103
+ df = reader.as_dataframe() # Return recordings as Pandas DataFrame.
104
+ print("\nRecording as Pandas DataFrame")
105
+ print("=" * 82)
106
+ print(df.head(24))
107
+ print("=" * 82)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env python
2
+ """Lowlevel API reflecting available XCP services
3
+
4
+ .. note:: For technical reasons the API is split into two parts;
5
+ common methods and a Python version specific part.
6
+
7
+ .. [1] XCP Specification, Part 2 - Protocol Layer Specification
8
+ """
9
+
10
+ from .master import Master # noqa: F401