pyxcp 0.21.9__cp312-cp312-win_amd64.whl → 0.22.23__cp312-cp312-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 (182) 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.cp310-win_amd64.pyd +0 -0
  21. pyxcp/cpp_ext/cpp_ext.cp311-win_amd64.pyd +0 -0
  22. pyxcp/cpp_ext/cpp_ext.cp312-win_amd64.pyd +0 -0
  23. pyxcp/cpp_ext/cpp_ext.cp38-win_amd64.pyd +0 -0
  24. pyxcp/cpp_ext/cpp_ext.cp39-win_amd64.pyd +0 -0
  25. pyxcp/cpp_ext/daqlist.hpp +200 -0
  26. pyxcp/cpp_ext/event.hpp +67 -0
  27. pyxcp/cpp_ext/extension_wrapper.cpp +96 -0
  28. pyxcp/cpp_ext/helper.hpp +280 -0
  29. pyxcp/cpp_ext/mcobject.hpp +246 -0
  30. pyxcp/cpp_ext/tsqueue.hpp +46 -0
  31. pyxcp/daq_stim/__init__.py +228 -0
  32. pyxcp/daq_stim/optimize/__init__.py +67 -0
  33. pyxcp/daq_stim/optimize/binpacking.py +41 -0
  34. pyxcp/daq_stim/scheduler.cpp +28 -0
  35. pyxcp/daq_stim/scheduler.hpp +75 -0
  36. pyxcp/daq_stim/stim.cp310-win_amd64.pyd +0 -0
  37. pyxcp/daq_stim/stim.cp311-win_amd64.pyd +0 -0
  38. pyxcp/daq_stim/stim.cp312-win_amd64.pyd +0 -0
  39. pyxcp/daq_stim/stim.cp38-win_amd64.pyd +0 -0
  40. pyxcp/daq_stim/stim.cp39-win_amd64.pyd +0 -0
  41. pyxcp/daq_stim/stim.cpp +13 -0
  42. pyxcp/daq_stim/stim.hpp +604 -0
  43. pyxcp/daq_stim/stim_wrapper.cpp +48 -0
  44. pyxcp/dllif.py +21 -18
  45. pyxcp/errormatrix.py +5 -3
  46. pyxcp/examples/conf_can.toml +4 -2
  47. pyxcp/examples/conf_can_vector.json +9 -9
  48. pyxcp/examples/conf_can_vector.toml +4 -2
  49. pyxcp/examples/conf_eth.toml +5 -2
  50. pyxcp/examples/conf_nixnet.json +18 -18
  51. pyxcp/examples/conf_sxi.json +7 -7
  52. pyxcp/examples/ex_arrow.py +109 -0
  53. pyxcp/examples/ex_csv.py +85 -0
  54. pyxcp/examples/ex_excel.py +95 -0
  55. pyxcp/examples/ex_mdf.py +124 -0
  56. pyxcp/examples/ex_sqlite.py +128 -0
  57. pyxcp/examples/run_daq.py +148 -0
  58. pyxcp/examples/xcp_policy.py +6 -7
  59. pyxcp/examples/xcp_read_benchmark.py +8 -6
  60. pyxcp/examples/xcp_skel.py +0 -2
  61. pyxcp/examples/xcp_unlock.py +1 -1
  62. pyxcp/examples/xcp_user_supplied_driver.py +1 -2
  63. pyxcp/examples/xcphello.py +6 -3
  64. pyxcp/examples/xcphello_recorder.py +4 -4
  65. pyxcp/master/__init__.py +1 -2
  66. pyxcp/master/errorhandler.py +107 -74
  67. pyxcp/master/master.py +196 -114
  68. pyxcp/py.typed +0 -0
  69. pyxcp/recorder/__init__.py +27 -6
  70. pyxcp/recorder/converter/__init__.py +37 -0
  71. pyxcp/recorder/lz4.c +129 -51
  72. pyxcp/recorder/lz4.h +45 -28
  73. pyxcp/recorder/lz4hc.c +560 -156
  74. pyxcp/recorder/lz4hc.h +1 -1
  75. pyxcp/recorder/mio.hpp +721 -767
  76. pyxcp/recorder/reader.hpp +139 -0
  77. pyxcp/recorder/reco.py +5 -8
  78. pyxcp/recorder/rekorder.cp310-win_amd64.pyd +0 -0
  79. pyxcp/recorder/rekorder.cp311-win_amd64.pyd +0 -0
  80. pyxcp/recorder/rekorder.cp312-win_amd64.pyd +0 -0
  81. pyxcp/recorder/rekorder.cp38-win_amd64.pyd +0 -0
  82. pyxcp/recorder/rekorder.cp39-win_amd64.pyd +0 -0
  83. pyxcp/recorder/rekorder.cpp +18 -22
  84. pyxcp/recorder/rekorder.hpp +200 -587
  85. pyxcp/recorder/setup.py +11 -10
  86. pyxcp/recorder/test_reko.py +2 -3
  87. pyxcp/recorder/unfolder.hpp +1332 -0
  88. pyxcp/recorder/wrap.cpp +171 -9
  89. pyxcp/recorder/writer.hpp +302 -0
  90. pyxcp/scripts/pyxcp_probe_can_drivers.py +0 -2
  91. pyxcp/scripts/xcp_examples.py +64 -0
  92. pyxcp/scripts/xcp_fetch_a2l.py +15 -10
  93. pyxcp/scripts/xcp_id_scanner.py +2 -6
  94. pyxcp/scripts/xcp_info.py +101 -63
  95. pyxcp/scripts/xcp_profile.py +27 -0
  96. pyxcp/stim/__init__.py +0 -0
  97. pyxcp/tests/test_asam_types.py +2 -2
  98. pyxcp/tests/test_binpacking.py +186 -0
  99. pyxcp/tests/test_can.py +1132 -38
  100. pyxcp/tests/test_checksum.py +2 -1
  101. pyxcp/tests/test_daq.py +193 -0
  102. pyxcp/tests/test_frame_padding.py +6 -3
  103. pyxcp/tests/test_master.py +42 -31
  104. pyxcp/tests/test_transport.py +12 -12
  105. pyxcp/tests/test_utils.py +2 -5
  106. pyxcp/timing.py +0 -2
  107. pyxcp/transport/__init__.py +9 -9
  108. pyxcp/transport/base.py +149 -127
  109. pyxcp/transport/base_transport.hpp +0 -0
  110. pyxcp/transport/can.py +194 -167
  111. pyxcp/transport/eth.py +80 -82
  112. pyxcp/transport/sxi.py +106 -60
  113. pyxcp/transport/transport_wrapper.cpp +0 -0
  114. pyxcp/transport/usb_transport.py +65 -83
  115. pyxcp/types.py +69 -20
  116. pyxcp/utils.py +47 -16
  117. pyxcp/vector/map.py +1 -3
  118. {pyxcp-0.21.9.dist-info → pyxcp-0.22.23.dist-info}/METADATA +28 -23
  119. pyxcp-0.22.23.dist-info/RECORD +140 -0
  120. {pyxcp-0.21.9.dist-info → pyxcp-0.22.23.dist-info}/WHEEL +1 -1
  121. {pyxcp-0.21.9.dist-info → pyxcp-0.22.23.dist-info}/entry_points.txt +2 -0
  122. pyxcp/config.py +0 -57
  123. pyxcp/cxx/asynchiofactory.hpp +0 -24
  124. pyxcp/cxx/blocking_client.cpp +0 -44
  125. pyxcp/cxx/blocking_socket.cpp +0 -43
  126. pyxcp/cxx/blocking_socket.hpp +0 -558
  127. pyxcp/cxx/concurrent_queue.hpp +0 -60
  128. pyxcp/cxx/eth.hpp +0 -57
  129. pyxcp/cxx/exceptions.hpp +0 -30
  130. pyxcp/cxx/iasyncioservice.hpp +0 -31
  131. pyxcp/cxx/iresource.hpp +0 -17
  132. pyxcp/cxx/isocket.hpp +0 -22
  133. pyxcp/cxx/linux/epoll.cpp +0 -51
  134. pyxcp/cxx/linux/epoll.hpp +0 -87
  135. pyxcp/cxx/linux/lit_tester.cpp +0 -19
  136. pyxcp/cxx/linux/socket.hpp +0 -234
  137. pyxcp/cxx/linux/timeout.hpp +0 -81
  138. pyxcp/cxx/memoryblock.hpp +0 -42
  139. pyxcp/cxx/pool.hpp +0 -81
  140. pyxcp/cxx/poolmgr.cpp +0 -6
  141. pyxcp/cxx/poolmgr.hpp +0 -31
  142. pyxcp/cxx/test_queue.cpp +0 -69
  143. pyxcp/cxx/timestamp.hpp +0 -84
  144. pyxcp/cxx/utils.cpp +0 -38
  145. pyxcp/cxx/utils.hpp +0 -29
  146. pyxcp/cxx/win/iocp.cpp +0 -242
  147. pyxcp/cxx/win/iocp.hpp +0 -42
  148. pyxcp/cxx/win/perhandledata.hpp +0 -24
  149. pyxcp/cxx/win/periodata.hpp +0 -97
  150. pyxcp/cxx/win/socket.hpp +0 -185
  151. pyxcp/cxx/win/timeout.hpp +0 -83
  152. pyxcp/examples/conf_can.json +0 -20
  153. pyxcp/examples/conf_eth.json +0 -8
  154. pyxcp/logger.py +0 -67
  155. pyxcp/tests/test_config.py +0 -62
  156. pyxcp/transport/candriver/__init__.py +0 -2
  157. pyxcp/transport/candriver/pc_canalystii.py +0 -27
  158. pyxcp/transport/candriver/pc_etas.py +0 -25
  159. pyxcp/transport/candriver/pc_gsusb.py +0 -23
  160. pyxcp/transport/candriver/pc_iscan.py +0 -23
  161. pyxcp/transport/candriver/pc_ixxat.py +0 -27
  162. pyxcp/transport/candriver/pc_kvaser.py +0 -39
  163. pyxcp/transport/candriver/pc_neovi.py +0 -31
  164. pyxcp/transport/candriver/pc_nican.py +0 -23
  165. pyxcp/transport/candriver/pc_nixnet.py +0 -23
  166. pyxcp/transport/candriver/pc_pcan.py +0 -25
  167. pyxcp/transport/candriver/pc_seeed.py +0 -28
  168. pyxcp/transport/candriver/pc_serial.py +0 -27
  169. pyxcp/transport/candriver/pc_slcan.py +0 -29
  170. pyxcp/transport/candriver/pc_socketcan.py +0 -23
  171. pyxcp/transport/candriver/pc_systec.py +0 -29
  172. pyxcp/transport/candriver/pc_usb2can.py +0 -30
  173. pyxcp/transport/candriver/pc_vector.py +0 -34
  174. pyxcp/transport/candriver/python_can.py +0 -101
  175. pyxcp/transport/cxx_ext/CMakeLists.txt +0 -51
  176. pyxcp/transport/cxx_ext/setup.py +0 -49
  177. pyxcp/transport/cxx_ext/tests/test_basic_socket.cpp +0 -39
  178. pyxcp/transport/cxx_ext/tests/test_pool.cpp +0 -39
  179. pyxcp/transport/cxx_ext/tests/test_timestamp.cpp +0 -27
  180. pyxcp-0.21.9.dist-info/RECORD +0 -147
  181. rekorder.cp312-win_amd64.pyd +0 -0
  182. {pyxcp-0.21.9.dist-info/licenses → pyxcp-0.22.23.dist-info}/LICENSE +0 -0
@@ -1,6 +1,7 @@
1
+ import pytest
2
+
1
3
  from pyxcp import checksum
2
4
 
3
- import pytest
4
5
 
5
6
  """
6
7
  XCP_ADD_11 0x10 0x10
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env python
2
+
3
+ from pyxcp.daq_stim import DaqList, DaqProcessor
4
+
5
+
6
+ DAQ_INFO = {
7
+ "channels": [
8
+ {
9
+ "cycle": 0,
10
+ "maxDaqList": 1,
11
+ "name": "Key T",
12
+ "priority": 0,
13
+ "properties": {"consistency": "CONSISTENCY_ODT", "daq": True, "packed": False, "stim": False},
14
+ "unit": "EVENT_CHANNEL_TIME_UNIT_1MS",
15
+ },
16
+ {
17
+ "cycle": 10,
18
+ "maxDaqList": 1,
19
+ "name": "10 ms",
20
+ "priority": 1,
21
+ "properties": {"consistency": "CONSISTENCY_ODT", "daq": True, "packed": False, "stim": True},
22
+ "unit": "EVENT_CHANNEL_TIME_UNIT_1MS",
23
+ },
24
+ {
25
+ "cycle": 100,
26
+ "maxDaqList": 1,
27
+ "name": "100ms",
28
+ "priority": 2,
29
+ "properties": {"consistency": "CONSISTENCY_ODT", "daq": True, "packed": False, "stim": True},
30
+ "unit": "EVENT_CHANNEL_TIME_UNIT_1MS",
31
+ },
32
+ {
33
+ "cycle": 1,
34
+ "maxDaqList": 1,
35
+ "name": "1ms",
36
+ "priority": 3,
37
+ "properties": {"consistency": "CONSISTENCY_ODT", "daq": True, "packed": False, "stim": True},
38
+ "unit": "EVENT_CHANNEL_TIME_UNIT_1MS",
39
+ },
40
+ {
41
+ "cycle": 10,
42
+ "maxDaqList": 1,
43
+ "name": "FilterBypassDaq",
44
+ "priority": 4,
45
+ "properties": {"consistency": "CONSISTENCY_ODT", "daq": True, "packed": False, "stim": True},
46
+ "unit": "EVENT_CHANNEL_TIME_UNIT_1MS",
47
+ },
48
+ {
49
+ "cycle": 10,
50
+ "maxDaqList": 1,
51
+ "name": "FilterBypassStim",
52
+ "priority": 5,
53
+ "properties": {"consistency": "CONSISTENCY_ODT", "daq": False, "packed": False, "stim": True},
54
+ "unit": "EVENT_CHANNEL_TIME_UNIT_1MS",
55
+ },
56
+ ],
57
+ "processor": {
58
+ "keyByte": {
59
+ "addressExtension": "AE_DIFFERENT_WITHIN_ODT",
60
+ "identificationField": "IDF_REL_ODT_NUMBER_ABS_DAQ_LIST_NUMBER_BYTE",
61
+ "optimisationType": "OM_DEFAULT",
62
+ },
63
+ "maxDaq": 0,
64
+ "minDaq": 0,
65
+ "properties": {
66
+ "bitStimSupported": False,
67
+ "configType": "DYNAMIC",
68
+ "overloadEvent": False,
69
+ "overloadMsb": True,
70
+ "pidOffSupported": False,
71
+ "prescalerSupported": True,
72
+ "resumeSupported": True,
73
+ "timestampSupported": True,
74
+ },
75
+ },
76
+ "resolution": {
77
+ "granularityOdtEntrySizeDaq": 1,
78
+ "granularityOdtEntrySizeStim": 1,
79
+ "maxOdtEntrySizeDaq": 218,
80
+ "maxOdtEntrySizeStim": 218,
81
+ "timestampMode": {"fixed": False, "size": "S4", "unit": "DAQ_TIMESTAMP_UNIT_10US"},
82
+ "timestampTicks": 10,
83
+ },
84
+ }
85
+
86
+ SLAVE_INFO = {
87
+ "addressGranularity": 0,
88
+ "byteOrder": 0,
89
+ "interleavedMode": False,
90
+ "masterBlockMode": True,
91
+ "maxBs": 2,
92
+ "maxCto": 255,
93
+ "maxDto": 1500,
94
+ "maxWriteDaqMultipleElements": 31,
95
+ "minSt": 0,
96
+ "optionalCommMode": True,
97
+ "pgmProcessor": {},
98
+ "protocolLayerVersion": 1,
99
+ "queueSize": 0,
100
+ "slaveBlockMode": True,
101
+ "supportsCalpag": True,
102
+ "supportsDaq": True,
103
+ "supportsPgm": True,
104
+ "supportsStim": True,
105
+ "transportLayerVersion": 1,
106
+ "xcpDriverVersionNumber": 25,
107
+ }
108
+
109
+
110
+ class AttrDict(dict):
111
+ def __getattr__(self, name):
112
+ return self[name]
113
+
114
+
115
+ class MockMaster:
116
+ def __init__(self):
117
+ self.slaveProperties = AttrDict(
118
+ {
119
+ "maxDto": 1500,
120
+ "supportsDaq": True,
121
+ }
122
+ )
123
+
124
+ def getDaqInfo(self):
125
+ return DAQ_INFO
126
+
127
+ def freeDaq(self):
128
+ pass
129
+
130
+ def allocDaq(self, daq_count):
131
+ self.daq_count = daq_count
132
+
133
+ def allocOdt(self, daq_num, odt_count):
134
+ pass
135
+
136
+ def allocOdtEntry(self, daq_num, odt_num, entry_count):
137
+ pass
138
+
139
+ def setDaqPtr(self, daqListNumber, odtNumber, odtEntryNumber):
140
+ pass
141
+
142
+ def writeDaq(self, bitOffset, entrySize, addressExt, address):
143
+ pass
144
+
145
+ def setDaqListMode(self, mode, daqListNumber, eventChannelNumber, prescaler, priority):
146
+ pass
147
+
148
+ def startStopDaqList(self, mode, daqListNumber):
149
+ pass
150
+
151
+ def startStopSynch(self, mode):
152
+ pass
153
+
154
+
155
+ DAQ_LISTS = [
156
+ DaqList(
157
+ "list1",
158
+ 1,
159
+ False,
160
+ True,
161
+ [
162
+ ("channel1", 0x1BD004, 0, "U32"),
163
+ ("channel2", 0x1BD008, 0, "U32"),
164
+ ("PWMFiltered", 0x1BDDE2, 0, "U8"),
165
+ ("PWM", 0x1BDDDF, 0, "U8"),
166
+ ("Triangle", 0x1BDDDE, 0, "U8"),
167
+ ],
168
+ ),
169
+ DaqList(
170
+ "list2",
171
+ 3,
172
+ False,
173
+ True,
174
+ [
175
+ ("TestWord_002", 0x1BE124, 0, "U16"),
176
+ ("TestWord_003", 0x1BE128, 0, "U16"),
177
+ ("TestWord_001", 0x1BE120, 0, "U16"),
178
+ ("TestWord_003", 0x1BE128, 0, "U16"),
179
+ ("TestWord_004", 0x1BE12C, 0, "U16"),
180
+ ("TestWord_005", 0x1BE134, 0, "U16"),
181
+ ("TestWord_006", 0x1BE134, 0, "U16"),
182
+ ("TestWord_007", 0x1BE138, 0, "U16"),
183
+ ("TestWord_008", 0x1BE13C, 0, "U16"),
184
+ ("TestWord_009", 0x1BE140, 0, "U16"),
185
+ ("TestWord_011", 0x1BE148, 0, "U16"),
186
+ ],
187
+ ),
188
+ ]
189
+
190
+ # daq = DaqProcessor(DAQ_LISTS)
191
+ # daq.set_master(MockMaster())
192
+ # daq.setup()
193
+ # daq.start()
@@ -1,4 +1,6 @@
1
- from pyxcp.transport.can import padFrame
1
+ import pytest
2
+
3
+ from pyxcp.transport.can import pad_frame
2
4
 
3
5
 
4
6
  def test_frame_padding_no_padding_length():
@@ -71,12 +73,13 @@ def test_frame_padding_no_padding_length():
71
73
  )
72
74
  for frame_len in range(65):
73
75
  frame = bytes(frame_len)
74
- padded_frame = padFrame(frame, padding_value=0, padding_len=0)
76
+ padded_frame = pad_frame(frame, padding_value=0, pad_frame=True)
75
77
  frame_len = len(padded_frame)
76
78
  _, expected_len = EXPECTED[frame_len]
77
79
  assert frame_len == expected_len
78
80
 
79
81
 
82
+ @pytest.mark.skip
80
83
  def test_frame_padding_padding_length32():
81
84
  EXPECTED = (
82
85
  (0, 32),
@@ -147,7 +150,7 @@ def test_frame_padding_padding_length32():
147
150
  )
148
151
  for frame_len in range(65):
149
152
  frame = bytes(frame_len)
150
- padded_frame = padFrame(frame, padding_value=0, padding_len=32)
153
+ padded_frame = pad_frame(frame, padding_value=0, pad_frame=True)
151
154
  frame_len = len(padded_frame)
152
155
  _, expected_len = EXPECTED[frame_len]
153
156
  assert frame_len == expected_len
@@ -1,12 +1,24 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
2
  import struct
4
3
  import time
5
4
  from collections import deque
5
+ from unittest import mock
6
+
6
7
  from pyxcp import types
7
8
  from pyxcp.master import Master
8
- from pyxcp.transport.can import CanInterfaceBase
9
- from unittest import mock
9
+
10
+
11
+ def create_config():
12
+ # Exception: XCPonEth - Failed to resolve address <MagicMock name='mock.transport.eth.host' id='2414047113872'>:<MagicMock name='mock.transport.eth.port' id='2414047478992'>
13
+ config = mock.MagicMock()
14
+ config.general.return_value = mock.MagicMock()
15
+ config.transport.return_value = mock.MagicMock()
16
+ config.transport.eth.return_value = mock.MagicMock()
17
+ config.transport.eth.host = "localhost"
18
+ config.transport.eth.port = 5555
19
+ config.transport.eth.bind_to_address = ""
20
+ config.transport.eth.bind_to_port = 0
21
+ return config
10
22
 
11
23
 
12
24
  class MockSocket:
@@ -48,7 +60,7 @@ class MockSocket:
48
60
  pass
49
61
 
50
62
 
51
- class MockCanInterface(CanInterfaceBase):
63
+ class MockCanInterface: # CanInterfaceBase
52
64
  def __init__(self):
53
65
  self.data = deque()
54
66
  self.receive_callback = None
@@ -87,18 +99,17 @@ class MockCanInterface(CanInterfaceBase):
87
99
  def read(self):
88
100
  pass
89
101
 
90
- def getTimestampResolution(self):
102
+ def get_timestamp_resolution(self):
91
103
  pass
92
104
 
93
105
 
94
106
  class TestMaster:
95
-
96
107
  DefaultConnectCmd = bytes([0x02, 0x00, 0x00, 0x00, 0xFF, 0x00])
97
108
  DefaultConnectResponse = "FF 3D C0 FF DC 05 01 01"
98
109
 
99
110
  @mock.patch("pyxcp.transport.eth")
100
111
  def testConnect(self, eth):
101
- with Master("eth") as xm:
112
+ with Master("eth", config=create_config()) as xm:
102
113
  xm.transport = eth()
103
114
  xm.transport.request.return_value = bytes([0x1D, 0xC0, 0xFF, 0xDC, 0x05, 0x01, 0x01])
104
115
 
@@ -121,7 +132,7 @@ class TestMaster:
121
132
 
122
133
  @mock.patch("pyxcp.transport.eth")
123
134
  def testDisconnect(self, eth):
124
- with Master("eth") as xm:
135
+ with Master("eth", config=create_config()) as xm:
125
136
  xm.transport = eth()
126
137
  xm.transport.request.return_value = bytes([])
127
138
  res = xm.disconnect()
@@ -129,7 +140,7 @@ class TestMaster:
129
140
 
130
141
  @mock.patch("pyxcp.transport.eth")
131
142
  def testGetStatus(self, eth):
132
- with Master("eth") as xm:
143
+ with Master("eth", config=create_config()) as xm:
133
144
  xm.transport = eth()
134
145
  xm.transport.request.return_value = bytes([0x1D, 0xC0, 0xFF, 0xDC, 0x05, 0x01, 0x01])
135
146
 
@@ -152,7 +163,7 @@ class TestMaster:
152
163
 
153
164
  @mock.patch("pyxcp.transport.eth")
154
165
  def testSync(self, eth):
155
- with Master("eth") as xm:
166
+ with Master("eth", config=create_config()) as xm:
156
167
  xm.transport = eth()
157
168
  xm.transport.request.return_value = bytes([0x00])
158
169
  res = xm.synch()
@@ -160,7 +171,7 @@ class TestMaster:
160
171
 
161
172
  @mock.patch("pyxcp.transport.eth")
162
173
  def testGetCommModeInfo(self, eth):
163
- with Master("eth") as xm:
174
+ with Master("eth", config=create_config()) as xm:
164
175
  xm.transport = eth()
165
176
  xm.transport.request.return_value = bytes([0x1D, 0xC0, 0xFF, 0xDC, 0x05, 0x01, 0x01])
166
177
 
@@ -179,7 +190,7 @@ class TestMaster:
179
190
 
180
191
  @mock.patch("pyxcp.transport.eth")
181
192
  def testGetId(self, eth):
182
- with Master("eth") as xm:
193
+ with Master("eth", config=create_config()) as xm:
183
194
  xm.transport = eth()
184
195
  xm.transport.MAX_DATAGRAM_SIZE = 512
185
196
  xm.transport.request.return_value = bytes([0x1D, 0xC0, 0xFF, 0xDC, 0x05, 0x01, 0x01])
@@ -204,7 +215,7 @@ class TestMaster:
204
215
  mock_socket.return_value.recv.side_effect = ms.recv
205
216
  mock_selector.return_value.select.side_effect = ms.select
206
217
 
207
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
218
+ with Master("eth", config=create_config()) as xm:
208
219
  ms.push_packet(self.DefaultConnectResponse)
209
220
 
210
221
  res = xm.connect()
@@ -248,7 +259,7 @@ class TestMaster:
248
259
  mock_socket.return_value.recv.side_effect = ms.recv
249
260
  mock_selector.return_value.select.side_effect = ms.select
250
261
 
251
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
262
+ with Master("eth", config=create_config()) as xm:
252
263
  ms.push_packet(self.DefaultConnectResponse)
253
264
 
254
265
  res = xm.connect()
@@ -271,7 +282,7 @@ class TestMaster:
271
282
  mock_socket.return_value.recv.side_effect = ms.recv
272
283
  mock_selector.return_value.select.side_effect = ms.select
273
284
 
274
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
285
+ with Master("eth", config=create_config()) as xm:
275
286
  ms.push_packet(self.DefaultConnectResponse)
276
287
 
277
288
  res = xm.connect()
@@ -303,7 +314,7 @@ class TestMaster:
303
314
  mock_socket.return_value.recv.side_effect = ms.recv
304
315
  mock_selector.return_value.select.side_effect = ms.select
305
316
 
306
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
317
+ with Master("eth", config=create_config()) as xm:
307
318
  ms.push_packet(self.DefaultConnectResponse)
308
319
 
309
320
  res = xm.connect()
@@ -326,7 +337,7 @@ class TestMaster:
326
337
  mock_socket.return_value.recv.side_effect = ms.recv
327
338
  mock_selector.return_value.select.side_effect = ms.select
328
339
 
329
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
340
+ with Master("eth", config=create_config()) as xm:
330
341
  ms.push_packet(self.DefaultConnectResponse)
331
342
 
332
343
  res = xm.connect()
@@ -354,7 +365,7 @@ class TestMaster:
354
365
  mock_socket.return_value.recv.side_effect = ms.recv
355
366
  mock_selector.return_value.select.side_effect = ms.select
356
367
 
357
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
368
+ with Master("eth", config=create_config()) as xm:
358
369
  ms.push_packet(self.DefaultConnectResponse)
359
370
 
360
371
  res = xm.connect()
@@ -417,7 +428,7 @@ class TestMaster:
417
428
  mock_socket.return_value.recv.side_effect = ms.recv
418
429
  mock_selector.return_value.select.side_effect = ms.select
419
430
 
420
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
431
+ with Master("eth", config=create_config()) as xm:
421
432
  ms.push_packet(self.DefaultConnectResponse)
422
433
 
423
434
  res = xm.connect()
@@ -440,7 +451,7 @@ class TestMaster:
440
451
  mock_socket.return_value.recv.side_effect = ms.recv
441
452
  mock_selector.return_value.select.side_effect = ms.select
442
453
 
443
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
454
+ with Master("eth", config=create_config()) as xm:
444
455
  ms.push_packet(self.DefaultConnectResponse)
445
456
 
446
457
  res = xm.connect()
@@ -464,7 +475,7 @@ class TestMaster:
464
475
  mock_socket.return_value.recv.side_effect = ms.recv
465
476
  mock_selector.return_value.select.side_effect = ms.select
466
477
 
467
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
478
+ with Master("eth", config=create_config()) as xm:
468
479
  ms.push_packet(self.DefaultConnectResponse)
469
480
 
470
481
  res = xm.connect()
@@ -490,7 +501,7 @@ class TestMaster:
490
501
  mock_socket.return_value.recv.side_effect = ms.recv
491
502
  mock_selector.return_value.select.side_effect = ms.select
492
503
 
493
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
504
+ with Master("eth", config=create_config()) as xm:
494
505
  ms.push_packet(self.DefaultConnectResponse)
495
506
 
496
507
  res = xm.connect()
@@ -530,7 +541,7 @@ class TestMaster:
530
541
  mock_socket.return_value.recv.side_effect = ms.recv
531
542
  mock_selector.return_value.select.side_effect = ms.select
532
543
 
533
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
544
+ with Master("eth", config=create_config()) as xm:
534
545
  ms.push_packet(self.DefaultConnectResponse)
535
546
 
536
547
  res = xm.connect()
@@ -569,7 +580,7 @@ class TestMaster:
569
580
  mock_socket.return_value.recv.side_effect = ms.recv
570
581
  mock_selector.return_value.select.side_effect = ms.select
571
582
 
572
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
583
+ with Master("eth", config=create_config()) as xm:
573
584
  ms.push_packet(self.DefaultConnectResponse)
574
585
 
575
586
  res = xm.connect()
@@ -609,7 +620,7 @@ class TestMaster:
609
620
  mock_socket.return_value.recv.side_effect = ms.recv
610
621
  mock_selector.return_value.select.side_effect = ms.select
611
622
 
612
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
623
+ with Master("eth", config=create_config()) as xm:
613
624
  ms.push_packet(self.DefaultConnectResponse)
614
625
 
615
626
  res = xm.connect()
@@ -650,7 +661,7 @@ class TestMaster:
650
661
  mock_socket.return_value.recv.side_effect = ms.recv
651
662
  mock_selector.return_value.select.side_effect = ms.select
652
663
 
653
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
664
+ with Master("eth", config=create_config()) as xm:
654
665
  ms.push_packet(self.DefaultConnectResponse)
655
666
 
656
667
  res = xm.connect()
@@ -674,7 +685,7 @@ class TestMaster:
674
685
  mock_socket.return_value.recv.side_effect = ms.recv
675
686
  mock_selector.return_value.select.side_effect = ms.select
676
687
 
677
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
688
+ with Master("eth", config=create_config()) as xm:
678
689
  ms.push_packet(self.DefaultConnectResponse)
679
690
 
680
691
  res = xm.connect()
@@ -698,7 +709,7 @@ class TestMaster:
698
709
  mock_socket.return_value.recv.side_effect = ms.recv
699
710
  mock_selector.return_value.select.side_effect = ms.select
700
711
 
701
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
712
+ with Master("eth", config=create_config()) as xm:
702
713
  ms.push_packet(self.DefaultConnectResponse)
703
714
 
704
715
  res = xm.connect()
@@ -724,7 +735,7 @@ class TestMaster:
724
735
  mock_socket.return_value.recv.side_effect = ms.recv
725
736
  mock_selector.return_value.select.side_effect = ms.select
726
737
 
727
- with Master("eth", config={"HOST": "localhost", "LOGLEVEL": "DEBUG"}) as xm:
738
+ with Master("eth", config=create_config()) as xm:
728
739
  ms.push_packet(self.DefaultConnectResponse)
729
740
 
730
741
  res = xm.connect()
@@ -748,7 +759,7 @@ class TestMaster:
748
759
  "CAN_USE_DEFAULT_LISTENER": False,
749
760
  }
750
761
  with Master("can", config=conf) as xm:
751
- mock_caninterface = xm.transport.canInterface
762
+ mock_caninterface = xm.transport.can_interface
752
763
  mock_caninterface.push_packet(self.DefaultConnectResponse)
753
764
  xm.connect()
754
765
 
@@ -817,7 +828,7 @@ class TestMaster:
817
828
  "CAN_USE_DEFAULT_LISTENER": False,
818
829
  }
819
830
  with Master("can", config=conf) as xm:
820
- mock_caninterface = xm.transport.canInterface
831
+ mock_caninterface = xm.transport.can_interface
821
832
  mock_caninterface.push_packet(self.DefaultConnectResponse)
822
833
  xm.connect()
823
834
 
@@ -1,13 +1,13 @@
1
- import pyxcp.transport.base as tr
2
-
3
1
  import pytest
4
2
 
3
+ import pyxcp.transport.base as tr
4
+
5
5
 
6
6
  def test_factory_works():
7
- assert isinstance(tr.createTransport("eth"), tr.BaseTransport)
8
- assert isinstance(tr.createTransport("sxi"), tr.BaseTransport)
7
+ assert isinstance(tr.create_transport("eth"), tr.BaseTransport)
8
+ assert isinstance(tr.create_transport("sxi"), tr.BaseTransport)
9
9
  assert isinstance(
10
- tr.createTransport(
10
+ tr.create_transport(
11
11
  "can",
12
12
  config={
13
13
  "CAN_ID_MASTER": 1,
@@ -20,10 +20,10 @@ def test_factory_works():
20
20
 
21
21
 
22
22
  def test_factory_works_case_insensitive():
23
- assert isinstance(tr.createTransport("ETH"), tr.BaseTransport)
24
- assert isinstance(tr.createTransport("SXI"), tr.BaseTransport)
23
+ assert isinstance(tr.create_transport("ETH"), tr.BaseTransport)
24
+ assert isinstance(tr.create_transport("SXI"), tr.BaseTransport)
25
25
  assert isinstance(
26
- tr.createTransport(
26
+ tr.create_transport(
27
27
  "CAN",
28
28
  config={
29
29
  "CAN_ID_MASTER": 1,
@@ -37,11 +37,11 @@ def test_factory_works_case_insensitive():
37
37
 
38
38
  def test_factory_invalid_transport_name_raises():
39
39
  with pytest.raises(ValueError):
40
- tr.createTransport("xCp")
40
+ tr.create_transport("xCp")
41
41
 
42
42
 
43
43
  def test_transport_names():
44
- transports = tr.availableTransports()
44
+ transports = tr.available_transports()
45
45
 
46
46
  assert "can" in transports
47
47
  assert "eth" in transports
@@ -49,7 +49,7 @@ def test_transport_names():
49
49
 
50
50
 
51
51
  def test_transport_names_are_lower_case_only():
52
- transports = tr.availableTransports()
52
+ transports = tr.available_transports()
53
53
 
54
54
  assert "CAN" not in transports
55
55
  assert "ETH" not in transports
@@ -57,7 +57,7 @@ def test_transport_names_are_lower_case_only():
57
57
 
58
58
 
59
59
  def test_transport_classes():
60
- transports = tr.availableTransports()
60
+ transports = tr.available_transports()
61
61
 
62
62
  assert issubclass(transports.get("can"), tr.BaseTransport)
63
63
  assert issubclass(transports.get("eth"), tr.BaseTransport)
pyxcp/tests/test_utils.py CHANGED
@@ -1,10 +1,7 @@
1
- from pyxcp.utils import flatten
2
- from pyxcp.utils import getPythonVersion
3
- from pyxcp.utils import hexDump
4
- from pyxcp.utils import PYTHON_VERSION
5
- from pyxcp.utils import slicer
6
1
  from sys import version_info
7
2
 
3
+ from pyxcp.utils import PYTHON_VERSION, flatten, getPythonVersion, hexDump, slicer
4
+
8
5
 
9
6
  def test_hexdump(capsys):
10
7
  print(hexDump(range(16)), end="")
pyxcp/timing.py CHANGED
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
2
  import time
4
3
 
5
4
 
6
5
  class Timing:
7
-
8
6
  T_US = 1000 * 1000
9
7
  T_MS = 1000
10
8
  T_S = 1
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- from .base import FrameAcquisitionPolicy
4
- from .base import FrameRecorderPolicy
5
- from .base import LegacyFrameAcquisitionPolicy
6
- from .base import StdoutPolicy
7
- from .can import Can
8
- from .eth import Eth
9
- from .sxi import SxI
10
- from .usb_transport import Usb
2
+ from .base import FrameAcquisitionPolicy # noqa: F401
3
+ from .base import FrameRecorderPolicy # noqa: F401
4
+ from .base import LegacyFrameAcquisitionPolicy # noqa: F401
5
+ from .base import NoOpPolicy # noqa: F401
6
+ from .base import StdoutPolicy # noqa: F401
7
+ from .can import Can # noqa: F401
8
+ from .eth import Eth # noqa: F401
9
+ from .sxi import SxI # noqa: F401
10
+ from .usb_transport import Usb # noqa: F401