generated from BrianPugh/python-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I currently have a ESP project where I write constantly to a file with the following function:
bool startTracking() {
file = LittleFS.open("Test.bin", "w");
if (!file) {
return false;
}
return true;
}
bool writeTrackingFile(const uint8_t *buffer, size_t length) {
return file.write(buffer, length) == length;
}
bool stopTracking() {
file.flush();
file.close();
return true;
}
The function writeTrackingFile
will be called on different length data. Now I want to add the tamp compressor before writing to the file. My approach would be:
const uint8_t compressorWindowBits = 10;
uint8_t compressorWindowBuffer[1 << compressorWindowBits];
uint8_t compressorOutputBuffer[64];
TampCompressor compressor;
TampConf compressorConf = {
.window = compressorWindowBits,
.literal = 8,
.use_custom_dictionary = false
};
bool startTracking() {
file = LittleFS.open("Test.bin", "w");
if (!file) {
return false;
}
if (tamp_compressor_init(&compressor, &compressorConf, compressorWindowBuffer) != TAMP_OK) {
ESP_LOGE(TAG, "Failed to initialize compressor");
return false;
}
return true;
}
bool writeTrackingFile(const uint8_t *buffer, size_t length) {
// TODO: Lost on how to write what to the buffer. Should I use tamp_compressor_compress_and_flush? or non flush version with sink and poll and only flush in stopTracking()?
return file.write(buffer, length) == length;
}
bool stopTracking() {
// TODO: Need to flush the compressor to get internal bytes?
file.flush();
file.close();
return true;
}
Thank you for your help! This library looks quite promising. Later on I want to test the high speed decompression with Python C bindings.
Metadata
Metadata
Assignees
Labels
No labels