pyxcp 0.25.1__cp314-cp314-macosx_11_0_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.
Files changed (154) 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 +0 -0
  18. pyxcp/asamkeydll.c +116 -0
  19. pyxcp/asamkeydll.sh +2 -0
  20. pyxcp/checksum.py +732 -0
  21. pyxcp/cmdline.py +84 -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.cpython-310-darwin.so +0 -0
  30. pyxcp/cpp_ext/cpp_ext.cpython-311-darwin.so +0 -0
  31. pyxcp/cpp_ext/cpp_ext.cpython-312-darwin.so +0 -0
  32. pyxcp/cpp_ext/cpp_ext.cpython-313-darwin.so +0 -0
  33. pyxcp/cpp_ext/cpp_ext.cpython-314-darwin.so +0 -0
  34. pyxcp/cpp_ext/daqlist.hpp +374 -0
  35. pyxcp/cpp_ext/event.hpp +67 -0
  36. pyxcp/cpp_ext/extension_wrapper.cpp +131 -0
  37. pyxcp/cpp_ext/framing.hpp +360 -0
  38. pyxcp/cpp_ext/helper.hpp +280 -0
  39. pyxcp/cpp_ext/mcobject.hpp +248 -0
  40. pyxcp/cpp_ext/sxi_framing.hpp +332 -0
  41. pyxcp/cpp_ext/tsqueue.hpp +46 -0
  42. pyxcp/daq_stim/__init__.py +306 -0
  43. pyxcp/daq_stim/optimize/__init__.py +67 -0
  44. pyxcp/daq_stim/optimize/binpacking.py +41 -0
  45. pyxcp/daq_stim/scheduler.cpp +62 -0
  46. pyxcp/daq_stim/scheduler.hpp +75 -0
  47. pyxcp/daq_stim/stim.cpp +13 -0
  48. pyxcp/daq_stim/stim.cpython-310-darwin.so +0 -0
  49. pyxcp/daq_stim/stim.cpython-311-darwin.so +0 -0
  50. pyxcp/daq_stim/stim.cpython-312-darwin.so +0 -0
  51. pyxcp/daq_stim/stim.cpython-313-darwin.so +0 -0
  52. pyxcp/daq_stim/stim.cpython-314-darwin.so +0 -0
  53. pyxcp/daq_stim/stim.hpp +604 -0
  54. pyxcp/daq_stim/stim_wrapper.cpp +50 -0
  55. pyxcp/dllif.py +100 -0
  56. pyxcp/errormatrix.py +878 -0
  57. pyxcp/examples/conf_can.toml +19 -0
  58. pyxcp/examples/conf_can_user.toml +16 -0
  59. pyxcp/examples/conf_can_vector.json +11 -0
  60. pyxcp/examples/conf_can_vector.toml +11 -0
  61. pyxcp/examples/conf_eth.toml +9 -0
  62. pyxcp/examples/conf_nixnet.json +20 -0
  63. pyxcp/examples/conf_socket_can.toml +12 -0
  64. pyxcp/examples/run_daq.py +165 -0
  65. pyxcp/examples/xcp_policy.py +60 -0
  66. pyxcp/examples/xcp_read_benchmark.py +38 -0
  67. pyxcp/examples/xcp_skel.py +49 -0
  68. pyxcp/examples/xcp_unlock.py +38 -0
  69. pyxcp/examples/xcp_user_supplied_driver.py +44 -0
  70. pyxcp/examples/xcphello.py +78 -0
  71. pyxcp/examples/xcphello_recorder.py +107 -0
  72. pyxcp/master/__init__.py +9 -0
  73. pyxcp/master/errorhandler.py +677 -0
  74. pyxcp/master/master.py +2641 -0
  75. pyxcp/py.typed +0 -0
  76. pyxcp/recorder/.idea/.gitignore +8 -0
  77. pyxcp/recorder/.idea/misc.xml +4 -0
  78. pyxcp/recorder/.idea/modules.xml +8 -0
  79. pyxcp/recorder/.idea/recorder.iml +6 -0
  80. pyxcp/recorder/.idea/sonarlint/issuestore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +7 -0
  81. pyxcp/recorder/.idea/sonarlint/issuestore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
  82. pyxcp/recorder/.idea/sonarlint/issuestore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
  83. pyxcp/recorder/.idea/sonarlint/issuestore/index.pb +7 -0
  84. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +0 -0
  85. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
  86. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
  87. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/index.pb +7 -0
  88. pyxcp/recorder/.idea/vcs.xml +10 -0
  89. pyxcp/recorder/__init__.py +96 -0
  90. pyxcp/recorder/build_clang.cmd +1 -0
  91. pyxcp/recorder/build_clang.sh +2 -0
  92. pyxcp/recorder/build_gcc.cmd +1 -0
  93. pyxcp/recorder/build_gcc.sh +2 -0
  94. pyxcp/recorder/build_gcc_arm.sh +2 -0
  95. pyxcp/recorder/converter/__init__.py +450 -0
  96. pyxcp/recorder/lz4.c +2829 -0
  97. pyxcp/recorder/lz4.h +879 -0
  98. pyxcp/recorder/lz4hc.c +2041 -0
  99. pyxcp/recorder/lz4hc.h +413 -0
  100. pyxcp/recorder/mio.hpp +1714 -0
  101. pyxcp/recorder/reader.hpp +138 -0
  102. pyxcp/recorder/reco.py +277 -0
  103. pyxcp/recorder/recorder.rst +0 -0
  104. pyxcp/recorder/rekorder.cpp +59 -0
  105. pyxcp/recorder/rekorder.cpython-310-darwin.so +0 -0
  106. pyxcp/recorder/rekorder.cpython-311-darwin.so +0 -0
  107. pyxcp/recorder/rekorder.cpython-312-darwin.so +0 -0
  108. pyxcp/recorder/rekorder.cpython-313-darwin.so +0 -0
  109. pyxcp/recorder/rekorder.cpython-314-darwin.so +0 -0
  110. pyxcp/recorder/rekorder.hpp +274 -0
  111. pyxcp/recorder/setup.py +41 -0
  112. pyxcp/recorder/test_reko.py +34 -0
  113. pyxcp/recorder/unfolder.hpp +1354 -0
  114. pyxcp/recorder/wrap.cpp +184 -0
  115. pyxcp/recorder/writer.hpp +302 -0
  116. pyxcp/scripts/__init__.py +0 -0
  117. pyxcp/scripts/pyxcp_probe_can_drivers.py +20 -0
  118. pyxcp/scripts/xcp_examples.py +64 -0
  119. pyxcp/scripts/xcp_fetch_a2l.py +40 -0
  120. pyxcp/scripts/xcp_id_scanner.py +19 -0
  121. pyxcp/scripts/xcp_info.py +144 -0
  122. pyxcp/scripts/xcp_profile.py +27 -0
  123. pyxcp/scripts/xmraw_converter.py +31 -0
  124. pyxcp/stim/__init__.py +0 -0
  125. pyxcp/tests/test_asam_types.py +24 -0
  126. pyxcp/tests/test_binpacking.py +186 -0
  127. pyxcp/tests/test_can.py +1324 -0
  128. pyxcp/tests/test_checksum.py +95 -0
  129. pyxcp/tests/test_daq.py +193 -0
  130. pyxcp/tests/test_daq_opt.py +426 -0
  131. pyxcp/tests/test_frame_padding.py +156 -0
  132. pyxcp/tests/test_framing.py +262 -0
  133. pyxcp/tests/test_master.py +2117 -0
  134. pyxcp/tests/test_transport.py +178 -0
  135. pyxcp/tests/test_utils.py +30 -0
  136. pyxcp/timing.py +60 -0
  137. pyxcp/transport/__init__.py +13 -0
  138. pyxcp/transport/base.py +484 -0
  139. pyxcp/transport/base_transport.hpp +0 -0
  140. pyxcp/transport/can.py +660 -0
  141. pyxcp/transport/eth.py +254 -0
  142. pyxcp/transport/sxi.py +209 -0
  143. pyxcp/transport/transport_ext.hpp +214 -0
  144. pyxcp/transport/transport_wrapper.cpp +249 -0
  145. pyxcp/transport/usb_transport.py +229 -0
  146. pyxcp/types.py +987 -0
  147. pyxcp/utils.py +128 -0
  148. pyxcp/vector/__init__.py +0 -0
  149. pyxcp/vector/map.py +82 -0
  150. pyxcp-0.25.1.dist-info/METADATA +341 -0
  151. pyxcp-0.25.1.dist-info/RECORD +154 -0
  152. pyxcp-0.25.1.dist-info/WHEEL +6 -0
  153. pyxcp-0.25.1.dist-info/entry_points.txt +9 -0
  154. pyxcp-0.25.1.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,49 @@
1
+ #!/usr/bin/env python
2
+ """Use this as a copy-and-paste template for your own scripts.
3
+ """
4
+
5
+ from pyxcp.cmdline import ArgumentParser
6
+
7
+
8
+ def callout(master, args):
9
+ if args.sk_dll:
10
+ master.seedNKeyDLL = args.sk_dll
11
+
12
+
13
+ ap = ArgumentParser(description="pyXCP skeleton.", callout=callout)
14
+
15
+ # Add command-line option for seed-and-key DLL.
16
+ ap.parser.add_argument(
17
+ "-s",
18
+ "--sk-dll",
19
+ dest="sk_dll",
20
+ help="Seed-and-Key .DLL name",
21
+ type=str,
22
+ default=None,
23
+ )
24
+
25
+ with ap.run() as x:
26
+ x.connect()
27
+ if x.slaveProperties.optionalCommMode:
28
+ # Collect additional properties.
29
+ x.getCommModeInfo()
30
+
31
+ # getId() is not strictly required.
32
+ slave_name = x.identifier(0x01)
33
+
34
+ # Unlock resources, if necessary.
35
+ # Could be more specific, like cond_unlock("DAQ")
36
+ # Note: Unlocking requires a seed-and-key DLL.
37
+ x.cond_unlock()
38
+
39
+ ##
40
+ # Your own code goes here.
41
+ ##
42
+
43
+ x.disconnect()
44
+
45
+ # Print some useful information.
46
+ # print("\nSlave properties:")
47
+ # print("=================")
48
+ # print("ID: '{}'".format(slave_name.decode("utf8")))
49
+ # pprint(x.slaveProperties)
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env python
2
+ """Very basic hello-world example.
3
+ """
4
+ from pyxcp.cmdline import ArgumentParser
5
+
6
+
7
+ """
8
+ """
9
+
10
+
11
+ def callout(master, args):
12
+ if args.sk_dll:
13
+ master.seedNKeyDLL = args.sk_dll
14
+
15
+
16
+ ap = ArgumentParser(callout)
17
+ ap.parser.add_argument(
18
+ "-s",
19
+ "--sk-dll",
20
+ dest="sk_dll",
21
+ help="Seed-and-Key .DLL name",
22
+ type=str,
23
+ default=None,
24
+ )
25
+
26
+ with ap.run() as x:
27
+ x.connect()
28
+
29
+ print("")
30
+ rps = x.getCurrentProtectionStatus()
31
+ print("Protection before unlocking:", rps, end="\n\n")
32
+
33
+ x.cond_unlock()
34
+
35
+ rps = x.getCurrentProtectionStatus()
36
+ print("Protection after unlocking:", rps)
37
+
38
+ x.disconnect()
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env python
2
+
3
+ from typing import Dict, List, 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
+
13
+ def init(self):
14
+ """Initialize the CAN interface here."""
15
+
16
+ def set_filters(self, filters):
17
+ print(f"set_filters({filters})")
18
+ self._filters = filters
19
+
20
+ def recv(self, timeout: Optional[float] = None) -> Optional[can.message.Message]:
21
+ """Receive CAN frames."""
22
+ return can.message.Message()
23
+
24
+ def send(self, msg: can.message.Message):
25
+ """Send CAN frames."""
26
+ print(f"send({msg})")
27
+
28
+ @property
29
+ def filters(self):
30
+ """Return the current CAN filters."""
31
+ return self._filters
32
+
33
+ @property
34
+ def state(self):
35
+ """Return the current state of the CAN interface."""
36
+ return can.BusState.ACTIVE
37
+
38
+
39
+ custom_interface = CustomCANInterface()
40
+
41
+ ap = ArgumentParser(description="User supplied CAN driver.")
42
+ with ap.run(transport_layer_interface=custom_interface) as x:
43
+ x.connect()
44
+ x.disconnect()
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env python
2
+ """Very basic hello-world example."""
3
+ from pprint import pprint
4
+
5
+ from pyxcp.cmdline import ArgumentParser
6
+ from pyxcp.utils import decode_bytes
7
+
8
+
9
+ daq_info = False
10
+
11
+
12
+ def callout(master, args):
13
+ global daq_info
14
+ if args.daq_info:
15
+ daq_info = True
16
+
17
+
18
+ ap = ArgumentParser(description="pyXCP hello world.", callout=callout)
19
+ ap.parser.add_argument(
20
+ "-d",
21
+ "--daq-info",
22
+ dest="daq_info",
23
+ help="Display DAQ-info",
24
+ default=False,
25
+ action="store_true",
26
+ )
27
+
28
+ with ap.run() as x:
29
+ x.connect()
30
+ if x.slaveProperties.optionalCommMode:
31
+ x.getCommModeInfo()
32
+ identifier = x.identifier(0x01)
33
+ print("\nSlave Properties:")
34
+ print("=================")
35
+ print(f"ID: {identifier!r}")
36
+ pprint(x.slaveProperties)
37
+ x.cond_unlock()
38
+ cps = x.getCurrentProtectionStatus()
39
+ print("\nProtection Status")
40
+ print("=================")
41
+ for k, v in cps.items():
42
+ print(f" {k:6s}: {v}")
43
+ daq = x.getDaqInfo()
44
+ pprint(daq)
45
+ if daq_info:
46
+ dqp = x.getDaqProcessorInfo()
47
+ print("\nDAQ Processor Info:")
48
+ print("===================")
49
+ print(dqp)
50
+ print("\nDAQ Events:")
51
+ print("===========")
52
+ for idx in range(dqp.maxEventChannel):
53
+ evt = x.getDaqEventInfo(idx)
54
+ length = evt.eventChannelNameLength
55
+ name = decode_bytes(x.pull(length))
56
+ dq = "DAQ" if evt.daqEventProperties.daq else ""
57
+ st = "STIM" if evt.daqEventProperties.stim else ""
58
+ dq_st = dq + " " + st
59
+ print(f" [{idx:04}] {name:r}")
60
+ print(f" dir: {dq_st}")
61
+ print(f" packed: {evt.daqEventProperties.packed}")
62
+ PFX_CONS = "CONSISTENCY_"
63
+ print(f" consistency: {evt.daqEventProperties.consistency.strip(PFX_CONS)}")
64
+ print(f" max. DAQ lists: {evt.maxDaqList}")
65
+ PFX_TU = "EVENT_CHANNEL_TIME_UNIT_"
66
+ print(f" unit: {evt.eventChannelTimeUnit.strip(PFX_TU)}")
67
+ print(f" cycle: {evt.eventChannelTimeCycle or 'SPORADIC'}")
68
+ print(f" priority {evt.eventChannelPriority}")
69
+
70
+ dqr = x.getDaqResolutionInfo()
71
+ print("\nDAQ Resolution Info:")
72
+ print("====================")
73
+ print(dqr)
74
+ for idx in range(dqp.maxDaq):
75
+ print(f"\nDAQ List Info #{idx}")
76
+ print("=================")
77
+ print(f"{x.getDaqListInfo(idx)}")
78
+ 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)