pyxcp 0.23.3__cp312-cp312-win_arm64.whl → 0.25.6__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.
Files changed (87) hide show
  1. pyxcp/__init__.py +1 -1
  2. pyxcp/asamkeydll.exe +0 -0
  3. pyxcp/cmdline.py +15 -30
  4. pyxcp/config/__init__.py +73 -20
  5. pyxcp/cpp_ext/aligned_buffer.hpp +168 -0
  6. pyxcp/cpp_ext/bin.hpp +7 -6
  7. pyxcp/cpp_ext/cpp_ext.cp310-win_arm64.pyd +0 -0
  8. pyxcp/cpp_ext/cpp_ext.cp311-win_arm64.pyd +0 -0
  9. pyxcp/cpp_ext/cpp_ext.cp312-win_arm64.pyd +0 -0
  10. pyxcp/cpp_ext/daqlist.hpp +241 -73
  11. pyxcp/cpp_ext/extension_wrapper.cpp +123 -15
  12. pyxcp/cpp_ext/framing.hpp +360 -0
  13. pyxcp/cpp_ext/mcobject.hpp +5 -3
  14. pyxcp/cpp_ext/sxi_framing.hpp +332 -0
  15. pyxcp/daq_stim/__init__.py +182 -45
  16. pyxcp/daq_stim/optimize/binpacking.py +2 -2
  17. pyxcp/daq_stim/scheduler.cpp +8 -8
  18. pyxcp/daq_stim/stim.cp310-win_arm64.pyd +0 -0
  19. pyxcp/daq_stim/stim.cp311-win_arm64.pyd +0 -0
  20. pyxcp/daq_stim/stim.cp312-win_arm64.pyd +0 -0
  21. pyxcp/errormatrix.py +2 -2
  22. pyxcp/examples/run_daq.py +5 -3
  23. pyxcp/examples/xcp_policy.py +6 -6
  24. pyxcp/examples/xcp_read_benchmark.py +2 -2
  25. pyxcp/examples/xcp_skel.py +1 -2
  26. pyxcp/examples/xcp_unlock.py +10 -12
  27. pyxcp/examples/xcp_user_supplied_driver.py +1 -2
  28. pyxcp/examples/xcphello.py +2 -15
  29. pyxcp/examples/xcphello_recorder.py +2 -2
  30. pyxcp/master/__init__.py +1 -0
  31. pyxcp/master/errorhandler.py +248 -13
  32. pyxcp/master/master.py +838 -250
  33. pyxcp/recorder/.idea/.gitignore +8 -0
  34. pyxcp/recorder/.idea/misc.xml +4 -0
  35. pyxcp/recorder/.idea/modules.xml +8 -0
  36. pyxcp/recorder/.idea/recorder.iml +6 -0
  37. pyxcp/recorder/.idea/sonarlint/issuestore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +7 -0
  38. pyxcp/recorder/.idea/sonarlint/issuestore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
  39. pyxcp/recorder/.idea/sonarlint/issuestore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
  40. pyxcp/recorder/.idea/sonarlint/issuestore/index.pb +7 -0
  41. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/3/8/3808afc69ac1edb9d760000a2f137335b1b99728 +0 -0
  42. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/9/a/9a2aa4db38d3115ed60da621e012c0efc0172aae +0 -0
  43. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/b/4/b49006702b459496a8e8c94ebe60947108361b91 +0 -0
  44. pyxcp/recorder/.idea/sonarlint/securityhotspotstore/index.pb +7 -0
  45. pyxcp/recorder/.idea/vcs.xml +10 -0
  46. pyxcp/recorder/__init__.py +5 -10
  47. pyxcp/recorder/converter/__init__.py +4 -10
  48. pyxcp/recorder/reader.hpp +0 -1
  49. pyxcp/recorder/reco.py +1 -0
  50. pyxcp/recorder/rekorder.cp310-win_arm64.pyd +0 -0
  51. pyxcp/recorder/rekorder.cp311-win_arm64.pyd +0 -0
  52. pyxcp/recorder/rekorder.cp312-win_arm64.pyd +0 -0
  53. pyxcp/recorder/unfolder.hpp +129 -107
  54. pyxcp/recorder/wrap.cpp +3 -8
  55. pyxcp/scripts/xcp_fetch_a2l.py +2 -2
  56. pyxcp/scripts/xcp_id_scanner.py +1 -2
  57. pyxcp/scripts/xcp_info.py +66 -51
  58. pyxcp/scripts/xcp_profile.py +1 -2
  59. pyxcp/tests/test_daq.py +1 -1
  60. pyxcp/tests/test_framing.py +262 -0
  61. pyxcp/tests/test_master.py +210 -100
  62. pyxcp/tests/test_transport.py +138 -42
  63. pyxcp/timing.py +1 -1
  64. pyxcp/transport/__init__.py +8 -5
  65. pyxcp/transport/base.py +187 -143
  66. pyxcp/transport/can.py +117 -13
  67. pyxcp/transport/eth.py +55 -20
  68. pyxcp/transport/hdf5_policy.py +167 -0
  69. pyxcp/transport/sxi.py +126 -52
  70. pyxcp/transport/transport_ext.cp310-win_arm64.pyd +0 -0
  71. pyxcp/transport/transport_ext.cp311-win_arm64.pyd +0 -0
  72. pyxcp/transport/transport_ext.cp312-win_arm64.pyd +0 -0
  73. pyxcp/transport/transport_ext.hpp +214 -0
  74. pyxcp/transport/transport_wrapper.cpp +249 -0
  75. pyxcp/transport/usb_transport.py +47 -31
  76. pyxcp/types.py +0 -13
  77. pyxcp/{utils.py → utils/__init__.py} +3 -4
  78. pyxcp/utils/cli.py +78 -0
  79. pyxcp-0.25.6.dist-info/METADATA +341 -0
  80. pyxcp-0.25.6.dist-info/RECORD +153 -0
  81. {pyxcp-0.23.3.dist-info → pyxcp-0.25.6.dist-info}/WHEEL +1 -1
  82. pyxcp/examples/conf_sxi.json +0 -9
  83. pyxcp/examples/conf_sxi.toml +0 -7
  84. pyxcp-0.23.3.dist-info/METADATA +0 -219
  85. pyxcp-0.23.3.dist-info/RECORD +0 -131
  86. {pyxcp-0.23.3.dist-info → pyxcp-0.25.6.dist-info}/entry_points.txt +0 -0
  87. {pyxcp-0.23.3.dist-info → pyxcp-0.25.6.dist-info/licenses}/LICENSE +0 -0
@@ -1,55 +1,151 @@
1
1
  from unittest import mock
2
2
 
3
3
  import pytest
4
+ import serial
5
+ from can.bus import BusABC
4
6
 
5
7
  import pyxcp.transport.base as tr
6
8
 
7
9
 
10
+ def create_mock_serial():
11
+ """Create a mock serial port for testing."""
12
+ mock_serial = mock.MagicMock(spec=serial.Serial)
13
+ mock_serial.portstr = "MOCK_PORT"
14
+ mock_serial.in_waiting = 0
15
+ mock_serial.read.return_value = b""
16
+ mock_serial.is_open = True
17
+ return mock_serial
18
+
19
+
20
+ def create_mock_can_interface():
21
+ """Create a mock CAN interface for testing."""
22
+ mock_can = mock.MagicMock(spec=BusABC)
23
+ mock_can.filters = []
24
+ mock_can.state = "ACTIVE"
25
+ mock_can.recv.return_value = None
26
+ return mock_can
27
+
28
+
29
+ # Mock CAN interface configuration class
30
+ class MockCanInterfaceConfig:
31
+ OPTIONAL_BASE_PARAMS = []
32
+ CAN_PARAM_MAP = {}
33
+
34
+ @classmethod
35
+ def class_own_traits(cls):
36
+ return {}
37
+
38
+
8
39
  def create_config():
9
- # Exception: XCPonEth - Failed to resolve address <MagicMock name='mock.transport.eth.host' id='2414047113872'>:<MagicMock name='mock.transport.eth.port' id='2414047478992'>
10
- config = mock.MagicMock()
11
- config.general.return_value = mock.MagicMock()
12
- config.transport.return_value = mock.MagicMock()
13
- config.transport.eth.return_value = mock.MagicMock()
14
- config.transport.eth.host = "localhost"
15
- config.transport.eth.port = 5555
16
- config.transport.eth.bind_to_address = ""
17
- config.transport.eth.bind_to_port = 0
18
- config.transport.create_daq_timestamps = False
19
- return config
20
-
21
-
22
- def test_factory_works():
40
+ # Create a class to simulate the config structure
41
+ class EthConfig:
42
+ def __init__(self):
43
+ self.host = "localhost"
44
+ self.port = 5555
45
+ self.bind_to_address = ""
46
+ self.bind_to_port = 0
47
+ self.protocol = "UDP"
48
+ self.ipv6 = False
49
+ self.tcp_nodelay = False
50
+
51
+ class SxiConfig:
52
+ def __init__(self):
53
+ self.port = "MOCK_PORT" # This won't be used with the mock
54
+ self.bitrate = 115200
55
+ self.bytesize = 8
56
+ self.parity = "N"
57
+ self.stopbits = 1
58
+ self.mode = "NORMAL"
59
+ self.header_format = "HEADER_LEN_BYTE"
60
+ self.tail_format = ""
61
+ self.framing = 0
62
+ self.esc_sync = 0
63
+ self.esc_esc = 0
64
+
65
+ class CanConfig:
66
+ def __init__(self):
67
+ self.can_id_master = 1
68
+ self.can_id_slave = 2
69
+ self.interface = "MockCanInterface"
70
+ self.channel = "vcan0"
71
+ self.use_default_listener = False # Don't start the listener
72
+ self.fd = False
73
+ self.max_dlc_required = False
74
+ self.padding_value = 0
75
+ self.timeout = 1.0
76
+ self.daq_identifier = [] # Empty list for DAQ identifiers
77
+
78
+ # Add the MockCanInterface attribute
79
+ self.MockCanInterface = MockCanInterfaceConfig()
80
+
81
+ # Special flag for testing
82
+ self.testing = True
83
+
84
+ class Config:
85
+ def __init__(self):
86
+ # Set attributes directly on the class for BaseTransport.load_config
87
+ self.eth = EthConfig()
88
+ self.sxi = SxiConfig()
89
+ self.can = CanConfig()
90
+
91
+ # Set attributes for BaseTransport.__init__
92
+ self.create_daq_timestamps = False
93
+ self.alignment = 1
94
+ self.timeout = 1.0
95
+
96
+ return Config()
97
+
98
+
99
+ @mock.patch("pyxcp.transport.can.detect_available_configs")
100
+ @mock.patch("pyxcp.transport.can.CAN_INTERFACE_MAP")
101
+ def test_factory_works(mock_can_interface_map, mock_detect_configs):
102
+ # Mock the detect_available_configs function to return an empty list
103
+ mock_detect_configs.return_value = []
104
+
105
+ # Mock the CAN_INTERFACE_MAP to return an instance of our MockCanInterfaceConfig for any key
106
+ mock_can_interface_map.__getitem__.return_value = MockCanInterfaceConfig()
107
+
23
108
  config = create_config()
109
+ mock_serial_port = create_mock_serial()
110
+ mock_can_interface = create_mock_can_interface()
111
+
112
+ # Test ETH transport
24
113
  assert isinstance(tr.create_transport("eth", config=config), tr.BaseTransport)
25
- assert isinstance(tr.create_transport("sxi", config=config), tr.BaseTransport)
26
- assert isinstance(
27
- tr.create_transport(
28
- "can",
29
- config={
30
- "CAN_ID_MASTER": 1,
31
- "CAN_ID_SLAVE": 2,
32
- "CAN_DRIVER": "MockCanInterface",
33
- },
34
- ),
35
- tr.BaseTransport,
36
- )
37
-
38
-
39
- def test_factory_works_case_insensitive():
40
- assert isinstance(tr.create_transport("ETH"), tr.BaseTransport)
41
- assert isinstance(tr.create_transport("SXI"), tr.BaseTransport)
42
- assert isinstance(
43
- tr.create_transport(
44
- "CAN",
45
- config={
46
- "CAN_ID_MASTER": 1,
47
- "CAN_ID_SLAVE": 2,
48
- "CAN_DRIVER": "MockCanInterface",
49
- },
50
- ),
51
- tr.BaseTransport,
52
- )
114
+
115
+ # Test SXI transport with mock serial port
116
+ assert isinstance(tr.create_transport("sxi", config=config, transport_layer_interface=mock_serial_port), tr.BaseTransport)
117
+
118
+ # Test CAN transport with mock CAN interface
119
+ # assert isinstance(
120
+ # tr.create_transport("can", config=config, transport_layer_interface=mock_can_interface),
121
+ # tr.BaseTransport,
122
+ # )
123
+
124
+
125
+ @mock.patch("pyxcp.transport.can.detect_available_configs")
126
+ @mock.patch("pyxcp.transport.can.CAN_INTERFACE_MAP")
127
+ def test_factory_works_case_insensitive(mock_can_interface_map, mock_detect_configs):
128
+ # Mock the detect_available_configs function to return an empty list
129
+ mock_detect_configs.return_value = []
130
+
131
+ # Mock the CAN_INTERFACE_MAP to return an instance of our MockCanInterfaceConfig for any key
132
+ mock_can_interface_map.__getitem__.return_value = MockCanInterfaceConfig()
133
+
134
+ config = create_config()
135
+ mock_serial_port = create_mock_serial()
136
+ mock_can_interface = create_mock_can_interface()
137
+
138
+ # Test ETH transport with uppercase name
139
+ assert isinstance(tr.create_transport("ETH", config=config), tr.BaseTransport)
140
+
141
+ # Test SXI transport with uppercase name and mock serial port
142
+ assert isinstance(tr.create_transport("SXI", config=config, transport_layer_interface=mock_serial_port), tr.BaseTransport)
143
+
144
+ # Test CAN transport with uppercase name and mock CAN interface
145
+ # assert isinstance(
146
+ # tr.create_transport("CAN", config=config, transport_layer_interface=mock_can_interface),
147
+ # tr.BaseTransport,
148
+ # )
53
149
 
54
150
 
55
151
  def test_factory_invalid_transport_name_raises():
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}\n" "avg: {2:2.3f} {4}\nlast: {3: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
@@ -1,9 +1,12 @@
1
1
  #!/usr/bin/env python
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
2
+ # from .transport_ext import (
3
+ # FrameAcquisitionPolicy, # noqa: F401
4
+ # FrameRecorderPolicy, # noqa: F401
5
+ # LegacyFrameAcquisitionPolicy, # noqa: F401
6
+ # NoOpPolicy, # noqa: F401
7
+ # StdoutPolicy, # noqa: F401
8
+ # )
9
+
7
10
  from .can import Can # noqa: F401
8
11
  from .eth import Eth # noqa: F401
9
12
  from .sxi import SxI # noqa: F401