pyxcp 0.21.11__cp310-cp310-win32.whl → 0.22.1__cp310-cp310-win32.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.

Files changed (168) hide show
  1. CMakeLists.txt +117 -0
  2. pyxcp/__init__.py +12 -20
  3. pyxcp/aml/EtasCANMonitoring.a2l +82 -83
  4. pyxcp/aml/XCP_Common.aml +0 -1
  5. pyxcp/aml/XCPonUSB.aml +1 -1
  6. pyxcp/aml/ifdata_CAN.a2l +0 -1
  7. pyxcp/aml/ifdata_Eth.a2l +0 -1
  8. pyxcp/aml/ifdata_Flx.a2l +0 -1
  9. pyxcp/aml/ifdata_SxI.a2l +0 -1
  10. pyxcp/aml/ifdata_USB.a2l +0 -1
  11. pyxcp/asam/types.py +4 -4
  12. pyxcp/asamkeydll.c +0 -1
  13. pyxcp/checksum.py +0 -1
  14. pyxcp/cmdline.py +30 -53
  15. pyxcp/config/__init__.py +1089 -0
  16. pyxcp/config/legacy.py +120 -0
  17. pyxcp/constants.py +12 -13
  18. pyxcp/cpp_ext/__init__.py +8 -0
  19. pyxcp/cpp_ext/bin.hpp +104 -0
  20. pyxcp/cpp_ext/blockmem.hpp +58 -0
  21. pyxcp/cpp_ext/cpp_ext.cp312-win_amd64.pyd +0 -0
  22. pyxcp/cpp_ext/daqlist.hpp +197 -0
  23. pyxcp/cpp_ext/event.hpp +67 -0
  24. pyxcp/cpp_ext/extension_wrapper.cpp +94 -0
  25. pyxcp/cpp_ext/helper.hpp +264 -0
  26. pyxcp/cpp_ext/mcobject.hpp +241 -0
  27. pyxcp/cpp_ext/tsqueue.hpp +46 -0
  28. pyxcp/daq_stim/__init__.py +226 -0
  29. pyxcp/daq_stim/optimize/__init__.py +67 -0
  30. pyxcp/daq_stim/optimize/binpacking.py +41 -0
  31. pyxcp/daq_stim/scheduler.cpp +28 -0
  32. pyxcp/daq_stim/scheduler.hpp +75 -0
  33. pyxcp/daq_stim/stim.cp312-win_amd64.pyd +0 -0
  34. pyxcp/daq_stim/stim.cpp +13 -0
  35. pyxcp/daq_stim/stim.hpp +604 -0
  36. pyxcp/daq_stim/stim_wrapper.cpp +48 -0
  37. pyxcp/dllif.py +21 -18
  38. pyxcp/errormatrix.py +5 -3
  39. pyxcp/examples/conf_can.toml +4 -2
  40. pyxcp/examples/conf_can_vector.json +9 -9
  41. pyxcp/examples/conf_can_vector.toml +4 -2
  42. pyxcp/examples/conf_eth.toml +5 -2
  43. pyxcp/examples/conf_nixnet.json +18 -18
  44. pyxcp/examples/conf_sxi.json +7 -7
  45. pyxcp/examples/ex_arrow.py +109 -0
  46. pyxcp/examples/ex_mdf.py +124 -0
  47. pyxcp/examples/ex_sqlite.py +128 -0
  48. pyxcp/examples/run_daq.py +146 -0
  49. pyxcp/examples/xcp_policy.py +6 -7
  50. pyxcp/examples/xcp_read_benchmark.py +8 -6
  51. pyxcp/examples/xcp_skel.py +0 -2
  52. pyxcp/examples/xcp_unlock.py +1 -1
  53. pyxcp/examples/xcp_user_supplied_driver.py +1 -2
  54. pyxcp/examples/xcphello.py +6 -3
  55. pyxcp/examples/xcphello_recorder.py +4 -4
  56. pyxcp/master/__init__.py +1 -2
  57. pyxcp/master/errorhandler.py +107 -74
  58. pyxcp/master/master.py +156 -117
  59. pyxcp/py.typed +0 -0
  60. pyxcp/recorder/__init__.py +27 -6
  61. pyxcp/recorder/converter/__init__.py +37 -0
  62. pyxcp/recorder/lz4.c +129 -51
  63. pyxcp/recorder/lz4.h +45 -28
  64. pyxcp/recorder/lz4hc.c +560 -156
  65. pyxcp/recorder/lz4hc.h +1 -1
  66. pyxcp/recorder/mio.hpp +721 -767
  67. pyxcp/recorder/reader.hpp +139 -0
  68. pyxcp/recorder/reco.py +5 -8
  69. pyxcp/recorder/rekorder.cp312-win_amd64.pyd +0 -0
  70. pyxcp/recorder/rekorder.cpp +18 -22
  71. pyxcp/recorder/rekorder.hpp +200 -587
  72. pyxcp/recorder/setup.py +11 -10
  73. pyxcp/recorder/test_reko.py +2 -3
  74. pyxcp/recorder/unfolder.hpp +1249 -0
  75. pyxcp/recorder/wrap.cpp +171 -9
  76. pyxcp/recorder/writer.hpp +302 -0
  77. pyxcp/scripts/pyxcp_probe_can_drivers.py +0 -2
  78. pyxcp/scripts/xcp_fetch_a2l.py +15 -10
  79. pyxcp/scripts/xcp_id_scanner.py +2 -6
  80. pyxcp/scripts/xcp_info.py +91 -71
  81. pyxcp/scripts/xcp_profile.py +27 -0
  82. pyxcp/stim/__init__.py +0 -0
  83. pyxcp/tests/test_asam_types.py +2 -2
  84. pyxcp/tests/test_binpacking.py +184 -0
  85. pyxcp/tests/test_can.py +1132 -38
  86. pyxcp/tests/test_checksum.py +2 -1
  87. pyxcp/tests/test_daq.py +188 -0
  88. pyxcp/tests/test_frame_padding.py +3 -3
  89. pyxcp/tests/test_master.py +42 -31
  90. pyxcp/tests/test_transport.py +12 -12
  91. pyxcp/tests/test_utils.py +2 -5
  92. pyxcp/timing.py +0 -2
  93. pyxcp/transport/__init__.py +9 -9
  94. pyxcp/transport/base.py +142 -124
  95. pyxcp/transport/base_transport.hpp +0 -0
  96. pyxcp/transport/can.py +194 -167
  97. pyxcp/transport/eth.py +80 -82
  98. pyxcp/transport/sxi.py +106 -60
  99. pyxcp/transport/transport_wrapper.cpp +0 -0
  100. pyxcp/transport/usb_transport.py +65 -83
  101. pyxcp/types.py +61 -20
  102. pyxcp/utils.py +47 -16
  103. pyxcp/vector/map.py +1 -3
  104. {pyxcp-0.21.11.dist-info → pyxcp-0.22.1.dist-info}/METADATA +27 -22
  105. pyxcp-0.22.1.dist-info/RECORD +126 -0
  106. {pyxcp-0.21.11.dist-info → pyxcp-0.22.1.dist-info}/WHEEL +1 -1
  107. {pyxcp-0.21.11.dist-info → pyxcp-0.22.1.dist-info}/entry_points.txt +1 -0
  108. pyxcp/config.py +0 -57
  109. pyxcp/cxx/asynchiofactory.hpp +0 -24
  110. pyxcp/cxx/blocking_client.cpp +0 -44
  111. pyxcp/cxx/blocking_socket.cpp +0 -43
  112. pyxcp/cxx/blocking_socket.hpp +0 -558
  113. pyxcp/cxx/concurrent_queue.hpp +0 -60
  114. pyxcp/cxx/eth.hpp +0 -57
  115. pyxcp/cxx/exceptions.hpp +0 -30
  116. pyxcp/cxx/iasyncioservice.hpp +0 -31
  117. pyxcp/cxx/iresource.hpp +0 -17
  118. pyxcp/cxx/isocket.hpp +0 -22
  119. pyxcp/cxx/linux/epoll.cpp +0 -51
  120. pyxcp/cxx/linux/epoll.hpp +0 -87
  121. pyxcp/cxx/linux/lit_tester.cpp +0 -19
  122. pyxcp/cxx/linux/socket.hpp +0 -234
  123. pyxcp/cxx/linux/timeout.hpp +0 -81
  124. pyxcp/cxx/memoryblock.hpp +0 -42
  125. pyxcp/cxx/pool.hpp +0 -81
  126. pyxcp/cxx/poolmgr.cpp +0 -6
  127. pyxcp/cxx/poolmgr.hpp +0 -31
  128. pyxcp/cxx/test_queue.cpp +0 -69
  129. pyxcp/cxx/timestamp.hpp +0 -84
  130. pyxcp/cxx/utils.cpp +0 -38
  131. pyxcp/cxx/utils.hpp +0 -29
  132. pyxcp/cxx/win/iocp.cpp +0 -242
  133. pyxcp/cxx/win/iocp.hpp +0 -42
  134. pyxcp/cxx/win/perhandledata.hpp +0 -24
  135. pyxcp/cxx/win/periodata.hpp +0 -97
  136. pyxcp/cxx/win/socket.hpp +0 -185
  137. pyxcp/cxx/win/timeout.hpp +0 -83
  138. pyxcp/examples/conf_can.json +0 -20
  139. pyxcp/examples/conf_eth.json +0 -8
  140. pyxcp/logger.py +0 -64
  141. pyxcp/tests/test_config.py +0 -62
  142. pyxcp/transport/candriver/__init__.py +0 -2
  143. pyxcp/transport/candriver/pc_canalystii.py +0 -27
  144. pyxcp/transport/candriver/pc_etas.py +0 -25
  145. pyxcp/transport/candriver/pc_gsusb.py +0 -23
  146. pyxcp/transport/candriver/pc_iscan.py +0 -23
  147. pyxcp/transport/candriver/pc_ixxat.py +0 -27
  148. pyxcp/transport/candriver/pc_kvaser.py +0 -39
  149. pyxcp/transport/candriver/pc_neovi.py +0 -31
  150. pyxcp/transport/candriver/pc_nican.py +0 -23
  151. pyxcp/transport/candriver/pc_nixnet.py +0 -23
  152. pyxcp/transport/candriver/pc_pcan.py +0 -25
  153. pyxcp/transport/candriver/pc_seeed.py +0 -28
  154. pyxcp/transport/candriver/pc_serial.py +0 -27
  155. pyxcp/transport/candriver/pc_slcan.py +0 -29
  156. pyxcp/transport/candriver/pc_socketcan.py +0 -23
  157. pyxcp/transport/candriver/pc_systec.py +0 -29
  158. pyxcp/transport/candriver/pc_usb2can.py +0 -30
  159. pyxcp/transport/candriver/pc_vector.py +0 -34
  160. pyxcp/transport/candriver/python_can.py +0 -101
  161. pyxcp/transport/cxx_ext/CMakeLists.txt +0 -51
  162. pyxcp/transport/cxx_ext/setup.py +0 -49
  163. pyxcp/transport/cxx_ext/tests/test_basic_socket.cpp +0 -39
  164. pyxcp/transport/cxx_ext/tests/test_pool.cpp +0 -39
  165. pyxcp/transport/cxx_ext/tests/test_timestamp.cpp +0 -27
  166. pyxcp-0.21.11.dist-info/RECORD +0 -147
  167. rekorder.cp310-win32.pyd +0 -0
  168. {pyxcp-0.21.11.dist-info/licenses → pyxcp-0.22.1.dist-info}/LICENSE +0 -0
pyxcp/scripts/xcp_info.py CHANGED
@@ -1,89 +1,109 @@
1
1
  #!/usr/bin/env python
2
+
2
3
  """XCP info/exploration tool.
3
4
  """
5
+
4
6
  from pprint import pprint
5
7
 
6
8
  from pyxcp.cmdline import ArgumentParser
7
9
  from pyxcp.types import TryCommandResult
8
10
 
9
11
 
10
- ap = ArgumentParser(description="XCP info/exploration tool.")
12
+ def main():
13
+ ap = ArgumentParser(description="XCP info/exploration tool.")
11
14
 
12
- with ap.run() as x:
13
- x.connect()
14
- if x.slaveProperties.optionalCommMode:
15
- x.try_command(x.getCommModeInfo, extra_msg="availability signaled by CONNECT, this may be a slave configuration error.")
16
- print("\nSlave Properties:")
17
- print("=================")
18
- pprint(x.slaveProperties)
15
+ with ap.run() as x:
16
+ x.connect()
17
+ if x.slaveProperties.optionalCommMode:
18
+ x.try_command(x.getCommModeInfo, extra_msg="availability signaled by CONNECT, this may be a slave configuration error.")
19
+ print("\nSlave Properties:")
20
+ print("=================")
21
+ pprint(x.slaveProperties)
19
22
 
20
- # result = x.id_scanner()
21
- # print("\n")
22
- # print("Implemented IDs:")
23
- # print("================")
24
- # for key, value in result.items():
25
- # print(f"{key}: {value}", end="\n\n")
26
- cps = x.getCurrentProtectionStatus()
27
- print("\nProtection Status")
28
- print("=================")
29
- for k, v in cps.items():
30
- print(f" {k:6s}: {v}")
31
- x.cond_unlock()
32
- print("\nDAQ Info:")
33
- print("=========")
34
- daq_info = x.getDaqInfo()
35
- pprint(daq_info)
23
+ result = x.id_scanner()
24
+ print("\n")
25
+ print("Implemented IDs:")
26
+ print("================")
27
+ for key, value in result.items():
28
+ print(f"{key}: {value}", end="\n\n")
29
+ cps = x.getCurrentProtectionStatus()
30
+ print("\nProtection Status")
31
+ print("=================")
32
+ for k, v in cps.items():
33
+ print(f" {k:6s}: {v}")
34
+ x.cond_unlock()
35
+ print("\nDAQ Info:")
36
+ print("=========")
37
+ daq_info = x.getDaqInfo()
38
+ pprint(daq_info)
36
39
 
37
- daq_pro = daq_info["processor"]
38
- daq_properties = daq_pro["properties"]
39
- if x.slaveProperties.transport_layer == "CAN":
40
- print("")
41
- if daq_properties["pidOffSupported"]:
42
- print("*** pidOffSupported -- i.e. one CAN-ID per DAQ-list.")
40
+ daq_pro = daq_info["processor"]
41
+ daq_properties = daq_pro["properties"]
42
+ if x.slaveProperties.transport_layer == "CAN":
43
+ print("")
44
+ if daq_properties["pidOffSupported"]:
45
+ print("*** pidOffSupported -- i.e. one CAN-ID per DAQ-list.")
46
+ else:
47
+ print("*** NO support for PID_OFF")
48
+ num_predefined = daq_pro["minDaq"]
49
+ print("\nPredefined DAQ-Lists")
50
+ print("====================")
51
+ if num_predefined > 0:
52
+ print(f"There are {num_predefined} predefined DAQ-lists")
53
+ for idx in range(num_predefined):
54
+ print(f"DAQ-List #{idx}\n____________\n")
55
+ status, dm = x.try_command(x.getDaqListMode, idx)
56
+ if status == TryCommandResult.OK:
57
+ print(dm)
58
+ status, di = x.try_command(x.getDaqListInfo, idx)
59
+ if status == TryCommandResult.OK:
60
+ print(di)
43
61
  else:
44
- print("*** NO support for PID_OFF")
45
- num_predefined = daq_pro["minDaq"]
46
- print("\nPredefined DAQ-Lists")
47
- print("====================")
48
- if num_predefined > 0:
49
- print(f"There are {num_predefined} predefined DAQ-lists")
50
- for idx in range(num_predefined):
51
- print(f"DAQ-List #{idx}\n____________\n")
52
- status, dm = x.try_command(x.getDaqListMode, idx)
62
+ print("*** NO Predefined DAQ-Lists")
63
+ print("\nPAG Info:")
64
+ print("=========")
65
+ if x.slaveProperties.supportsCalpag:
66
+ status, pag = x.try_command(x.getPagProcessorInfo)
53
67
  if status == TryCommandResult.OK:
54
- print(dm)
55
- status, di = x.try_command(x.getDaqListInfo, idx)
68
+ print(pag)
69
+ # for idx in range(pag.maxSegments):
70
+ # x.getSegmentInfo(0x01, idx, 0, 0)
71
+ else:
72
+ print("*** PAGING IS NOT SUPPORTED.")
73
+
74
+ print("\nPGM Info:")
75
+ print("=========")
76
+ if x.slaveProperties.supportsPgm:
77
+ status, pgm = x.try_command(x.getPgmProcessorInfo)
78
+ if status == TryCommandResult.OK:
79
+ print(pgm)
80
+ else:
81
+ print("*** FLASH PROGRAMMING IS NOT SUPPORTED.")
82
+
83
+ if x.slaveProperties.transport_layer == "CAN":
84
+ print("\nTransport-Layer CAN:")
85
+ print("====================")
86
+ status, res = x.try_command(x.getSlaveID, 0)
56
87
  if status == TryCommandResult.OK:
57
- print(di)
58
- else:
59
- print("*** NO Predefined DAQ-Lists")
60
- print("\nPAG Info:")
61
- print("=========")
62
- if x.slaveProperties.supportsCalpag:
63
- status, pag = x.try_command(x.getPagProcessorInfo)
64
- if status == TryCommandResult.OK:
65
- print(pag)
66
- # for idx in range(pag.maxSegments):
67
- # x.getSegmentInfo(0x01, idx, 0, 0)
68
- else:
69
- print("*** PAGING IS NOT SUPPORTED.")
88
+ print("CAN identifier for CMD/STIM:\n", res)
89
+ else:
90
+ print("*** GET_SLAVE_ID() IS NOT SUPPORTED.") # no response from bc address ???
70
91
 
71
- print("\nPGM Info:")
72
- print("=========")
73
- if x.slaveProperties.supportsPgm:
74
- status, pgm = x.try_command(x.getPgmProcessorInfo)
75
- if status == TryCommandResult.OK:
76
- print(pgm)
77
- else:
78
- print("*** FLASH PROGRAMMING IS NOT SUPPORTED.")
92
+ print("\nPer DAQ-list Identifier")
93
+ print("-----------------------")
94
+ daq_id = 0
95
+ while True:
96
+ status, res = x.try_command(x.getDaqId, daq_id)
97
+ if status == TryCommandResult.OK:
98
+ print(f"DAQ-list #{daq_id}:", res)
99
+ daq_id += 1
100
+ else:
101
+ break
102
+ if daq_id == 0:
103
+ print("N/A")
104
+ x.disconnect()
105
+ print("\nDone.")
79
106
 
80
- if x.slaveProperties.transport_layer == "CAN":
81
- # print("OK, CAN!!!")
82
- for idx in range(num_predefined):
83
- status, daq_id = x.try_command(x.getDaqId, idx)
84
- if status != TryCommandResult.OK:
85
- break
86
- print(f"DAQ-ID #{idx}", daq_id)
87
- x.disconnect()
88
107
 
89
- print("\nDone.")
108
+ if __name__ == "__main__":
109
+ main()
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env python
2
+ """Create / convert pyxcp profiles (configurations).
3
+ """
4
+
5
+ import sys
6
+
7
+ from pyxcp.cmdline import ArgumentParser
8
+
9
+
10
+ def main():
11
+ if len(sys.argv) == 1:
12
+ sys.argv.append("profile")
13
+ elif len(sys.argv) >= 2 and sys.argv[1] != "profile":
14
+ sys.argv.insert(1, "profile")
15
+
16
+ ap = ArgumentParser(description="Create / convert pyxcp profiles (configurations).")
17
+
18
+ try:
19
+ with ap.run() as x: # noqa: F841
20
+ pass
21
+ except FileNotFoundError as e:
22
+ print(f"Error: {e}")
23
+ sys.exit(1)
24
+
25
+
26
+ if __name__ == "__main__":
27
+ main()
pyxcp/stim/__init__.py ADDED
File without changes
@@ -1,7 +1,7 @@
1
- from pyxcp.asam import types
2
-
3
1
  import pytest
4
2
 
3
+ from pyxcp.asam import types
4
+
5
5
 
6
6
  def testEncodeUint32_0():
7
7
  assert types.A_Uint32("<").encode(3415750566) == b"\xa67\x98\xcb"
@@ -0,0 +1,184 @@
1
+ import pytest
2
+
3
+ from pyxcp.daq_stim.optimize import McObject, make_continuous_blocks
4
+ from pyxcp.daq_stim.optimize.binpacking import Bin, first_fit_decreasing
5
+
6
+
7
+ @pytest.fixture
8
+ def blocks():
9
+ return [
10
+ McObject(name="", address=0x000E10BA, length=2),
11
+ McObject(name="", address=0x000E10BE, length=2),
12
+ McObject(name="", address=0x000E41F4, length=4),
13
+ McObject(name="", address=0x000E51FC, length=4),
14
+ McObject(name="", address=0x00125288, length=4),
15
+ McObject(name="", address=0x00125294, length=4),
16
+ McObject(name="", address=0x001252A1, length=1),
17
+ McObject(name="", address=0x001252A4, length=4),
18
+ McObject(name="", address=0x00125438, length=3),
19
+ McObject(name="", address=0x0012543C, length=1),
20
+ ]
21
+
22
+
23
+ def test_pack_to_single_bin(blocks):
24
+ BIN_SIZE = 253
25
+ bins = first_fit_decreasing(items=blocks, bin_size=BIN_SIZE)
26
+
27
+ assert len(bins) == 1
28
+ bin0 = bins[0]
29
+ assert bin0.residual_capacity == BIN_SIZE - 29
30
+ assert bin0.entries == [
31
+ McObject(name="", address=0x000E41F4, length=4),
32
+ McObject(name="", address=0x000E51FC, length=4),
33
+ McObject(name="", address=0x00125288, length=4),
34
+ McObject(name="", address=0x00125294, length=4),
35
+ McObject(name="", address=0x001252A4, length=4),
36
+ McObject(name="", address=0x00125438, length=3),
37
+ McObject(name="", address=0x000E10BA, length=2),
38
+ McObject(name="", address=0x000E10BE, length=2),
39
+ McObject(name="", address=0x001252A1, length=1),
40
+ McObject(name="", address=0x0012543C, length=1),
41
+ ]
42
+
43
+
44
+ def test_pack_empty_block_set():
45
+ BIN_SIZE = 253
46
+ bins = first_fit_decreasing(items=[], bin_size=BIN_SIZE)
47
+ assert bins == [Bin(size=BIN_SIZE)]
48
+
49
+
50
+ def test_pack_to_multiple_bins1(blocks):
51
+ BIN_SIZE = 6
52
+ bins = first_fit_decreasing(items=blocks, bin_size=BIN_SIZE)
53
+ assert len(bins) == 6
54
+ bin0, bin1, bin2, bin3, bin4, bin5 = bins
55
+ assert bin0.residual_capacity == 0
56
+ assert bin0.entries == [
57
+ McObject(name="", address=0x000E41F4, length=4),
58
+ McObject(name="", address=0x000E10BA, length=2),
59
+ ]
60
+ assert bin1.residual_capacity == 0
61
+ assert bin1.entries == [
62
+ McObject(name="", address=0x000E51FC, length=4),
63
+ McObject(name="", address=0x000E10BE, length=2),
64
+ ]
65
+ assert bin2.residual_capacity == 0
66
+ assert bin2.entries == [
67
+ McObject(name="", address=0x00125288, length=4),
68
+ McObject(name="", address=0x001252A1, length=1),
69
+ McObject(name="", address=0x0012543C, length=1),
70
+ ]
71
+ assert bin3.residual_capacity == 2
72
+ assert bin3.entries == [McObject(name="", address=0x00125294, length=4)]
73
+ assert bin4.residual_capacity == 2
74
+ assert bin4.entries == [McObject(name="", address=0x001252A4, length=4)]
75
+ assert bin5.residual_capacity == 3
76
+ assert bin5.entries == [McObject(name="", address=0x00125438, length=3)]
77
+
78
+
79
+ def test_binpacking_raises(blocks):
80
+ BIN_SIZE = 7
81
+ with pytest.raises(ValueError):
82
+ first_fit_decreasing(items=[McObject(name="", address=0x1000, length=32)], bin_size=BIN_SIZE)
83
+
84
+
85
+ def test_binpacking_works(blocks):
86
+ BIN_SIZE = 7
87
+ first_fit_decreasing(items=[McObject(name="", address=0x1000, length=7)], bin_size=BIN_SIZE)
88
+
89
+
90
+ def test_make_continuous_blocks1():
91
+ BLOCKS = [
92
+ McObject(name="", address=0x000E0002, length=2),
93
+ McObject(name="", address=0x000E0008, ext=23, length=4),
94
+ McObject(name="", address=0x000E0004, length=4),
95
+ McObject(name="", address=0x000E000C, ext=23, length=4),
96
+ McObject(name="", address=0x000E0000, length=2),
97
+ ]
98
+ bins = make_continuous_blocks(chunks=BLOCKS)
99
+ assert bins == [
100
+ McObject(
101
+ name="",
102
+ address=917504,
103
+ ext=0,
104
+ length=8,
105
+ components=[
106
+ McObject(name="", address=917504, ext=0, length=2, components=[]),
107
+ McObject(name="", address=917506, ext=0, length=2, components=[]),
108
+ McObject(name="", address=917508, ext=0, length=4, components=[]),
109
+ ],
110
+ ),
111
+ McObject(
112
+ name="",
113
+ address=917512,
114
+ ext=23,
115
+ length=8,
116
+ components=[
117
+ McObject(name="", address=917512, ext=23, length=4, components=[]),
118
+ McObject(name="", address=917516, ext=23, length=4, components=[]),
119
+ ],
120
+ ),
121
+ ]
122
+
123
+
124
+ def test_make_continuous_blocks2():
125
+ BLOCKS = [
126
+ McObject(name="", address=0x000E0002, length=2),
127
+ McObject(name="", address=0x000E0008, length=4),
128
+ McObject(name="", address=0x000E0004, length=4),
129
+ McObject(name="", address=0x000E000C, length=4),
130
+ McObject(name="", address=0x000E0000, length=2),
131
+ ]
132
+ bins = make_continuous_blocks(chunks=BLOCKS)
133
+ assert bins == [
134
+ McObject(
135
+ name="",
136
+ address=917504,
137
+ ext=0,
138
+ length=16,
139
+ components=[
140
+ McObject(name="", address=917504, ext=0, length=2, components=[]),
141
+ McObject(name="", address=917506, ext=0, length=2, components=[]),
142
+ McObject(name="", address=917508, ext=0, length=4, components=[]),
143
+ McObject(name="", address=917512, ext=0, length=4, components=[]),
144
+ McObject(name="", address=917516, ext=0, length=4, components=[]),
145
+ ],
146
+ )
147
+ ]
148
+
149
+
150
+ def test_make_continuous_blocks3():
151
+ BLOCKS = [
152
+ McObject(name="", address=0x000E0002, ext=0x01, length=2),
153
+ McObject(name="", address=0x000E0008, ext=0x03, length=4),
154
+ McObject(name="", address=0x000E0004, ext=0x02, length=4),
155
+ McObject(name="", address=0x000E000C, ext=0x04, length=4),
156
+ McObject(name="", address=0x000E0000, ext=0x00, length=2),
157
+ ]
158
+ bins = make_continuous_blocks(chunks=BLOCKS)
159
+ assert bins == [
160
+ McObject(
161
+ name="", address=917504, ext=0, length=2, components=[McObject(name="", address=917504, ext=0, length=2, components=[])]
162
+ ),
163
+ McObject(
164
+ name="", address=917506, ext=1, length=2, components=[McObject(name="", address=917506, ext=1, length=2, components=[])]
165
+ ),
166
+ McObject(
167
+ name="", address=917508, ext=2, length=4, components=[McObject(name="", address=917508, ext=2, length=4, components=[])]
168
+ ),
169
+ McObject(
170
+ name="", address=917512, ext=3, length=4, components=[McObject(name="", address=917512, ext=3, length=4, components=[])]
171
+ ),
172
+ McObject(
173
+ name="", address=917516, ext=4, length=4, components=[McObject(name="", address=917516, ext=4, length=4, components=[])]
174
+ ),
175
+ ]
176
+
177
+
178
+ def test_mc_object_len_zero():
179
+ with pytest.raises(ValueError):
180
+ McObject(name="", address=0, ext=0, length=0)
181
+
182
+
183
+ def test_mc_object_ok():
184
+ McObject(name="", address=0, ext=0, length=1)