Skip to content

Commit c786848

Browse files
committed
flash_log_write() returns success/fail info
1 parent 8946989 commit c786848

File tree

1 file changed

+12
-7
lines changed
  • firmware/nRF51/tag-proximity/src

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void flash_log_block_commit(void)
193193

194194
#if FLASH_LOG_COMPRESSION
195195

196-
static void flash_log_write(uint8_t flush_buf)
196+
static int flash_log_write(uint8_t flush_buf)
197197
{
198198
uint8_t *my_head = buf_head;
199199
uint16_t chunk_size;
@@ -251,7 +251,7 @@ static void flash_log_write(uint8_t flush_buf)
251251
status_flags |= ERROR_LOG_COMPRESS;
252252
heatshrink_encoder_reset(&hse);
253253
buf_tail = my_head;
254-
return;
254+
return 1;
255255
}
256256

257257
/* if block buffer is almost full, or if we are flushing the ring buffer,
@@ -268,7 +268,7 @@ static void flash_log_write(uint8_t flush_buf)
268268
status_flags |= ERROR_LOG_COMPRESS;
269269
heatshrink_encoder_reset(&hse);
270270
buf_tail = my_head;
271-
return;
271+
return 1;
272272
}
273273

274274
/* if necessary, pull out remaining compressed data */
@@ -291,7 +291,7 @@ static void flash_log_write(uint8_t flush_buf)
291291
status_flags |= ERROR_LOG_COMPRESS;
292292
heatshrink_encoder_reset(&hse);
293293
buf_tail = my_head;
294-
return;
294+
return 1;
295295
}
296296
} while (pres == HSER_POLL_MORE);
297297
}
@@ -303,7 +303,7 @@ static void flash_log_write(uint8_t flush_buf)
303303
status_flags |= ERROR_LOG_COMPRESS;
304304
heatshrink_encoder_reset(&hse);
305305
buf_tail = my_head;
306-
return;
306+
return 1;
307307
}
308308

309309
/* reset encoder */
@@ -312,11 +312,13 @@ static void flash_log_write(uint8_t flush_buf)
312312
/* commit block to flash */
313313
flash_log_block_commit();
314314
}
315+
316+
return 0;
315317
}
316318

317319
#else
318320

319-
static void flash_log_write(uint8_t flush_buf)
321+
static int flash_log_write(uint8_t flush_buf)
320322
{
321323
uint8_t *my_head = buf_head;
322324
uint16_t chunk_size;
@@ -349,6 +351,8 @@ static void flash_log_write(uint8_t flush_buf)
349351
commit block to flash memory */
350352
if ( (LogBlock.env.len == LOG_BLOCK_DATA_SIZE) || flush_buf )
351353
flash_log_block_commit();
354+
355+
return 0;
352356
}
353357

354358
#endif /* FLASH_LOG_COMPRESSION */
@@ -369,7 +373,8 @@ void flash_log_flush(void)
369373

370374
/* flush ring buffer */
371375
while (BUF_LEN(my_head,buf_tail) > 0)
372-
flash_log_write(0);
376+
if (flash_log_write(0))
377+
break; /* on error */
373378

374379
/* flush block buffer */
375380
flash_log_write(1);

0 commit comments

Comments
 (0)