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/recorder/reader.hpp
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
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
|
-
m_offset += (metadata_length + sizeof(std::size_t));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
[[nodiscard]] FileHeaderType get_header() const noexcept {
|
|
55
|
-
return m_header;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
[[nodiscard]] auto get_header_as_tuple() const noexcept -> HeaderTuple {
|
|
59
|
-
auto hdr = get_header();
|
|
60
|
-
|
|
61
|
-
return std::make_tuple(
|
|
62
|
-
hdr.version, hdr.options, hdr.num_containers, hdr.record_count, hdr.size_uncompressed, hdr.size_compressed,
|
|
63
|
-
(double)((std::uint64_t)(((double)hdr.size_uncompressed / (double)hdr.size_compressed * 100.0) + 0.5)) / 100.0
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
[[nodiscard]] auto get_metadata() const noexcept {
|
|
68
|
-
return m_metadata;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
void reset() noexcept {
|
|
72
|
-
m_current_container = 0;
|
|
73
|
-
m_offset = file_header_size();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
std::optional<FrameVector> next_block() {
|
|
77
|
-
auto container = ContainerHeaderType{};
|
|
78
|
-
auto frame = frame_header_t{};
|
|
79
|
-
std::uint64_t boffs = 0;
|
|
80
|
-
auto result = FrameVector{};
|
|
81
|
-
payload_t payload;
|
|
82
|
-
|
|
83
|
-
if (m_current_container >= m_header.num_containers) {
|
|
84
|
-
return std::nullopt;
|
|
85
|
-
}
|
|
86
|
-
read_bytes(m_offset, detail::CONTAINER_SIZE, reinterpret_cast<blob_t *>(&container));
|
|
87
|
-
__ALIGN auto buffer = new blob_t[container.size_uncompressed];
|
|
88
|
-
m_offset += detail::CONTAINER_SIZE;
|
|
89
|
-
result.reserve(container.record_count);
|
|
90
|
-
const int uc_size = ::LZ4_decompress_safe(
|
|
91
|
-
reinterpret_cast<char const *>(ptr(m_offset)), reinterpret_cast<char *>(buffer), container.size_compressed,
|
|
92
|
-
container.size_uncompressed
|
|
93
|
-
);
|
|
94
|
-
if (uc_size < 0) {
|
|
95
|
-
throw std::runtime_error("LZ4 decompression failed.");
|
|
96
|
-
}
|
|
97
|
-
boffs = 0;
|
|
98
|
-
for (std::uint64_t idx = 0; idx < container.record_count; ++idx) {
|
|
99
|
-
_fcopy(reinterpret_cast<char *>(&frame), reinterpret_cast<char const *>(&(buffer[boffs])), sizeof(frame_header_t));
|
|
100
|
-
boffs += sizeof(frame_header_t);
|
|
101
|
-
result.emplace_back(
|
|
102
|
-
frame.category, frame.counter, frame.timestamp, frame.length, create_payload(frame.length, &buffer[boffs])
|
|
103
|
-
);
|
|
104
|
-
boffs += frame.length;
|
|
105
|
-
}
|
|
106
|
-
m_offset += container.size_compressed;
|
|
107
|
-
m_current_container += 1;
|
|
108
|
-
delete[] buffer;
|
|
109
|
-
|
|
110
|
-
return std::optional<FrameVector>{ result };
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
~XcpLogFileReader() noexcept {
|
|
114
|
-
delete m_mmap;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
protected:
|
|
118
|
-
|
|
119
|
-
[[nodiscard]] blob_t const *ptr(std::uint64_t pos = 0) const {
|
|
120
|
-
return reinterpret_cast<blob_t const *>(m_mmap->data() + pos);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
void read_bytes(std::uint64_t pos, std::uint64_t count, blob_t *buf) const {
|
|
124
|
-
auto addr = reinterpret_cast<char const *>(ptr(pos));
|
|
125
|
-
_fcopy(reinterpret_cast<char *>(buf), addr, count);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
private:
|
|
129
|
-
|
|
130
|
-
std::string m_file_name;
|
|
131
|
-
std::uint64_t m_offset{ 0 };
|
|
132
|
-
std::uint64_t m_current_container{ 0 };
|
|
133
|
-
mio::mmap_source *m_mmap{ nullptr };
|
|
134
|
-
FileHeaderType m_header;
|
|
135
|
-
std::string m_metadata;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
#endif // RECORDER_READER_HPP
|
|
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
|
+
m_offset += (metadata_length + sizeof(std::size_t));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
[[nodiscard]] FileHeaderType get_header() const noexcept {
|
|
55
|
+
return m_header;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[[nodiscard]] auto get_header_as_tuple() const noexcept -> HeaderTuple {
|
|
59
|
+
auto hdr = get_header();
|
|
60
|
+
|
|
61
|
+
return std::make_tuple(
|
|
62
|
+
hdr.version, hdr.options, hdr.num_containers, hdr.record_count, hdr.size_uncompressed, hdr.size_compressed,
|
|
63
|
+
(double)((std::uint64_t)(((double)hdr.size_uncompressed / (double)hdr.size_compressed * 100.0) + 0.5)) / 100.0
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[[nodiscard]] auto get_metadata() const noexcept {
|
|
68
|
+
return m_metadata;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void reset() noexcept {
|
|
72
|
+
m_current_container = 0;
|
|
73
|
+
m_offset = file_header_size();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
std::optional<FrameVector> next_block() {
|
|
77
|
+
auto container = ContainerHeaderType{};
|
|
78
|
+
auto frame = frame_header_t{};
|
|
79
|
+
std::uint64_t boffs = 0;
|
|
80
|
+
auto result = FrameVector{};
|
|
81
|
+
payload_t payload;
|
|
82
|
+
|
|
83
|
+
if (m_current_container >= m_header.num_containers) {
|
|
84
|
+
return std::nullopt;
|
|
85
|
+
}
|
|
86
|
+
read_bytes(m_offset, detail::CONTAINER_SIZE, reinterpret_cast<blob_t *>(&container));
|
|
87
|
+
__ALIGN auto buffer = new blob_t[container.size_uncompressed];
|
|
88
|
+
m_offset += detail::CONTAINER_SIZE;
|
|
89
|
+
result.reserve(container.record_count);
|
|
90
|
+
const int uc_size = ::LZ4_decompress_safe(
|
|
91
|
+
reinterpret_cast<char const *>(ptr(m_offset)), reinterpret_cast<char *>(buffer), container.size_compressed,
|
|
92
|
+
container.size_uncompressed
|
|
93
|
+
);
|
|
94
|
+
if (uc_size < 0) {
|
|
95
|
+
throw std::runtime_error("LZ4 decompression failed.");
|
|
96
|
+
}
|
|
97
|
+
boffs = 0;
|
|
98
|
+
for (std::uint64_t idx = 0; idx < container.record_count; ++idx) {
|
|
99
|
+
_fcopy(reinterpret_cast<char *>(&frame), reinterpret_cast<char const *>(&(buffer[boffs])), sizeof(frame_header_t));
|
|
100
|
+
boffs += sizeof(frame_header_t);
|
|
101
|
+
result.emplace_back(
|
|
102
|
+
frame.category, frame.counter, frame.timestamp, frame.length, create_payload(frame.length, &buffer[boffs])
|
|
103
|
+
);
|
|
104
|
+
boffs += frame.length;
|
|
105
|
+
}
|
|
106
|
+
m_offset += container.size_compressed;
|
|
107
|
+
m_current_container += 1;
|
|
108
|
+
delete[] buffer;
|
|
109
|
+
|
|
110
|
+
return std::optional<FrameVector>{ result };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
~XcpLogFileReader() noexcept {
|
|
114
|
+
delete m_mmap;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
protected:
|
|
118
|
+
|
|
119
|
+
[[nodiscard]] blob_t const *ptr(std::uint64_t pos = 0) const {
|
|
120
|
+
return reinterpret_cast<blob_t const *>(m_mmap->data() + pos);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void read_bytes(std::uint64_t pos, std::uint64_t count, blob_t *buf) const {
|
|
124
|
+
auto addr = reinterpret_cast<char const *>(ptr(pos));
|
|
125
|
+
_fcopy(reinterpret_cast<char *>(buf), addr, count);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private:
|
|
129
|
+
|
|
130
|
+
std::string m_file_name;
|
|
131
|
+
std::uint64_t m_offset{ 0 };
|
|
132
|
+
std::uint64_t m_current_container{ 0 };
|
|
133
|
+
mio::mmap_source *m_mmap{ nullptr };
|
|
134
|
+
FileHeaderType m_header;
|
|
135
|
+
std::string m_metadata;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
#endif // RECORDER_READER_HPP
|