Skip to content

Commit

Permalink
recorder: Update interface
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Aug 17, 2022
1 parent ca9f649 commit 5dad87e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pyxcp/recorder/rekorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void some_records(XcpLogFileWriter& writer)
{
const auto COUNT = 1024 * 100 * 5;
unsigned filler = 0x00;
blob_t buffer[1024];
char buffer[1024];

for (auto idx = 0; idx < COUNT; ++idx) {
auto fr = frame_header_t{};
Expand All @@ -18,7 +18,7 @@ void some_records(XcpLogFileWriter& writer)
fr.length = 10 + (rand() % 240);
filler = (filler + 1) % 16;
memset(buffer, filler, fr.length);
writer.add_frame(fr.category, fr.counter, fr.timestamp, fr.length, reinterpret_cast<blob_t *>(buffer));
writer.add_frame(fr.category, fr.counter, fr.timestamp, fr.length, reinterpret_cast<char*>(&buffer));
}
}

Expand Down
7 changes: 3 additions & 4 deletions pyxcp/recorder/rekorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,13 @@ class XcpLogFileWriter
}
}

void add_frame(uint8_t category, uint16_t counter, double timestamp, uint16_t length, blob_t * data/*payload_t& payload*/) {
void add_frame(uint8_t category, uint16_t counter, double timestamp, uint16_t length, char const * data) {
auto pl = std::make_shared<blob_t[]>(length);
_fcopy(reinterpret_cast<char*>(pl.get()), reinterpret_cast<char const *>(data), length);
//#if 0
_fcopy(reinterpret_cast<char*>(pl.get()), data, length);

my_queue.put(
std::make_tuple(category, counter, timestamp, length, std::move(pl))
);
//#endif

#if 0
const frame_header_t frame {category, counter, timestamp, length};
Expand Down
14 changes: 7 additions & 7 deletions pyxcp/recorder/test_reko.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@

# Pre-allocate a 100MB file -- Note: due to the nature of memory-mapped files, this is a HARD limit.
# Chunk size is 1MB (i.e. compression granularity).
writer = XcpLogFileWriter("test_logger", prealloc = 100, chunk_size=1)
writer = XcpLogFileWriter("test_logger", prealloc=100, chunk_size=1)

# Write some records.
for idx in range(512 * 1024):
value = idx % 256
writer.add_frame(FrameCategory.CMD, idx, perf_counter(), [value] * value)
writer.finalize() # We're done.
writer.add_frame(FrameCategory.CMD, idx, perf_counter(), bytes([value] * value))
writer.finalize() # We're done.


reader = XcpLogFileReader("test_logger")
hdr = reader.get_header() # Get file information.
hdr = reader.get_header() # Get file information.
print(hdr)

df = reader.as_dataframe() # Return recordings as Pandas DataFrame.
df = reader.as_dataframe() # Return recordings as Pandas DataFrame.
print(df.info())
print(df.describe())


reader.reset_iter() # Non-standard method to restart iteration.
reader.reset_iter() # Non-standard method to restart iteration.

idx = 0
# Iterate over frames/records.
for frame in reader:
for _frame in reader:
idx += 1
print("---")
print(f"Iterated over {idx} frames")

0 comments on commit 5dad87e

Please sign in to comment.