pyxcp 0.21.10__cp39-cp39-win_amd64.whl → 0.22.23__cp39-cp39-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 (173) 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/cpp_ext.cp39-win_amd64.pyd +0 -0
  22. pyxcp/cpp_ext/daqlist.hpp +200 -0
  23. pyxcp/cpp_ext/event.hpp +67 -0
  24. pyxcp/cpp_ext/extension_wrapper.cpp +96 -0
  25. pyxcp/cpp_ext/helper.hpp +280 -0
  26. pyxcp/cpp_ext/mcobject.hpp +246 -0
  27. pyxcp/cpp_ext/tsqueue.hpp +46 -0
  28. pyxcp/daq_stim/__init__.py +228 -0
  29. pyxcp/daq_stim/optimize/__init__.py +67 -0
  30. pyxcp/daq_stim/optimize/binpacking.py +41 -0
  31. pyxcp/daq_stim/scheduler.cpp +28 -0
  32. pyxcp/daq_stim/scheduler.hpp +75 -0
  33. pyxcp/daq_stim/stim.cp38-win_amd64.pyd +0 -0
  34. pyxcp/daq_stim/stim.cp39-win_amd64.pyd +0 -0
  35. pyxcp/daq_stim/stim.cpp +13 -0
  36. pyxcp/daq_stim/stim.hpp +604 -0
  37. pyxcp/daq_stim/stim_wrapper.cpp +48 -0
  38. pyxcp/dllif.py +21 -18
  39. pyxcp/errormatrix.py +5 -3
  40. pyxcp/examples/conf_can.toml +4 -2
  41. pyxcp/examples/conf_can_vector.json +9 -9
  42. pyxcp/examples/conf_can_vector.toml +4 -2
  43. pyxcp/examples/conf_eth.toml +5 -2
  44. pyxcp/examples/conf_nixnet.json +18 -18
  45. pyxcp/examples/conf_sxi.json +7 -7
  46. pyxcp/examples/ex_arrow.py +109 -0
  47. pyxcp/examples/ex_csv.py +85 -0
  48. pyxcp/examples/ex_excel.py +95 -0
  49. pyxcp/examples/ex_mdf.py +124 -0
  50. pyxcp/examples/ex_sqlite.py +128 -0
  51. pyxcp/examples/run_daq.py +148 -0
  52. pyxcp/examples/xcp_policy.py +6 -7
  53. pyxcp/examples/xcp_read_benchmark.py +8 -6
  54. pyxcp/examples/xcp_skel.py +0 -2
  55. pyxcp/examples/xcp_unlock.py +1 -1
  56. pyxcp/examples/xcp_user_supplied_driver.py +1 -2
  57. pyxcp/examples/xcphello.py +6 -3
  58. pyxcp/examples/xcphello_recorder.py +4 -4
  59. pyxcp/master/__init__.py +1 -2
  60. pyxcp/master/errorhandler.py +107 -74
  61. pyxcp/master/master.py +201 -119
  62. pyxcp/py.typed +0 -0
  63. pyxcp/recorder/__init__.py +27 -6
  64. pyxcp/recorder/converter/__init__.py +37 -0
  65. pyxcp/recorder/lz4.c +129 -51
  66. pyxcp/recorder/lz4.h +45 -28
  67. pyxcp/recorder/lz4hc.c +560 -156
  68. pyxcp/recorder/lz4hc.h +1 -1
  69. pyxcp/recorder/mio.hpp +721 -767
  70. pyxcp/recorder/reader.hpp +139 -0
  71. pyxcp/recorder/reco.py +5 -8
  72. pyxcp/recorder/rekorder.cp38-win_amd64.pyd +0 -0
  73. pyxcp/recorder/rekorder.cp39-win_amd64.pyd +0 -0
  74. pyxcp/recorder/rekorder.cpp +18 -22
  75. pyxcp/recorder/rekorder.hpp +200 -587
  76. pyxcp/recorder/setup.py +11 -10
  77. pyxcp/recorder/test_reko.py +2 -3
  78. pyxcp/recorder/unfolder.hpp +1332 -0
  79. pyxcp/recorder/wrap.cpp +171 -9
  80. pyxcp/recorder/writer.hpp +302 -0
  81. pyxcp/scripts/pyxcp_probe_can_drivers.py +0 -2
  82. pyxcp/scripts/xcp_examples.py +64 -0
  83. pyxcp/scripts/xcp_fetch_a2l.py +15 -10
  84. pyxcp/scripts/xcp_id_scanner.py +2 -6
  85. pyxcp/scripts/xcp_info.py +101 -63
  86. pyxcp/scripts/xcp_profile.py +27 -0
  87. pyxcp/stim/__init__.py +0 -0
  88. pyxcp/tests/test_asam_types.py +2 -2
  89. pyxcp/tests/test_binpacking.py +186 -0
  90. pyxcp/tests/test_can.py +1132 -38
  91. pyxcp/tests/test_checksum.py +2 -1
  92. pyxcp/tests/test_daq.py +193 -0
  93. pyxcp/tests/test_frame_padding.py +6 -3
  94. pyxcp/tests/test_master.py +42 -31
  95. pyxcp/tests/test_transport.py +12 -12
  96. pyxcp/tests/test_utils.py +2 -5
  97. pyxcp/timing.py +0 -2
  98. pyxcp/transport/__init__.py +9 -9
  99. pyxcp/transport/base.py +149 -127
  100. pyxcp/transport/base_transport.hpp +0 -0
  101. pyxcp/transport/can.py +194 -167
  102. pyxcp/transport/eth.py +80 -82
  103. pyxcp/transport/sxi.py +106 -60
  104. pyxcp/transport/transport_wrapper.cpp +0 -0
  105. pyxcp/transport/usb_transport.py +65 -83
  106. pyxcp/types.py +69 -20
  107. pyxcp/utils.py +47 -16
  108. pyxcp/vector/map.py +1 -3
  109. {pyxcp-0.21.10.dist-info → pyxcp-0.22.23.dist-info}/METADATA +28 -23
  110. pyxcp-0.22.23.dist-info/RECORD +131 -0
  111. {pyxcp-0.21.10.dist-info → pyxcp-0.22.23.dist-info}/WHEEL +1 -1
  112. {pyxcp-0.21.10.dist-info → pyxcp-0.22.23.dist-info}/entry_points.txt +2 -0
  113. pyxcp/config.py +0 -57
  114. pyxcp/cxx/asynchiofactory.hpp +0 -24
  115. pyxcp/cxx/blocking_client.cpp +0 -44
  116. pyxcp/cxx/blocking_socket.cpp +0 -43
  117. pyxcp/cxx/blocking_socket.hpp +0 -558
  118. pyxcp/cxx/concurrent_queue.hpp +0 -60
  119. pyxcp/cxx/eth.hpp +0 -57
  120. pyxcp/cxx/exceptions.hpp +0 -30
  121. pyxcp/cxx/iasyncioservice.hpp +0 -31
  122. pyxcp/cxx/iresource.hpp +0 -17
  123. pyxcp/cxx/isocket.hpp +0 -22
  124. pyxcp/cxx/linux/epoll.cpp +0 -51
  125. pyxcp/cxx/linux/epoll.hpp +0 -87
  126. pyxcp/cxx/linux/lit_tester.cpp +0 -19
  127. pyxcp/cxx/linux/socket.hpp +0 -234
  128. pyxcp/cxx/linux/timeout.hpp +0 -81
  129. pyxcp/cxx/memoryblock.hpp +0 -42
  130. pyxcp/cxx/pool.hpp +0 -81
  131. pyxcp/cxx/poolmgr.cpp +0 -6
  132. pyxcp/cxx/poolmgr.hpp +0 -31
  133. pyxcp/cxx/test_queue.cpp +0 -69
  134. pyxcp/cxx/timestamp.hpp +0 -84
  135. pyxcp/cxx/utils.cpp +0 -38
  136. pyxcp/cxx/utils.hpp +0 -29
  137. pyxcp/cxx/win/iocp.cpp +0 -242
  138. pyxcp/cxx/win/iocp.hpp +0 -42
  139. pyxcp/cxx/win/perhandledata.hpp +0 -24
  140. pyxcp/cxx/win/periodata.hpp +0 -97
  141. pyxcp/cxx/win/socket.hpp +0 -185
  142. pyxcp/cxx/win/timeout.hpp +0 -83
  143. pyxcp/examples/conf_can.json +0 -20
  144. pyxcp/examples/conf_eth.json +0 -8
  145. pyxcp/logger.py +0 -67
  146. pyxcp/tests/test_config.py +0 -62
  147. pyxcp/transport/candriver/__init__.py +0 -2
  148. pyxcp/transport/candriver/pc_canalystii.py +0 -27
  149. pyxcp/transport/candriver/pc_etas.py +0 -25
  150. pyxcp/transport/candriver/pc_gsusb.py +0 -23
  151. pyxcp/transport/candriver/pc_iscan.py +0 -23
  152. pyxcp/transport/candriver/pc_ixxat.py +0 -27
  153. pyxcp/transport/candriver/pc_kvaser.py +0 -39
  154. pyxcp/transport/candriver/pc_neovi.py +0 -31
  155. pyxcp/transport/candriver/pc_nican.py +0 -23
  156. pyxcp/transport/candriver/pc_nixnet.py +0 -23
  157. pyxcp/transport/candriver/pc_pcan.py +0 -25
  158. pyxcp/transport/candriver/pc_seeed.py +0 -28
  159. pyxcp/transport/candriver/pc_serial.py +0 -27
  160. pyxcp/transport/candriver/pc_slcan.py +0 -29
  161. pyxcp/transport/candriver/pc_socketcan.py +0 -23
  162. pyxcp/transport/candriver/pc_systec.py +0 -29
  163. pyxcp/transport/candriver/pc_usb2can.py +0 -30
  164. pyxcp/transport/candriver/pc_vector.py +0 -34
  165. pyxcp/transport/candriver/python_can.py +0 -101
  166. pyxcp/transport/cxx_ext/CMakeLists.txt +0 -51
  167. pyxcp/transport/cxx_ext/setup.py +0 -49
  168. pyxcp/transport/cxx_ext/tests/test_basic_socket.cpp +0 -39
  169. pyxcp/transport/cxx_ext/tests/test_pool.cpp +0 -39
  170. pyxcp/transport/cxx_ext/tests/test_timestamp.cpp +0 -27
  171. pyxcp-0.21.10.dist-info/RECORD +0 -147
  172. rekorder.cp39-win_amd64.pyd +0 -0
  173. {pyxcp-0.21.10.dist-info/licenses → pyxcp-0.22.23.dist-info}/LICENSE +0 -0
@@ -0,0 +1,139 @@
1
+
2
+ #ifndef RECORDER_READER_HPP
3
+ #define RECORDER_READER_HPP
4
+
5
+ #include <iostream>
6
+
7
+ class XcpLogFileReader {
8
+ public:
9
+
10
+ explicit XcpLogFileReader(const std::string &file_name) {
11
+ if (!file_name.ends_with(detail::FILE_EXTENSION)) {
12
+ m_file_name = file_name + detail::FILE_EXTENSION;
13
+ } else {
14
+ m_file_name = file_name;
15
+ }
16
+
17
+ m_mmap = new mio::mmap_source(m_file_name);
18
+ blob_t magic[detail::MAGIC_SIZE + 1];
19
+
20
+ read_bytes(0UL, detail::MAGIC_SIZE, magic);
21
+ if (memcmp(detail::MAGIC.c_str(), magic, detail::MAGIC_SIZE) != 0) {
22
+ throw std::runtime_error("Invalid file magic.");
23
+ }
24
+ m_offset = detail::MAGIC_SIZE;
25
+
26
+ read_bytes(m_offset, detail::FILE_HEADER_SIZE, reinterpret_cast<blob_t *>(&m_header));
27
+ // printf("Sizes: %u %u %.3f\n", m_header.size_uncompressed,
28
+ // m_header.size_compressed,
29
+ // float(m_header.size_uncompressed) / float(m_header.size_compressed));
30
+ if (m_header.hdr_size != detail::FILE_HEADER_SIZE + detail::MAGIC_SIZE) {
31
+ throw std::runtime_error("File header size does not match.");
32
+ }
33
+ if (detail::VERSION != m_header.version) {
34
+ throw std::runtime_error("File version mismatch.");
35
+ }
36
+ #if 0
37
+ if (m_header.num_containers < 1) {
38
+ throw std::runtime_error("At least one container required.");
39
+ }
40
+ #endif
41
+ m_offset += detail::FILE_HEADER_SIZE;
42
+
43
+ if ((m_header.options & XMRAW_HAS_METADATA) == XMRAW_HAS_METADATA) {
44
+ std::size_t metadata_length = 0;
45
+ std::size_t data_start = m_offset + sizeof(std::size_t);
46
+
47
+ read_bytes(m_offset, sizeof(std::size_t), reinterpret_cast<blob_t *>(&metadata_length));
48
+
49
+ std::copy(ptr(data_start), ptr(data_start + metadata_length), std::back_inserter(m_metadata));
50
+ // std::cout << "Metadata: " << m_metadata << std::endl;
51
+ m_offset += (metadata_length + sizeof(std::size_t));
52
+ }
53
+ }
54
+
55
+ [[nodiscard]] FileHeaderType get_header() const noexcept {
56
+ return m_header;
57
+ }
58
+
59
+ [[nodiscard]] auto get_header_as_tuple() const noexcept -> HeaderTuple {
60
+ auto hdr = get_header();
61
+
62
+ return std::make_tuple(
63
+ hdr.version, hdr.options, hdr.num_containers, hdr.record_count, hdr.size_uncompressed, hdr.size_compressed,
64
+ (double)((std::uint64_t)(((double)hdr.size_uncompressed / (double)hdr.size_compressed * 100.0) + 0.5)) / 100.0
65
+ );
66
+ }
67
+
68
+ [[nodiscard]] auto get_metadata() const noexcept {
69
+ return m_metadata;
70
+ }
71
+
72
+ void reset() noexcept {
73
+ m_current_container = 0;
74
+ m_offset = file_header_size();
75
+ }
76
+
77
+ std::optional<FrameVector> next_block() {
78
+ auto container = ContainerHeaderType{};
79
+ auto frame = frame_header_t{};
80
+ std::uint64_t boffs = 0;
81
+ auto result = FrameVector{};
82
+ payload_t payload;
83
+
84
+ if (m_current_container >= m_header.num_containers) {
85
+ return std::nullopt;
86
+ }
87
+ read_bytes(m_offset, detail::CONTAINER_SIZE, reinterpret_cast<blob_t *>(&container));
88
+ __ALIGN auto buffer = new blob_t[container.size_uncompressed];
89
+ m_offset += detail::CONTAINER_SIZE;
90
+ result.reserve(container.record_count);
91
+ const int uc_size = ::LZ4_decompress_safe(
92
+ reinterpret_cast<char const *>(ptr(m_offset)), reinterpret_cast<char *>(buffer), container.size_compressed,
93
+ container.size_uncompressed
94
+ );
95
+ if (uc_size < 0) {
96
+ throw std::runtime_error("LZ4 decompression failed.");
97
+ }
98
+ boffs = 0;
99
+ for (std::uint64_t idx = 0; idx < container.record_count; ++idx) {
100
+ _fcopy(reinterpret_cast<char *>(&frame), reinterpret_cast<char const *>(&(buffer[boffs])), sizeof(frame_header_t));
101
+ boffs += sizeof(frame_header_t);
102
+ result.emplace_back(
103
+ frame.category, frame.counter, frame.timestamp, frame.length, create_payload(frame.length, &buffer[boffs])
104
+ );
105
+ boffs += frame.length;
106
+ }
107
+ m_offset += container.size_compressed;
108
+ m_current_container += 1;
109
+ delete[] buffer;
110
+
111
+ return std::optional<FrameVector>{ result };
112
+ }
113
+
114
+ ~XcpLogFileReader() noexcept {
115
+ delete m_mmap;
116
+ }
117
+
118
+ protected:
119
+
120
+ [[nodiscard]] blob_t const *ptr(std::uint64_t pos = 0) const {
121
+ return reinterpret_cast<blob_t const *>(m_mmap->data() + pos);
122
+ }
123
+
124
+ void read_bytes(std::uint64_t pos, std::uint64_t count, blob_t *buf) const {
125
+ auto addr = reinterpret_cast<char const *>(ptr(pos));
126
+ _fcopy(reinterpret_cast<char *>(buf), addr, count);
127
+ }
128
+
129
+ private:
130
+
131
+ std::string m_file_name;
132
+ std::uint64_t m_offset{ 0 };
133
+ std::uint64_t m_current_container{ 0 };
134
+ mio::mmap_source *m_mmap{ nullptr };
135
+ FileHeaderType m_header;
136
+ std::string m_metadata;
137
+ };
138
+
139
+ #endif // RECORDER_READER_HPP
pyxcp/recorder/reco.py CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
2
  """Raw XCP traffic recorder.
4
3
 
5
4
  Data is stored in LZ4 compressed containers.
@@ -15,8 +14,6 @@ See
15
14
  """
16
15
  import enum
17
16
  import mmap
18
- import os
19
- import pathlib
20
17
  import struct
21
18
  from collections import namedtuple
22
19
 
@@ -27,7 +24,7 @@ FILE_EXTENSION = ".xmraw" # XCP Measurement / raw data.
27
24
 
28
25
  MAGIC = b"ASAMINT::XCP_RAW"
29
26
 
30
- FILE_HEADER_STRUCT = struct.Struct("<{:d}sHHHLLLL".format(len(MAGIC)))
27
+ FILE_HEADER_STRUCT = struct.Struct(f"<{len(MAGIC):d}sHHHLLLL")
31
28
  FileHeader = namedtuple(
32
29
  "FileHeader",
33
30
  "magic hdr_size version options num_containers record_count size_compressed size_uncompressed",
@@ -82,7 +79,7 @@ class XcpLogFileWriter:
82
79
  ):
83
80
  self._is_closed = True
84
81
  try:
85
- self._of = open("{}{}".format(file_name, FILE_EXTENSION), "w+b")
82
+ self._of = open(f"{file_name}{FILE_EXTENSION}", "w+b")
86
83
  except Exception:
87
84
  raise
88
85
  else:
@@ -161,7 +158,7 @@ class XcpLogFileWriter:
161
158
  try:
162
159
  self._mapping[address : address + length] = data
163
160
  except IndexError:
164
- raise XcpLogFileCapacityExceededError("Maximum file size of {} MBytes exceeded.".format(self.prealloc)) from None
161
+ raise XcpLogFileCapacityExceededError(f"Maximum file size of {self.prealloc} MBytes exceeded.") from None
165
162
 
166
163
  def _write_header(
167
164
  self,
@@ -201,7 +198,7 @@ class XcpLogFileReader:
201
198
  def __init__(self, file_name):
202
199
  self._is_closed = True
203
200
  try:
204
- self._log_file = open("{}{}".format(file_name, FILE_EXTENSION), "r+b")
201
+ self._log_file = open(f"{file_name}{FILE_EXTENSION}", "r+b")
205
202
  except Exception:
206
203
  raise
207
204
  else:
@@ -218,7 +215,7 @@ class XcpLogFileReader:
218
215
  self.total_size_uncompressed,
219
216
  ) = FILE_HEADER_STRUCT.unpack(self.get(0, FILE_HEADER_STRUCT.size))
220
217
  if magic != MAGIC:
221
- raise XcpLogFileParseError("Invalid file magic: '{}'.".format(magic))
218
+ raise XcpLogFileParseError(f"Invalid file magic: {magic!r}.")
222
219
 
223
220
  def __del__(self):
224
221
  if not self._is_closed:
@@ -3,28 +3,24 @@
3
3
 
4
4
  #include "rekorder.hpp"
5
5
 
6
-
7
- void some_records(XcpLogFileWriter& writer)
8
- {
9
- const auto COUNT = 1024 * 100 * 5;
10
- unsigned filler = 0x00;
11
- char buffer[1024];
6
+ void some_records(XcpLogFileWriter& writer) {
7
+ const auto COUNT = 1024 * 100 * 5;
8
+ unsigned filler = 0x00;
9
+ char buffer[1024];
12
10
 
13
11
  for (auto idx = 0; idx < COUNT; ++idx) {
14
- auto fr = frame_header_t{};
15
- fr.category = 1;
16
- fr.counter = idx;
12
+ auto fr = frame_header_t{};
13
+ fr.category = 1;
14
+ fr.counter = idx;
17
15
  fr.timestamp = std::clock();
18
- fr.length = 10 + (rand() % 240);
19
- filler = (filler + 1) % 16;
16
+ fr.length = 10 + (rand() % 240);
17
+ filler = (filler + 1) % 16;
20
18
  memset(buffer, filler, fr.length);
21
- writer.add_frame(fr.category, fr.counter, fr.timestamp, fr.length, std::bit_cast<char const*>(&buffer));
19
+ writer.add_frame(fr.category, fr.counter, fr.timestamp, fr.length, std::bit_cast<char const *>(&buffer));
22
20
  }
23
21
  }
24
22
 
25
-
26
- int main()
27
- {
23
+ int main() {
28
24
  srand(42);
29
25
 
30
26
  printf("\nWRITER\n");
@@ -49,15 +45,15 @@ int main()
49
45
  printf("size/uncompressed: %u\n", header.size_uncompressed);
50
46
  printf("compression ratio: %.2f\n", static_cast<float>(header.size_uncompressed) / static_cast<float>(header.size_compressed));
51
47
 
52
- while (true) {
53
- const auto& frames = reader.next_block();
54
- if (!frames) {
55
- break;
56
- }
57
- for (const auto& frame: frames.value()) {
48
+ while (true) {
49
+ const auto& frames = reader.next_block();
50
+ if (!frames) {
51
+ break;
52
+ }
53
+ for (const auto& frame : frames.value()) {
58
54
  auto const& [category, counter, timestamp, length, payload] = frame;
59
55
  }
60
- }
56
+ }
61
57
  printf("---\n");
62
58
  printf("Finished.\n");
63
59
  }