Skip to content

Commit 8946989

Browse files
committed
On error, reset heatshrink encoder
1 parent c207266 commit 8946989

File tree

1 file changed

+8
-4
lines changed
  • firmware/nRF51/tag-proximity/src

1 file changed

+8
-4
lines changed

firmware/nRF51/tag-proximity/src/log.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ static void flash_log_write(uint8_t flush_buf)
244244
buf_tail -= BUF_SIZE;
245245
}
246246

247-
/* on error, clear the ring buffer and exit */
247+
/* on error, clear the ring buffer, reset encoder and exit */
248248
if (pres < 0 || sres < 0)
249249
{
250250
log_compression_error++;
251251
status_flags |= ERROR_LOG_COMPRESS;
252+
heatshrink_encoder_reset(&hse);
252253
buf_tail = my_head;
253254
return;
254255
}
@@ -260,11 +261,12 @@ static void flash_log_write(uint8_t flush_buf)
260261
/* signal encoder that we are done */
261262
fres = heatshrink_encoder_finish(&hse);
262263

263-
/* on error, clear the ring buffer and exit */
264+
/* on error, clear the ring buffer, reset encoder and exit */
264265
if (fres < 0)
265266
{
266267
log_compression_error++;
267268
status_flags |= ERROR_LOG_COMPRESS;
269+
heatshrink_encoder_reset(&hse);
268270
buf_tail = my_head;
269271
return;
270272
}
@@ -282,22 +284,24 @@ static void flash_log_write(uint8_t flush_buf)
282284
/* update block length */
283285
LogBlock.env.len += poll_sz;
284286

285-
/* on block buffer overflow, clear the ring buffer and exit */
287+
/* on block buffer overflow, clear the ring buffer, reset encoder and exit */
286288
if (LogBlock.env.len >= LOG_BLOCK_DATA_SIZE)
287289
{
288290
log_compression_error++;
289291
status_flags |= ERROR_LOG_COMPRESS;
292+
heatshrink_encoder_reset(&hse);
290293
buf_tail = my_head;
291294
return;
292295
}
293296
} while (pres == HSER_POLL_MORE);
294297
}
295298

296-
/* on error, clear the ring buffer and exit */
299+
/* on error, clear the ring buffer, reset encoder and exit */
297300
if (pres < 0)
298301
{
299302
log_compression_error++;
300303
status_flags |= ERROR_LOG_COMPRESS;
304+
heatshrink_encoder_reset(&hse);
301305
buf_tail = my_head;
302306
return;
303307
}

0 commit comments

Comments
 (0)