1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include "log_api.h"
- #include "log.h"
- #include "rtc.h"
- #include "ringfs.h"
- #include "spi_flash.h"
- #include "FreeRTOS.h"
- #include "task.h"
- #include "semphr.h"
- #include "rtc.h"
- #include <string.h>
- #include <stdio.h>
- #include <inttypes.h>
- #undef DBG
- #define DBG if(1)
- extern struct ringfs fs_archive;
- extern SemaphoreHandle_t log_mutex;
- //
- void log_get_entry_count(void)
- {
- int count_flash = 0;
-
- count_flash = ringfs_count_exact(&fs_archive);
- printf("Count archive entry: %u\r\n", count_flash);
- }
- //
- int log_get_entry(uint32_t index, struct ringfs *fs)
- {
- archive_entry_t entry;
- int start = ringfs_count_estimate(fs);
-
- fs->cursor_position = start - (index - 1) - 1;
-
- if (fs->cursor_position < 0)
- return -1;
- else
- {
- fs->cursor.sector = (fs->read.sector + fs->cursor_position/fs->slots_per_sector)%fs->flash->sector_count;
- fs->cursor.slot = fs->cursor_position%fs->slots_per_sector;
- }
-
- log_fetch(&entry, ARCHIVE_ENTRY, portMAX_DELAY);
-
- printf("[entry] timestamp = % " PRId64 ", value = %u, crc = %u\r\n", entry.timestamp, entry.input_value, entry.crc);
-
- return 0;
- }
- //
- int mb_log_get_entry(uint8_t *buf, uint16_t entry_index)
- {
- *buf = 77;
-
- return 0;
- }
|