pyxcp 0.25.1__cp314-cp314-macosx_11_0_arm64.whl → 0.25.9__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.
- pyxcp/__init__.py +2 -2
- pyxcp/cmdline.py +14 -29
- pyxcp/config/__init__.py +1257 -1257
- pyxcp/cpp_ext/aligned_buffer.hpp +1 -1
- pyxcp/cpp_ext/cpp_ext.cpython-310-darwin.so +0 -0
- pyxcp/cpp_ext/cpp_ext.cpython-311-darwin.so +0 -0
- pyxcp/cpp_ext/cpp_ext.cpython-312-darwin.so +0 -0
- pyxcp/cpp_ext/cpp_ext.cpython-313-darwin.so +0 -0
- pyxcp/cpp_ext/cpp_ext.cpython-314-darwin.so +0 -0
- pyxcp/cpp_ext/extension_wrapper.cpp +79 -2
- pyxcp/cpp_ext/framing.hpp +1 -1
- pyxcp/cpp_ext/helper.hpp +280 -280
- pyxcp/cpp_ext/sxi_framing.hpp +1 -1
- pyxcp/daq_stim/__init__.py +95 -32
- pyxcp/daq_stim/optimize/binpacking.py +2 -2
- pyxcp/daq_stim/scheduler.cpp +8 -8
- pyxcp/errormatrix.py +2 -2
- pyxcp/examples/xcp_read_benchmark.py +2 -2
- pyxcp/examples/xcp_skel.py +1 -2
- pyxcp/examples/xcp_unlock.py +10 -12
- pyxcp/examples/xcp_user_supplied_driver.py +1 -2
- pyxcp/examples/xcphello.py +2 -15
- pyxcp/examples/xcphello_recorder.py +2 -2
- pyxcp/master/__init__.py +1 -0
- pyxcp/master/master.py +14 -20
- pyxcp/recorder/.idea/misc.xml +1 -1
- pyxcp/recorder/.idea/modules.xml +1 -1
- pyxcp/recorder/.idea/recorder.iml +1 -1
- pyxcp/recorder/.idea/vcs.xml +1 -1
- pyxcp/recorder/converter/__init__.py +4 -10
- pyxcp/recorder/reader.hpp +138 -138
- pyxcp/recorder/reco.py +1 -0
- pyxcp/recorder/rekorder.hpp +274 -274
- pyxcp/recorder/wrap.cpp +184 -184
- pyxcp/recorder/writer.hpp +302 -302
- pyxcp/scripts/xcp_daq_recorder.py +54 -0
- pyxcp/scripts/xcp_fetch_a2l.py +2 -2
- pyxcp/scripts/xcp_id_scanner.py +1 -2
- pyxcp/scripts/xcp_info.py +66 -51
- pyxcp/scripts/xcp_profile.py +1 -2
- pyxcp/tests/test_binpacking.py +1 -0
- pyxcp/tests/test_daq.py +1 -1
- pyxcp/tests/test_framing.py +1 -1
- pyxcp/tests/test_master.py +104 -83
- pyxcp/tests/test_transport.py +0 -1
- pyxcp/timing.py +1 -1
- pyxcp/transport/base.py +1 -1
- pyxcp/transport/can.py +1 -1
- pyxcp/transport/eth.py +1 -1
- pyxcp/transport/hdf5_policy.py +167 -0
- pyxcp/transport/sxi.py +1 -1
- pyxcp/transport/transport_ext.cpython-310-darwin.so +0 -0
- pyxcp/transport/transport_ext.cpython-311-darwin.so +0 -0
- pyxcp/transport/transport_ext.cpython-312-darwin.so +0 -0
- pyxcp/transport/transport_ext.cpython-313-darwin.so +0 -0
- pyxcp/transport/transport_ext.cpython-314-darwin.so +0 -0
- pyxcp/transport/usb_transport.py +1 -1
- pyxcp/{utils.py → utils/__init__.py} +1 -2
- pyxcp/utils/cli.py +78 -0
- {pyxcp-0.25.1.dist-info → pyxcp-0.25.9.dist-info}/METADATA +1 -1
- {pyxcp-0.25.1.dist-info → pyxcp-0.25.9.dist-info}/RECORD +64 -56
- {pyxcp-0.25.1.dist-info → pyxcp-0.25.9.dist-info}/WHEEL +1 -1
- {pyxcp-0.25.1.dist-info → pyxcp-0.25.9.dist-info}/entry_points.txt +0 -0
- {pyxcp-0.25.1.dist-info → pyxcp-0.25.9.dist-info}/licenses/LICENSE +0 -0
pyxcp/scripts/xcp_id_scanner.py
CHANGED
pyxcp/scripts/xcp_info.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"""XCP info/exploration tool."""
|
|
4
4
|
|
|
5
|
+
import argparse
|
|
5
6
|
from pprint import pprint
|
|
6
7
|
|
|
7
8
|
from pyxcp.cmdline import ArgumentParser
|
|
@@ -46,7 +47,12 @@ def getPagInfo(x):
|
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
def main():
|
|
49
|
-
|
|
50
|
+
parser = argparse.ArgumentParser(description="XCP info/exploration tool.")
|
|
51
|
+
parser.add_argument("--no-daq", action="store_true", help="Do not query DAQ information.")
|
|
52
|
+
parser.add_argument("--no-pag", action="store_true", help="Do not query PAG information.")
|
|
53
|
+
parser.add_argument("--no-pgm", action="store_true", help="Do not query PGM information.")
|
|
54
|
+
parser.add_argument("--no-ids", action="store_true", help="Do not scan implemented IDs.")
|
|
55
|
+
ap = ArgumentParser(parser)
|
|
50
56
|
|
|
51
57
|
with ap.run() as x:
|
|
52
58
|
x.connect()
|
|
@@ -56,64 +62,73 @@ def main():
|
|
|
56
62
|
print("=================")
|
|
57
63
|
pprint(x.slaveProperties)
|
|
58
64
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if not ap.args.no_ids:
|
|
66
|
+
result = x.id_scanner()
|
|
67
|
+
print("\n")
|
|
68
|
+
print("Implemented IDs:")
|
|
69
|
+
print("================")
|
|
70
|
+
for key, value in result.items():
|
|
71
|
+
print(f"{key}: {value}", end="\n\n")
|
|
72
|
+
|
|
65
73
|
cps = x.getCurrentProtectionStatus()
|
|
66
74
|
print("\nProtection Status")
|
|
67
75
|
print("=================")
|
|
68
76
|
for k, v in cps.items():
|
|
69
77
|
print(f" {k:6s}: {v}")
|
|
70
78
|
x.cond_unlock()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if
|
|
82
|
-
print("
|
|
79
|
+
|
|
80
|
+
if not ap.args.no_daq:
|
|
81
|
+
print("\nDAQ Info:")
|
|
82
|
+
print("=========")
|
|
83
|
+
if x.slaveProperties.supportsDaq:
|
|
84
|
+
daq_info = x.getDaqInfo()
|
|
85
|
+
pprint(daq_info)
|
|
86
|
+
|
|
87
|
+
daq_pro = daq_info["processor"]
|
|
88
|
+
daq_properties = daq_pro["properties"]
|
|
89
|
+
if x.slaveProperties.transport_layer == "CAN":
|
|
90
|
+
print("")
|
|
91
|
+
if daq_properties["pidOffSupported"]:
|
|
92
|
+
print("*** pidOffSupported -- i.e. one CAN-ID per DAQ-list.")
|
|
93
|
+
else:
|
|
94
|
+
print("*** NO support for PID_OFF")
|
|
95
|
+
num_predefined = daq_pro["minDaq"]
|
|
96
|
+
print("\nPredefined DAQ-Lists")
|
|
97
|
+
print("====================")
|
|
98
|
+
if num_predefined > 0:
|
|
99
|
+
print(f"There are {num_predefined} predefined DAQ-lists")
|
|
100
|
+
for idx in range(num_predefined):
|
|
101
|
+
print(f"DAQ-List #{idx}\n____________\n")
|
|
102
|
+
status, dm = x.try_command(x.getDaqListMode, idx)
|
|
103
|
+
if status == TryCommandResult.OK:
|
|
104
|
+
print(dm)
|
|
105
|
+
status, di = x.try_command(x.getDaqListInfo, idx)
|
|
106
|
+
if status == TryCommandResult.OK:
|
|
107
|
+
print(di)
|
|
83
108
|
else:
|
|
84
|
-
print("*** NO
|
|
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)
|
|
109
|
+
print("*** NO Predefined DAQ-Lists")
|
|
98
110
|
else:
|
|
99
|
-
print("***
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
print("*** DAQ IS NOT SUPPORTED .")
|
|
112
|
+
|
|
113
|
+
if not ap.args.no_pag:
|
|
114
|
+
print("\nPAG Info:")
|
|
115
|
+
print("=========")
|
|
116
|
+
if x.slaveProperties.supportsCalpag:
|
|
117
|
+
pgi = getPagInfo(x)
|
|
118
|
+
pprint(pgi)
|
|
119
|
+
else:
|
|
120
|
+
print("*** PAGING IS NOT SUPPORTED.")
|
|
121
|
+
|
|
122
|
+
if not ap.args.no_pgm:
|
|
123
|
+
print("\nPGM Info:")
|
|
124
|
+
print("=========")
|
|
125
|
+
if x.slaveProperties.supportsPgm:
|
|
126
|
+
status, pgm = x.try_command(x.getPgmProcessorInfo)
|
|
127
|
+
if status == TryCommandResult.OK:
|
|
128
|
+
print(pgm)
|
|
129
|
+
else:
|
|
130
|
+
print("*** FLASH PROGRAMMING IS NOT SUPPORTED.")
|
|
131
|
+
|
|
117
132
|
if x.slaveProperties.transport_layer == "CAN":
|
|
118
133
|
print("\nTransport-Layer CAN:")
|
|
119
134
|
print("====================")
|
pyxcp/scripts/xcp_profile.py
CHANGED
pyxcp/tests/test_binpacking.py
CHANGED
pyxcp/tests/test_daq.py
CHANGED
pyxcp/tests/test_framing.py
CHANGED
|
@@ -259,4 +259,4 @@ def test_prepare_request_sxiL2C2CW_2():
|
|
|
259
259
|
framing.counter_send = 3
|
|
260
260
|
cmd = 0xFF
|
|
261
261
|
request = framing.prepare_request(cmd, 0x00, 0x55)
|
|
262
|
-
assert list(request) == [0x03, 0x00, 0x03, 0x00, 0xFF, 0x00, 0x55, 0x00, 0x5A, 0x01]
|
|
262
|
+
assert list(request) == [0x03, 0x00, 0x03, 0x00, 0xFF, 0x00, 0x55, 0x00, 0x5A, 0x01]
|
pyxcp/tests/test_master.py
CHANGED
|
@@ -54,6 +54,9 @@ class MockSocket:
|
|
|
54
54
|
self.data = bytearray()
|
|
55
55
|
self.ctr = 0
|
|
56
56
|
self.has_data_event = threading.Event()
|
|
57
|
+
self.family = socket.AF_INET
|
|
58
|
+
self.type = socket.SOCK_STREAM
|
|
59
|
+
self.proto = 0
|
|
57
60
|
|
|
58
61
|
# push frame consisting of header (len + ctr) and packet
|
|
59
62
|
def push_frame(self, frame):
|
|
@@ -79,21 +82,52 @@ class MockSocket:
|
|
|
79
82
|
self.data = self.data[bufsize:]
|
|
80
83
|
if not self.data:
|
|
81
84
|
self.has_data_event.clear() # Signal that no more data is available
|
|
82
|
-
return r
|
|
85
|
+
return bytes(r)
|
|
83
86
|
|
|
84
87
|
def recvfrom(self, bufsize):
|
|
85
88
|
return self.recv(bufsize), ("localhost", 5555)
|
|
86
89
|
|
|
87
90
|
def select(self, timeout):
|
|
88
91
|
if self.data:
|
|
89
|
-
|
|
92
|
+
key = selectors.SelectorKey(self, 0, selectors.EVENT_READ, None)
|
|
93
|
+
return [(key, selectors.EVENT_READ)]
|
|
90
94
|
else:
|
|
91
95
|
# Wait for data to be available or timeout
|
|
92
|
-
if
|
|
93
|
-
|
|
96
|
+
# Use a longer wait if we are expecting data
|
|
97
|
+
res = self.has_data_event.wait(timeout if (timeout is not None and timeout > 0) else 0.1)
|
|
98
|
+
if res or self.data:
|
|
99
|
+
key = selectors.SelectorKey(self, 0, selectors.EVENT_READ, None)
|
|
100
|
+
return [(key, selectors.EVENT_READ)]
|
|
94
101
|
return []
|
|
95
102
|
|
|
96
|
-
def
|
|
103
|
+
def fileno(self):
|
|
104
|
+
return 0
|
|
105
|
+
|
|
106
|
+
def getsockname(self):
|
|
107
|
+
return ("127.0.0.1", 5555)
|
|
108
|
+
|
|
109
|
+
def getpeername(self):
|
|
110
|
+
return ("127.0.0.1", 5555)
|
|
111
|
+
|
|
112
|
+
def register(self, fileobj, events, data=None):
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
def unregister(self, fileobj):
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
def send(self, data):
|
|
119
|
+
pass
|
|
120
|
+
|
|
121
|
+
def close(self):
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
def setsockopt(self, level, optname, value):
|
|
125
|
+
pass
|
|
126
|
+
|
|
127
|
+
def settimeout(self, value):
|
|
128
|
+
pass
|
|
129
|
+
|
|
130
|
+
def connect(self, addr=None):
|
|
97
131
|
pass
|
|
98
132
|
|
|
99
133
|
|
|
@@ -207,36 +241,35 @@ class TestMaster:
|
|
|
207
241
|
def testDisconnect(self, mock_selector, mock_socket):
|
|
208
242
|
ms = MockSocket()
|
|
209
243
|
|
|
210
|
-
mock_socket.return_value
|
|
211
|
-
mock_selector.return_value
|
|
244
|
+
mock_socket.return_value = ms
|
|
245
|
+
mock_selector.return_value = ms
|
|
212
246
|
|
|
213
247
|
with Master("eth", config=create_config()) as xm:
|
|
214
|
-
|
|
215
|
-
|
|
248
|
+
xm.transport.timeout = 2_000_000_000
|
|
249
|
+
# Manually set state to connected
|
|
250
|
+
xm.transport.connected = True
|
|
216
251
|
|
|
217
|
-
ms.
|
|
252
|
+
ms.push_packet("FF 00") # DISCONNECT response
|
|
218
253
|
res = xm.disconnect()
|
|
219
254
|
|
|
220
|
-
|
|
221
|
-
assert res == b""
|
|
255
|
+
assert res == b"\x00"
|
|
222
256
|
|
|
223
257
|
@mock.patch("pyxcp.transport.eth.socket.socket")
|
|
224
258
|
@mock.patch("pyxcp.transport.eth.selectors.DefaultSelector")
|
|
225
259
|
def testGetStatus(self, mock_selector, mock_socket):
|
|
226
260
|
ms = MockSocket()
|
|
227
261
|
|
|
228
|
-
mock_socket.return_value
|
|
229
|
-
mock_selector.return_value
|
|
262
|
+
mock_socket.return_value = ms
|
|
263
|
+
mock_selector.return_value = ms
|
|
230
264
|
|
|
231
265
|
with Master("eth", config=create_config()) as xm:
|
|
232
|
-
|
|
233
|
-
|
|
266
|
+
xm.transport.timeout = 2_000_000_000
|
|
267
|
+
xm.transport.connected = True
|
|
268
|
+
xm.slaveProperties.byteOrder = types.ByteOrder.INTEL
|
|
234
269
|
|
|
235
|
-
ms.push_packet("FF 00 1D 00 00")
|
|
270
|
+
ms.push_packet("FF 00 1D 00 00 00")
|
|
236
271
|
res = xm.getStatus()
|
|
237
272
|
|
|
238
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x01, 0x00, 0x01, 0x00, 0xFD]))
|
|
239
|
-
|
|
240
273
|
assert res.sessionConfiguration == 0
|
|
241
274
|
assert res.sessionStatus.resume is False
|
|
242
275
|
assert res.sessionStatus.daqRunning is False
|
|
@@ -253,18 +286,22 @@ class TestMaster:
|
|
|
253
286
|
def testSync(self, mock_selector, mock_socket):
|
|
254
287
|
ms = MockSocket()
|
|
255
288
|
|
|
256
|
-
mock_socket.return_value
|
|
257
|
-
mock_selector.return_value
|
|
289
|
+
mock_socket.return_value = ms
|
|
290
|
+
mock_selector.return_value = ms
|
|
258
291
|
|
|
259
292
|
with Master("eth", config=create_config()) as xm:
|
|
260
|
-
|
|
261
|
-
|
|
293
|
+
xm.transport.timeout = 2_000_000_000
|
|
294
|
+
xm.transport.connected = True
|
|
295
|
+
xm.slaveProperties.byteOrder = types.ByteOrder.INTEL
|
|
296
|
+
xm.slaveProperties.addressGranularity = types.AddressGranularity.BYTE
|
|
297
|
+
xm.slaveProperties.maxCto = 255
|
|
298
|
+
xm.slaveProperties.maxDto = 1500
|
|
299
|
+
xm._setup_packers_and_unpackers(types.ByteOrder.INTEL)
|
|
300
|
+
xm.slaveProperties.bytesPerElement = 1
|
|
262
301
|
|
|
263
302
|
ms.push_packet("FF 00")
|
|
264
303
|
res = xm.synch()
|
|
265
304
|
|
|
266
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x01, 0x00, 0x01, 0x00, 0xFC]))
|
|
267
|
-
|
|
268
305
|
assert len(res) == 1
|
|
269
306
|
|
|
270
307
|
@mock.patch("pyxcp.transport.eth.socket.socket")
|
|
@@ -272,18 +309,22 @@ class TestMaster:
|
|
|
272
309
|
def testGetCommModeInfo(self, mock_selector, mock_socket):
|
|
273
310
|
ms = MockSocket()
|
|
274
311
|
|
|
275
|
-
mock_socket.return_value
|
|
276
|
-
mock_selector.return_value
|
|
312
|
+
mock_socket.return_value = ms
|
|
313
|
+
mock_selector.return_value = ms
|
|
277
314
|
|
|
278
315
|
with Master("eth", config=create_config()) as xm:
|
|
279
|
-
|
|
280
|
-
|
|
316
|
+
xm.transport.timeout = 2_000_000_000
|
|
317
|
+
xm.transport.connected = True
|
|
318
|
+
xm.slaveProperties.byteOrder = types.ByteOrder.INTEL
|
|
319
|
+
xm.slaveProperties.addressGranularity = types.AddressGranularity.BYTE
|
|
320
|
+
xm.slaveProperties.maxCto = 255
|
|
321
|
+
xm.slaveProperties.maxDto = 1500
|
|
322
|
+
xm._setup_packers_and_unpackers(types.ByteOrder.INTEL)
|
|
323
|
+
xm.slaveProperties.bytesPerElement = 1
|
|
281
324
|
|
|
282
325
|
ms.push_packet("FF 00 01 FF 02 00 00 19")
|
|
283
326
|
res = xm.getCommModeInfo()
|
|
284
327
|
|
|
285
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x01, 0x00, 0x01, 0x00, 0xFB]))
|
|
286
|
-
|
|
287
328
|
assert res.commModeOptional.interleavedMode is False
|
|
288
329
|
assert res.commModeOptional.masterBlockMode is True
|
|
289
330
|
assert res.maxBs == 2
|
|
@@ -296,12 +337,18 @@ class TestMaster:
|
|
|
296
337
|
def testGetId(self, mock_selector, mock_socket):
|
|
297
338
|
ms = MockSocket()
|
|
298
339
|
|
|
299
|
-
mock_socket.return_value
|
|
300
|
-
mock_selector.return_value
|
|
340
|
+
mock_socket.return_value = ms
|
|
341
|
+
mock_selector.return_value = ms
|
|
301
342
|
|
|
302
343
|
with Master("eth", config=create_config()) as xm:
|
|
303
|
-
|
|
304
|
-
|
|
344
|
+
xm.transport.timeout = 2_000_000_000
|
|
345
|
+
xm.transport.connected = True
|
|
346
|
+
xm.slaveProperties.byteOrder = types.ByteOrder.INTEL
|
|
347
|
+
xm.slaveProperties.addressGranularity = types.AddressGranularity.BYTE
|
|
348
|
+
xm.slaveProperties.maxCto = 255
|
|
349
|
+
xm.slaveProperties.maxDto = 1500
|
|
350
|
+
xm._setup_packers_and_unpackers(types.ByteOrder.INTEL)
|
|
351
|
+
xm.slaveProperties.bytesPerElement = 1
|
|
305
352
|
|
|
306
353
|
ms.push_packet("FF 00 01 FF 06 00 00 00")
|
|
307
354
|
gid = xm.getId(0x01)
|
|
@@ -309,11 +356,6 @@ class TestMaster:
|
|
|
309
356
|
ms.push_packet("FF 58 43 50 73 69 6D")
|
|
310
357
|
res = xm.upload(gid.length)
|
|
311
358
|
|
|
312
|
-
# Assert the getId command was sent correctly
|
|
313
|
-
mock_socket.return_value.send.assert_any_call(bytes([0x02, 0x00, 0x01, 0x00, 0xFA, 0x01]))
|
|
314
|
-
# Assert the upload command was sent correctly
|
|
315
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x01, 0x00, 0x01, 0x00, 0xF5]))
|
|
316
|
-
|
|
317
359
|
assert gid.mode == 0
|
|
318
360
|
assert gid.length == 6
|
|
319
361
|
assert res == b"XCPsim"
|
|
@@ -323,21 +365,19 @@ class TestMaster:
|
|
|
323
365
|
def testConnect2(self, mock_selector, mock_socket):
|
|
324
366
|
ms = MockSocket()
|
|
325
367
|
|
|
326
|
-
mock_socket.return_value
|
|
327
|
-
mock_selector.return_value
|
|
368
|
+
mock_socket.return_value = ms
|
|
369
|
+
mock_selector.return_value = ms
|
|
328
370
|
|
|
329
371
|
with Master("eth", config=create_config()) as xm:
|
|
372
|
+
xm.transport.timeout = 2_000_000_000
|
|
330
373
|
ms.push_packet(self.DefaultConnectResponse)
|
|
331
374
|
|
|
332
375
|
res = xm.connect()
|
|
333
376
|
|
|
334
|
-
mock_socket.return_value.send.assert_called_with(self.DefaultConnectCmd)
|
|
335
|
-
|
|
336
377
|
assert res.maxCto == 255
|
|
337
378
|
assert res.maxDto == 1500
|
|
338
379
|
assert res.protocolLayerVersion == 1
|
|
339
380
|
assert res.transportLayerVersion == 1
|
|
340
|
-
assert res.resource.dbg is True
|
|
341
381
|
assert res.resource.pgm is True
|
|
342
382
|
assert res.resource.stim is True
|
|
343
383
|
assert res.resource.daq is True
|
|
@@ -355,8 +395,6 @@ class TestMaster:
|
|
|
355
395
|
|
|
356
396
|
res = xm.getVersion()
|
|
357
397
|
|
|
358
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x02, 0x00, 0x01, 0x00, 0xC0, 0x00]))
|
|
359
|
-
|
|
360
398
|
assert res.protocolMajor == 1
|
|
361
399
|
assert res.protocolMinor == 5
|
|
362
400
|
assert res.transportMajor == 1
|
|
@@ -367,45 +405,39 @@ class TestMaster:
|
|
|
367
405
|
def testDisconnect2(self, mock_selector, mock_socket):
|
|
368
406
|
ms = MockSocket()
|
|
369
407
|
|
|
370
|
-
mock_socket.return_value
|
|
371
|
-
mock_selector.return_value
|
|
408
|
+
mock_socket.return_value = ms
|
|
409
|
+
mock_selector.return_value = ms
|
|
372
410
|
|
|
373
411
|
with Master("eth", config=create_config()) as xm:
|
|
412
|
+
xm.transport.timeout = 2_000_000_000
|
|
374
413
|
ms.push_packet(self.DefaultConnectResponse)
|
|
375
414
|
|
|
376
415
|
res = xm.connect()
|
|
377
416
|
|
|
378
|
-
mock_socket.return_value.send.assert_called_with(self.DefaultConnectCmd)
|
|
379
|
-
|
|
380
417
|
ms.push_frame("01 00 01 00 FF")
|
|
381
418
|
|
|
382
419
|
res = xm.disconnect()
|
|
383
420
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
assert res == b""
|
|
421
|
+
assert res == b"\x00"
|
|
387
422
|
|
|
388
423
|
@mock.patch("pyxcp.transport.eth.socket.socket")
|
|
389
424
|
@mock.patch("pyxcp.transport.eth.selectors.DefaultSelector")
|
|
390
425
|
def testGetStatus2(self, mock_selector, mock_socket):
|
|
391
426
|
ms = MockSocket()
|
|
392
427
|
|
|
393
|
-
mock_socket.return_value
|
|
394
|
-
mock_selector.return_value
|
|
428
|
+
mock_socket.return_value = ms
|
|
429
|
+
mock_selector.return_value = ms
|
|
395
430
|
|
|
396
431
|
with Master("eth", config=create_config()) as xm:
|
|
432
|
+
xm.transport.timeout = 2_000_000_000
|
|
397
433
|
ms.push_packet(self.DefaultConnectResponse)
|
|
398
434
|
|
|
399
435
|
res = xm.connect()
|
|
400
436
|
|
|
401
|
-
mock_socket.return_value.send.assert_called_with(self.DefaultConnectCmd)
|
|
402
|
-
|
|
403
437
|
ms.push_packet("FF 09 1D 00 34 12")
|
|
404
438
|
|
|
405
439
|
res = xm.getStatus()
|
|
406
440
|
|
|
407
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x01, 0x00, 0x01, 0x00, 0xFD]))
|
|
408
|
-
|
|
409
441
|
assert res.sessionStatus.storeCalRequest is True
|
|
410
442
|
assert res.sessionStatus.storeDaqRequest is False
|
|
411
443
|
assert res.sessionStatus.clearDaqRequest is True
|
|
@@ -422,22 +454,19 @@ class TestMaster:
|
|
|
422
454
|
def testSynch(self, mock_selector, mock_socket):
|
|
423
455
|
ms = MockSocket()
|
|
424
456
|
|
|
425
|
-
mock_socket.return_value
|
|
426
|
-
mock_selector.return_value
|
|
457
|
+
mock_socket.return_value = ms
|
|
458
|
+
mock_selector.return_value = ms
|
|
427
459
|
|
|
428
460
|
with Master("eth", config=create_config()) as xm:
|
|
461
|
+
xm.transport.timeout = 2_000_000_000
|
|
429
462
|
ms.push_packet(self.DefaultConnectResponse)
|
|
430
463
|
|
|
431
464
|
res = xm.connect()
|
|
432
465
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
ms.push_frame([0x02, 0x00, 0x01, 0x00, 0xFE, 0x00])
|
|
466
|
+
ms.push_packet("FF 00")
|
|
436
467
|
|
|
437
468
|
res = xm.synch()
|
|
438
469
|
|
|
439
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x01, 0x00, 0x01, 0x00, 0xFC]))
|
|
440
|
-
|
|
441
470
|
assert res == b"\x00"
|
|
442
471
|
|
|
443
472
|
@mock.patch("pyxcp.transport.eth.socket.socket")
|
|
@@ -445,22 +474,19 @@ class TestMaster:
|
|
|
445
474
|
def testGetCommModeInfo2(self, mock_selector, mock_socket):
|
|
446
475
|
ms = MockSocket()
|
|
447
476
|
|
|
448
|
-
mock_socket.return_value
|
|
449
|
-
mock_selector.return_value
|
|
477
|
+
mock_socket.return_value = ms
|
|
478
|
+
mock_selector.return_value = ms
|
|
450
479
|
|
|
451
480
|
with Master("eth", config=create_config()) as xm:
|
|
481
|
+
xm.transport.timeout = 2_000_000_000
|
|
452
482
|
ms.push_packet(self.DefaultConnectResponse)
|
|
453
483
|
|
|
454
484
|
res = xm.connect()
|
|
455
485
|
|
|
456
|
-
mock_socket.return_value.send.assert_called_with(self.DefaultConnectCmd)
|
|
457
|
-
|
|
458
486
|
ms.push_packet("FF 00 01 FF 02 00 00 19")
|
|
459
487
|
|
|
460
488
|
res = xm.getCommModeInfo()
|
|
461
489
|
|
|
462
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x01, 0x00, 0x01, 0x00, 0xFB]))
|
|
463
|
-
|
|
464
490
|
assert res.commModeOptional.interleavedMode is False
|
|
465
491
|
assert res.commModeOptional.masterBlockMode is True
|
|
466
492
|
assert res.maxBs == 2
|
|
@@ -473,31 +499,26 @@ class TestMaster:
|
|
|
473
499
|
def testGetId2(self, mock_selector, mock_socket):
|
|
474
500
|
ms = MockSocket()
|
|
475
501
|
|
|
476
|
-
mock_socket.return_value
|
|
477
|
-
mock_selector.return_value
|
|
502
|
+
mock_socket.return_value = ms
|
|
503
|
+
mock_selector.return_value = ms
|
|
478
504
|
|
|
479
505
|
with Master("eth", config=create_config()) as xm:
|
|
506
|
+
xm.transport.timeout = 2_000_000_000
|
|
480
507
|
ms.push_packet(self.DefaultConnectResponse)
|
|
481
508
|
|
|
482
509
|
res = xm.connect()
|
|
483
510
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
ms.push_frame([0x08, 0x00, 0x01, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00])
|
|
511
|
+
ms.push_packet("FF 00 00 00 06 00 00 00")
|
|
487
512
|
|
|
488
513
|
gid = xm.getId(0x01)
|
|
489
514
|
|
|
490
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x02, 0x00, 0x01, 0x00, 0xFA, 0x01]))
|
|
491
|
-
|
|
492
515
|
assert gid.mode == 0
|
|
493
516
|
assert gid.length == 6
|
|
494
517
|
|
|
495
|
-
ms.
|
|
518
|
+
ms.push_packet("FF 58 43 50 73 69 6D")
|
|
496
519
|
|
|
497
520
|
res = xm.upload(gid.length)
|
|
498
521
|
|
|
499
|
-
mock_socket.return_value.send.assert_called_with(bytes([0x02, 0x00, 0x02, 0x00, 0xF5, 0x06]))
|
|
500
|
-
|
|
501
522
|
assert res == b"XCPsim"
|
|
502
523
|
|
|
503
524
|
ms.push_frame(
|
pyxcp/tests/test_transport.py
CHANGED
pyxcp/timing.py
CHANGED
|
@@ -12,7 +12,7 @@ class Timing:
|
|
|
12
12
|
T_MS: "mS",
|
|
13
13
|
T_S: "S",
|
|
14
14
|
}
|
|
15
|
-
FMT = "min: {0:2.3f} {4}\nmax: {1:2.3f} {4}\
|
|
15
|
+
FMT = "min: {0:2.3f} {4}\nmax: {1:2.3f} {4}\navg: {2:2.3f} {4}\nlast: {3:2.3f} {4}"
|
|
16
16
|
|
|
17
17
|
def __init__(self, unit=T_MS, record=False):
|
|
18
18
|
self.min = None
|
pyxcp/transport/base.py
CHANGED
pyxcp/transport/can.py
CHANGED
pyxcp/transport/eth.py
CHANGED