pyxcp 0.21.9__cp38-cp38-win_amd64.whl → 0.22.23__cp38-cp38-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.

Potentially problematic release.


This version of pyxcp might be problematic. Click here for more details.

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