@@ -161,6 +161,7 @@ static void flash_log_block_commit(void)
161
161
current_block = FLASH_LOG_FIRST_BLOCK ;
162
162
#else
163
163
log_running = 0 ;
164
+ status_flags |= ERROR_FLASH_FULL ;
164
165
#endif
165
166
}
166
167
@@ -223,8 +224,10 @@ static int flash_log_write(uint8_t flush_buf)
223
224
sres = heatshrink_encoder_sink (& hse , buf_tail , chunk_size , & sink_sz );
224
225
225
226
/* handle encoder error */
226
- if (sres < 0 )
227
+ if (sres < 0 ) {
228
+ status_flags |= ERROR_LOG_COMPRESS ;
227
229
goto cleanup ;
230
+ }
228
231
229
232
/* advance tail of ring buffer */
230
233
buf_tail += sink_sz ;
@@ -239,12 +242,21 @@ static int flash_log_write(uint8_t flush_buf)
239
242
LOG_BLOCK_DATA_SIZE - LogBlock .env .len ,
240
243
& poll_sz );
241
244
245
+ /* update block length */
242
246
LogBlock .env .len += poll_sz ;
247
+
248
+ /* handle block buffer overflow */
249
+ if (LogBlock .env .len >= LOG_BLOCK_DATA_SIZE ) {
250
+ status_flags |= ERROR_LOG_BLK_OVERFLOW ;
251
+ goto cleanup ;
252
+ }
243
253
} while (pres == HSER_POLL_MORE );
244
254
245
255
/* handle encoder error */
246
- if (pres < 0 )
256
+ if (pres < 0 ) {
257
+ status_flags |= ERROR_LOG_COMPRESS ;
247
258
goto cleanup ;
259
+ }
248
260
}
249
261
250
262
/* if block buffer is almost full, or if we are flushing the ring buffer,
@@ -255,8 +267,10 @@ static int flash_log_write(uint8_t flush_buf)
255
267
fres = heatshrink_encoder_finish (& hse );
256
268
257
269
/* handle encoder error */
258
- if (fres < 0 )
270
+ if (fres < 0 ) {
271
+ status_flags |= ERROR_LOG_COMPRESS ;
259
272
goto cleanup ;
273
+ }
260
274
261
275
/* if necessary, pull out remaining compressed data */
262
276
if (fres == HSER_FINISH_MORE )
@@ -280,8 +294,10 @@ static int flash_log_write(uint8_t flush_buf)
280
294
}
281
295
282
296
/* handle encoder error */
283
- if (pres < 0 )
297
+ if (pres < 0 ) {
298
+ status_flags |= ERROR_LOG_COMPRESS ;
284
299
goto cleanup ;
300
+ }
285
301
286
302
/* reset encoder */
287
303
heatshrink_encoder_reset (& hse );
@@ -296,9 +312,8 @@ static int flash_log_write(uint8_t flush_buf)
296
312
/* on error, reset all state */
297
313
cleanup :
298
314
299
- /* report error */
315
+ /* log error */
300
316
log_compression_error ++ ;
301
- status_flags |= ERROR_LOG_COMPRESS ;
302
317
303
318
/* clear block buffer */
304
319
block_init ();
0 commit comments