@@ -207,7 +207,7 @@ static int flash_log_write(uint8_t flush_buf)
207
207
/* proceed until there is data in the ring buffer
208
208
and there is space in the block buffer */
209
209
while ( (BUF_LEN (my_head ,buf_tail ) > 0 ) &&
210
- (LOG_BLOCK_DATA_SIZE - LogBlock .env .len > COMPRESS_CHUNK_SIZE ) )
210
+ (LOG_BLOCK_DATA_SIZE - LogBlock .env .len > BLOCK_SPACE_MIN ) )
211
211
{
212
212
/* set the size of the next _contiguous_ chunk to compress */
213
213
if (buf_tail < my_head )
@@ -226,6 +226,11 @@ static int flash_log_write(uint8_t flush_buf)
226
226
if (sres < 0 )
227
227
goto cleanup ;
228
228
229
+ /* advance tail of ring buffer */
230
+ buf_tail += sink_sz ;
231
+ if (buf_tail >= buffer + BUF_SIZE )
232
+ buf_tail -= BUF_SIZE ;
233
+
229
234
/* pull out the compressed stream */
230
235
do {
231
236
pres = heatshrink_encoder_poll (
@@ -240,16 +245,11 @@ static int flash_log_write(uint8_t flush_buf)
240
245
/* handle encoder error */
241
246
if (pres < 0 )
242
247
goto cleanup ;
243
-
244
- /* advance tail of ring buffer */
245
- buf_tail += sink_sz ;
246
- if (buf_tail >= buffer + BUF_SIZE )
247
- buf_tail -= BUF_SIZE ;
248
248
}
249
249
250
250
/* if block buffer is almost full, or if we are flushing the ring buffer,
251
251
flush the encoder and commit compressed data to flash memory */
252
- if ( (LOG_BLOCK_DATA_SIZE - LogBlock .env .len <= COMPRESS_CHUNK_SIZE ) || flush_buf )
252
+ if ( (LOG_BLOCK_DATA_SIZE - LogBlock .env .len <= BLOCK_SPACE_MIN ) || flush_buf )
253
253
{
254
254
/* signal encoder that we are done */
255
255
fres = heatshrink_encoder_finish (& hse );
0 commit comments