@@ -244,11 +244,12 @@ static void flash_log_write(uint8_t flush_buf)
244
244
buf_tail -= BUF_SIZE ;
245
245
}
246
246
247
- /* on error, clear the ring buffer and exit */
247
+ /* on error, clear the ring buffer, reset encoder and exit */
248
248
if (pres < 0 || sres < 0 )
249
249
{
250
250
log_compression_error ++ ;
251
251
status_flags |= ERROR_LOG_COMPRESS ;
252
+ heatshrink_encoder_reset (& hse );
252
253
buf_tail = my_head ;
253
254
return ;
254
255
}
@@ -260,11 +261,12 @@ static void flash_log_write(uint8_t flush_buf)
260
261
/* signal encoder that we are done */
261
262
fres = heatshrink_encoder_finish (& hse );
262
263
263
- /* on error, clear the ring buffer and exit */
264
+ /* on error, clear the ring buffer, reset encoder and exit */
264
265
if (fres < 0 )
265
266
{
266
267
log_compression_error ++ ;
267
268
status_flags |= ERROR_LOG_COMPRESS ;
269
+ heatshrink_encoder_reset (& hse );
268
270
buf_tail = my_head ;
269
271
return ;
270
272
}
@@ -282,22 +284,24 @@ static void flash_log_write(uint8_t flush_buf)
282
284
/* update block length */
283
285
LogBlock .env .len += poll_sz ;
284
286
285
- /* on block buffer overflow, clear the ring buffer and exit */
287
+ /* on block buffer overflow, clear the ring buffer, reset encoder and exit */
286
288
if (LogBlock .env .len >= LOG_BLOCK_DATA_SIZE )
287
289
{
288
290
log_compression_error ++ ;
289
291
status_flags |= ERROR_LOG_COMPRESS ;
292
+ heatshrink_encoder_reset (& hse );
290
293
buf_tail = my_head ;
291
294
return ;
292
295
}
293
296
} while (pres == HSER_POLL_MORE );
294
297
}
295
298
296
- /* on error, clear the ring buffer and exit */
299
+ /* on error, clear the ring buffer, reset encoder and exit */
297
300
if (pres < 0 )
298
301
{
299
302
log_compression_error ++ ;
300
303
status_flags |= ERROR_LOG_COMPRESS ;
304
+ heatshrink_encoder_reset (& hse );
301
305
buf_tail = my_head ;
302
306
return ;
303
307
}
0 commit comments