pyxcp 0.23.0__cp312-cp312-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyxcp might be problematic. Click here for more details.
- pyxcp/__init__.py +20 -0
- pyxcp/aml/EtasCANMonitoring.a2l +82 -0
- pyxcp/aml/EtasCANMonitoring.aml +67 -0
- pyxcp/aml/XCP_Common.aml +408 -0
- pyxcp/aml/XCPonCAN.aml +78 -0
- pyxcp/aml/XCPonEth.aml +33 -0
- pyxcp/aml/XCPonFlx.aml +113 -0
- pyxcp/aml/XCPonSxI.aml +66 -0
- pyxcp/aml/XCPonUSB.aml +106 -0
- pyxcp/aml/ifdata_CAN.a2l +20 -0
- pyxcp/aml/ifdata_Eth.a2l +11 -0
- pyxcp/aml/ifdata_Flx.a2l +94 -0
- pyxcp/aml/ifdata_SxI.a2l +13 -0
- pyxcp/aml/ifdata_USB.a2l +81 -0
- pyxcp/asam/__init__.py +0 -0
- pyxcp/asam/types.py +131 -0
- pyxcp/asamkeydll.c +116 -0
- pyxcp/asamkeydll.sh +2 -0
- pyxcp/checksum.py +732 -0
- pyxcp/cmdline.py +52 -0
- pyxcp/config/__init__.py +1113 -0
- pyxcp/config/legacy.py +120 -0
- pyxcp/constants.py +47 -0
- pyxcp/cpp_ext/__init__.py +0 -0
- pyxcp/cpp_ext/bin.hpp +104 -0
- pyxcp/cpp_ext/blockmem.hpp +58 -0
- pyxcp/cpp_ext/cpp_ext.cp310-win_arm64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp311-win_arm64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp312-win_arm64.pyd +0 -0
- pyxcp/cpp_ext/daqlist.hpp +206 -0
- pyxcp/cpp_ext/event.hpp +67 -0
- pyxcp/cpp_ext/extension_wrapper.cpp +100 -0
- pyxcp/cpp_ext/helper.hpp +280 -0
- pyxcp/cpp_ext/mcobject.hpp +246 -0
- pyxcp/cpp_ext/tsqueue.hpp +46 -0
- pyxcp/daq_stim/__init__.py +232 -0
- pyxcp/daq_stim/optimize/__init__.py +67 -0
- pyxcp/daq_stim/optimize/binpacking.py +41 -0
- pyxcp/daq_stim/scheduler.cpp +62 -0
- pyxcp/daq_stim/scheduler.hpp +75 -0
- pyxcp/daq_stim/stim.cp310-win_arm64.pyd +0 -0
- pyxcp/daq_stim/stim.cp311-win_arm64.pyd +0 -0
- pyxcp/daq_stim/stim.cp312-win_arm64.pyd +0 -0
- pyxcp/daq_stim/stim.cpp +13 -0
- pyxcp/daq_stim/stim.hpp +604 -0
- pyxcp/daq_stim/stim_wrapper.cpp +50 -0
- pyxcp/dllif.py +100 -0
- pyxcp/errormatrix.py +878 -0
- pyxcp/examples/conf_can.toml +19 -0
- pyxcp/examples/conf_can_user.toml +16 -0
- pyxcp/examples/conf_can_vector.json +11 -0
- pyxcp/examples/conf_can_vector.toml +11 -0
- pyxcp/examples/conf_eth.toml +9 -0
- pyxcp/examples/conf_nixnet.json +20 -0
- pyxcp/examples/conf_socket_can.toml +12 -0
- pyxcp/examples/conf_sxi.json +9 -0
- pyxcp/examples/conf_sxi.toml +7 -0
- pyxcp/examples/run_daq.py +163 -0
- pyxcp/examples/xcp_policy.py +60 -0
- pyxcp/examples/xcp_read_benchmark.py +38 -0
- pyxcp/examples/xcp_skel.py +49 -0
- pyxcp/examples/xcp_unlock.py +38 -0
- pyxcp/examples/xcp_user_supplied_driver.py +44 -0
- pyxcp/examples/xcphello.py +78 -0
- pyxcp/examples/xcphello_recorder.py +107 -0
- pyxcp/master/__init__.py +9 -0
- pyxcp/master/errorhandler.py +442 -0
- pyxcp/master/master.py +2047 -0
- pyxcp/py.typed +0 -0
- pyxcp/recorder/__init__.py +101 -0
- pyxcp/recorder/build_clang.cmd +1 -0
- pyxcp/recorder/build_clang.sh +2 -0
- pyxcp/recorder/build_gcc.cmd +1 -0
- pyxcp/recorder/build_gcc.sh +2 -0
- pyxcp/recorder/build_gcc_arm.sh +2 -0
- pyxcp/recorder/converter/__init__.py +450 -0
- pyxcp/recorder/lz4.c +2829 -0
- pyxcp/recorder/lz4.h +879 -0
- pyxcp/recorder/lz4hc.c +2041 -0
- pyxcp/recorder/lz4hc.h +413 -0
- pyxcp/recorder/mio.hpp +1714 -0
- pyxcp/recorder/reader.hpp +139 -0
- pyxcp/recorder/reco.py +277 -0
- pyxcp/recorder/recorder.rst +0 -0
- pyxcp/recorder/rekorder.cp310-win_arm64.pyd +0 -0
- pyxcp/recorder/rekorder.cp311-win_arm64.pyd +0 -0
- pyxcp/recorder/rekorder.cp312-win_arm64.pyd +0 -0
- pyxcp/recorder/rekorder.cpp +59 -0
- pyxcp/recorder/rekorder.hpp +274 -0
- pyxcp/recorder/setup.py +41 -0
- pyxcp/recorder/test_reko.py +34 -0
- pyxcp/recorder/unfolder.hpp +1332 -0
- pyxcp/recorder/wrap.cpp +189 -0
- pyxcp/recorder/writer.hpp +302 -0
- pyxcp/scripts/__init__.py +0 -0
- pyxcp/scripts/pyxcp_probe_can_drivers.py +20 -0
- pyxcp/scripts/xcp_examples.py +64 -0
- pyxcp/scripts/xcp_fetch_a2l.py +40 -0
- pyxcp/scripts/xcp_id_scanner.py +19 -0
- pyxcp/scripts/xcp_info.py +144 -0
- pyxcp/scripts/xcp_profile.py +27 -0
- pyxcp/scripts/xmraw_converter.py +31 -0
- pyxcp/stim/__init__.py +0 -0
- pyxcp/tests/test_asam_types.py +24 -0
- pyxcp/tests/test_binpacking.py +186 -0
- pyxcp/tests/test_can.py +1324 -0
- pyxcp/tests/test_checksum.py +95 -0
- pyxcp/tests/test_daq.py +193 -0
- pyxcp/tests/test_daq_opt.py +426 -0
- pyxcp/tests/test_frame_padding.py +156 -0
- pyxcp/tests/test_master.py +2006 -0
- pyxcp/tests/test_transport.py +81 -0
- pyxcp/tests/test_utils.py +30 -0
- pyxcp/timing.py +60 -0
- pyxcp/transport/__init__.py +10 -0
- pyxcp/transport/base.py +440 -0
- pyxcp/transport/base_transport.hpp +0 -0
- pyxcp/transport/can.py +556 -0
- pyxcp/transport/eth.py +219 -0
- pyxcp/transport/sxi.py +135 -0
- pyxcp/transport/transport_wrapper.cpp +0 -0
- pyxcp/transport/usb_transport.py +213 -0
- pyxcp/types.py +1000 -0
- pyxcp/utils.py +128 -0
- pyxcp/vector/__init__.py +0 -0
- pyxcp/vector/map.py +82 -0
- pyxcp-0.23.0.dist-info/LICENSE +165 -0
- pyxcp-0.23.0.dist-info/METADATA +107 -0
- pyxcp-0.23.0.dist-info/RECORD +131 -0
- pyxcp-0.23.0.dist-info/WHEEL +4 -0
- pyxcp-0.23.0.dist-info/entry_points.txt +9 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
"""XCP info/exploration tool."""
|
|
4
|
+
|
|
5
|
+
from pprint import pprint
|
|
6
|
+
|
|
7
|
+
from pyxcp.cmdline import ArgumentParser
|
|
8
|
+
from pyxcp.types import TryCommandResult
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def getPagInfo(x):
|
|
12
|
+
result = {}
|
|
13
|
+
if x.slaveProperties.supportsCalpag:
|
|
14
|
+
status, pag = x.try_command(x.getPagProcessorInfo)
|
|
15
|
+
if status == TryCommandResult.OK:
|
|
16
|
+
result["maxSegments"] = pag.maxSegments
|
|
17
|
+
result["pagProperties"] = {}
|
|
18
|
+
result["pagProperties"]["freezeSupported"] = pag.pagProperties.freezeSupported
|
|
19
|
+
result["segments"] = []
|
|
20
|
+
for i in range(pag.maxSegments):
|
|
21
|
+
segment = {}
|
|
22
|
+
status, std_info = x.try_command(x.getSegmentInfo, 0x01, i, 0, 0)
|
|
23
|
+
if status == TryCommandResult.OK:
|
|
24
|
+
segment["maxPages"] = std_info.maxPages
|
|
25
|
+
segment["addressExtension"] = std_info.addressExtension
|
|
26
|
+
segment["maxMapping"] = std_info.maxMapping
|
|
27
|
+
segment["compressionMethod"] = std_info.compressionMethod
|
|
28
|
+
segment["encryptionMethod"] = std_info.encryptionMethod
|
|
29
|
+
|
|
30
|
+
status, seg_address = x.try_command(x.getSegmentInfo, 0x00, i, 0, 0)
|
|
31
|
+
status, seg_length = x.try_command(x.getSegmentInfo, 0x00, i, 1, 0)
|
|
32
|
+
|
|
33
|
+
segment["address"] = seg_address.basicInfo
|
|
34
|
+
segment["length"] = seg_length.basicInfo
|
|
35
|
+
|
|
36
|
+
result["segments"].append(segment)
|
|
37
|
+
|
|
38
|
+
status, pgi = x.try_command(x.getPageInfo, i, 0)
|
|
39
|
+
# print("PAGE:", pgi)
|
|
40
|
+
# for j in range(si.maxPages):
|
|
41
|
+
# pgi = x.getPageInfo(i, j)
|
|
42
|
+
# print(pgi)
|
|
43
|
+
else:
|
|
44
|
+
break
|
|
45
|
+
return result
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def main():
|
|
49
|
+
ap = ArgumentParser(description="XCP info/exploration tool.")
|
|
50
|
+
|
|
51
|
+
with ap.run() as x:
|
|
52
|
+
x.connect()
|
|
53
|
+
if x.slaveProperties.optionalCommMode:
|
|
54
|
+
x.try_command(x.getCommModeInfo, extra_msg="availability signaled by CONNECT, this may be a slave configuration error.")
|
|
55
|
+
print("\nSlave Properties:")
|
|
56
|
+
print("=================")
|
|
57
|
+
pprint(x.slaveProperties)
|
|
58
|
+
|
|
59
|
+
result = x.id_scanner()
|
|
60
|
+
print("\n")
|
|
61
|
+
print("Implemented IDs:")
|
|
62
|
+
print("================")
|
|
63
|
+
for key, value in result.items():
|
|
64
|
+
print(f"{key}: {value}", end="\n\n")
|
|
65
|
+
cps = x.getCurrentProtectionStatus()
|
|
66
|
+
print("\nProtection Status")
|
|
67
|
+
print("=================")
|
|
68
|
+
for k, v in cps.items():
|
|
69
|
+
print(f" {k:6s}: {v}")
|
|
70
|
+
x.cond_unlock()
|
|
71
|
+
print("\nDAQ Info:")
|
|
72
|
+
print("=========")
|
|
73
|
+
if x.slaveProperties.supportsDaq:
|
|
74
|
+
daq_info = x.getDaqInfo()
|
|
75
|
+
pprint(daq_info)
|
|
76
|
+
|
|
77
|
+
daq_pro = daq_info["processor"]
|
|
78
|
+
daq_properties = daq_pro["properties"]
|
|
79
|
+
if x.slaveProperties.transport_layer == "CAN":
|
|
80
|
+
print("")
|
|
81
|
+
if daq_properties["pidOffSupported"]:
|
|
82
|
+
print("*** pidOffSupported -- i.e. one CAN-ID per DAQ-list.")
|
|
83
|
+
else:
|
|
84
|
+
print("*** NO support for PID_OFF")
|
|
85
|
+
num_predefined = daq_pro["minDaq"]
|
|
86
|
+
print("\nPredefined DAQ-Lists")
|
|
87
|
+
print("====================")
|
|
88
|
+
if num_predefined > 0:
|
|
89
|
+
print(f"There are {num_predefined} predefined DAQ-lists")
|
|
90
|
+
for idx in range(num_predefined):
|
|
91
|
+
print(f"DAQ-List #{idx}\n____________\n")
|
|
92
|
+
status, dm = x.try_command(x.getDaqListMode, idx)
|
|
93
|
+
if status == TryCommandResult.OK:
|
|
94
|
+
print(dm)
|
|
95
|
+
status, di = x.try_command(x.getDaqListInfo, idx)
|
|
96
|
+
if status == TryCommandResult.OK:
|
|
97
|
+
print(di)
|
|
98
|
+
else:
|
|
99
|
+
print("*** NO Predefined DAQ-Lists")
|
|
100
|
+
else:
|
|
101
|
+
print("*** DAQ IS NOT SUPPORTED .")
|
|
102
|
+
print("\nPAG Info:")
|
|
103
|
+
print("=========")
|
|
104
|
+
if x.slaveProperties.supportsCalpag:
|
|
105
|
+
pgi = getPagInfo(x)
|
|
106
|
+
pprint(pgi)
|
|
107
|
+
else:
|
|
108
|
+
print("*** PAGING IS NOT SUPPORTED.")
|
|
109
|
+
print("\nPGM Info:")
|
|
110
|
+
print("=========")
|
|
111
|
+
if x.slaveProperties.supportsPgm:
|
|
112
|
+
status, pgm = x.try_command(x.getPgmProcessorInfo)
|
|
113
|
+
if status == TryCommandResult.OK:
|
|
114
|
+
print(pgm)
|
|
115
|
+
else:
|
|
116
|
+
print("*** FLASH PROGRAMMING IS NOT SUPPORTED.")
|
|
117
|
+
if x.slaveProperties.transport_layer == "CAN":
|
|
118
|
+
print("\nTransport-Layer CAN:")
|
|
119
|
+
print("====================")
|
|
120
|
+
status, res = x.try_command(x.getSlaveID, 0)
|
|
121
|
+
if status == TryCommandResult.OK:
|
|
122
|
+
print("CAN identifier for CMD/STIM:\n", res)
|
|
123
|
+
else:
|
|
124
|
+
pass
|
|
125
|
+
# print("*** GET_SLAVE_ID() IS NOT SUPPORTED.") # no response from bc address ???
|
|
126
|
+
|
|
127
|
+
print("\nPer DAQ-list Identifier")
|
|
128
|
+
print("-----------------------")
|
|
129
|
+
daq_id = 0
|
|
130
|
+
while True:
|
|
131
|
+
status, res = x.try_command(x.getDaqId, daq_id)
|
|
132
|
+
if status == TryCommandResult.OK:
|
|
133
|
+
print(f"DAQ-list #{daq_id}:", res)
|
|
134
|
+
daq_id += 1
|
|
135
|
+
else:
|
|
136
|
+
break
|
|
137
|
+
if daq_id == 0:
|
|
138
|
+
print("N/A")
|
|
139
|
+
x.disconnect()
|
|
140
|
+
print("\nDone.")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
if __name__ == "__main__":
|
|
144
|
+
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()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from pyxcp.recorder.converter import convert_xmraw
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
parser = argparse.ArgumentParser(description="Convert .xmraw files.")
|
|
7
|
+
|
|
8
|
+
parser.add_argument(
|
|
9
|
+
"target_type",
|
|
10
|
+
help="target file type",
|
|
11
|
+
choices=[
|
|
12
|
+
"arrow",
|
|
13
|
+
"csv",
|
|
14
|
+
"excel",
|
|
15
|
+
"hdf5",
|
|
16
|
+
"mdf",
|
|
17
|
+
"sqlite3",
|
|
18
|
+
],
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def main():
|
|
23
|
+
parser.add_argument("xmraw_file", help=".xmraw file")
|
|
24
|
+
parser.add_argument("-t", "--taget-file-name", dest="target_file_name", help="target file name")
|
|
25
|
+
args = parser.parse_args()
|
|
26
|
+
|
|
27
|
+
convert_xmraw(args.target_type, args.xmraw_file, args.target_file_name)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if __name__ == "__main__":
|
|
31
|
+
main()
|
pyxcp/stim/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from pyxcp.asam import types
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def testEncodeUint32_0():
|
|
7
|
+
assert types.A_Uint32("<").encode(3415750566) == b"\xa67\x98\xcb"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def testDecodeUint32_0():
|
|
11
|
+
assert types.A_Uint32("<").decode((0xA6, 0x37, 0x98, 0xCB)) == 3415750566
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def testLittleEndian():
|
|
15
|
+
assert isinstance(types.AsamBaseType(types.INTEL), types.AsamBaseType)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def testBigEndian():
|
|
19
|
+
assert isinstance(types.AsamBaseType(types.MOTOROLA), types.AsamBaseType)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def testInvalidByteOrderRaisesTypeError():
|
|
23
|
+
with pytest.raises(ValueError):
|
|
24
|
+
types.AsamBaseType("#")
|
|
@@ -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)
|