|
@@ -85,13 +85,15 @@ void log_init(bool format)
|
|
|
|
|
|
log_entries_capacity = ringfs_capacity(&fs_log);
|
|
log_entries_capacity = ringfs_capacity(&fs_log);
|
|
|
|
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
archive_entries_capacity = ringfs_capacity(&fs_ch_arch[0]);
|
|
archive_entries_capacity = ringfs_capacity(&fs_ch_arch[0]);
|
|
|
|
|
|
// Event
|
|
// Event
|
|
archive_event = xEventGroupCreate();
|
|
archive_event = xEventGroupCreate();
|
|
|
|
|
|
xTaskCreate(archive_task, "archive_task", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
|
|
xTaskCreate(archive_task, "archive_task", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
|
|
-
|
|
|
|
|
|
+#endif
|
|
|
|
+
|
|
log_queue = xQueueCreate(10, sizeof(log_entry_t));
|
|
log_queue = xQueueCreate(10, sizeof(log_entry_t));
|
|
|
|
|
|
xTaskCreate(log_task, "log_task", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
|
|
xTaskCreate(log_task, "log_task", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
|
|
@@ -153,8 +155,10 @@ int log_fetch(void *entry, entry_type_t entry_type, uint8_t ch, uint32_t timeout
|
|
return ret;
|
|
return ret;
|
|
if (entry_type == LOG_ENTRY)
|
|
if (entry_type == LOG_ENTRY)
|
|
ret = ringfs_fetch(&fs_log, entry);
|
|
ret = ringfs_fetch(&fs_log, entry);
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
else if (entry_type == ARCHIVE_ENTRY)
|
|
else if (entry_type == ARCHIVE_ENTRY)
|
|
ret = ringfs_fetch(&fs_ch_arch[ch], entry);
|
|
ret = ringfs_fetch(&fs_ch_arch[ch], entry);
|
|
|
|
+#endif
|
|
else ret = -1;
|
|
else ret = -1;
|
|
|
|
|
|
xSemaphoreGive(log_mutex);
|
|
xSemaphoreGive(log_mutex);
|
|
@@ -172,8 +176,10 @@ int log_discard(void *entry, entry_type_t entry_type, uint8_t ch, uint32_t timeo
|
|
return ret;
|
|
return ret;
|
|
if (entry_type == LOG_ENTRY)
|
|
if (entry_type == LOG_ENTRY)
|
|
ret = ringfs_discard(&fs_log);
|
|
ret = ringfs_discard(&fs_log);
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
else if (entry_type == ARCHIVE_ENTRY)
|
|
else if (entry_type == ARCHIVE_ENTRY)
|
|
ret = ringfs_discard(&fs_ch_arch[ch]);
|
|
ret = ringfs_discard(&fs_ch_arch[ch]);
|
|
|
|
+#endif
|
|
else ret = -1;
|
|
else ret = -1;
|
|
|
|
|
|
xSemaphoreGive(log_mutex);
|
|
xSemaphoreGive(log_mutex);
|
|
@@ -203,12 +209,14 @@ int log_append(void *entry, entry_type_t entry_type, uint8_t ch)
|
|
log_etnry_ptr->crc = crc_8(entry, sizeof(log_entry_t) - 1);
|
|
log_etnry_ptr->crc = crc_8(entry, sizeof(log_entry_t) - 1);
|
|
ret = ringfs_append(&fs_log, entry);
|
|
ret = ringfs_append(&fs_log, entry);
|
|
}
|
|
}
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
else if (entry_type == ARCHIVE_ENTRY)
|
|
else if (entry_type == ARCHIVE_ENTRY)
|
|
{
|
|
{
|
|
archive_etnry_ptr = (archive_entry_t*)entry;
|
|
archive_etnry_ptr = (archive_entry_t*)entry;
|
|
archive_etnry_ptr->crc = crc_8(entry, sizeof(archive_entry_t) - 1);
|
|
archive_etnry_ptr->crc = crc_8(entry, sizeof(archive_entry_t) - 1);
|
|
ret = ringfs_append(&fs_ch_arch[ch], entry);
|
|
ret = ringfs_append(&fs_ch_arch[ch], entry);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
else ret = -1;
|
|
else ret = -1;
|
|
|
|
|
|
xSemaphoreGive(log_mutex);
|
|
xSemaphoreGive(log_mutex);
|
|
@@ -225,7 +233,9 @@ uint16_t log_capacity(void)
|
|
//
|
|
//
|
|
uint16_t log_arch_capacity(uint8_t ch)
|
|
uint16_t log_arch_capacity(uint8_t ch)
|
|
{
|
|
{
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
return ringfs_count_exact(&fs_ch_arch[ch]);
|
|
return ringfs_count_exact(&fs_ch_arch[ch]);
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------- //
|
|
// -------------------------------------------------------------------------- //
|
|
@@ -261,8 +271,11 @@ void log_info(uint8_t val, uint8_t ch)
|
|
{
|
|
{
|
|
if (val > 1)
|
|
if (val > 1)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
struct ringfs *fs = val == 0 ? &fs_log : &fs_ch_arch[ch];
|
|
struct ringfs *fs = val == 0 ? &fs_log : &fs_ch_arch[ch];
|
|
|
|
+#else
|
|
|
|
+ struct ringfs *fs = &fs_log;
|
|
|
|
+#endif
|
|
|
|
|
|
int capacity_flash = 0;
|
|
int capacity_flash = 0;
|
|
int count_flash = 0;
|
|
int count_flash = 0;
|
|
@@ -295,10 +308,12 @@ void log_format(uint8_t val, uint8_t ch)
|
|
DBG printf("Formating log partition...\r\n");
|
|
DBG printf("Formating log partition...\r\n");
|
|
ringfs_format(&fs_log);
|
|
ringfs_format(&fs_log);
|
|
}
|
|
}
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
else if (val == 1) {
|
|
else if (val == 1) {
|
|
DBG printf("Formating archive partition...\r\n");
|
|
DBG printf("Formating archive partition...\r\n");
|
|
ringfs_format(&fs_ch_arch[ch]);
|
|
ringfs_format(&fs_ch_arch[ch]);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
// Добавить n записей журнала
|
|
// Добавить n записей журнала
|
|
@@ -420,6 +435,7 @@ void log_task(void *params)
|
|
// TODO
|
|
// TODO
|
|
void log_check_archive_cnt(void)
|
|
void log_check_archive_cnt(void)
|
|
{
|
|
{
|
|
|
|
+#if defined (MDIO_88) || (MAI_12)
|
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
|
uint8_t channel_number = log_get_arch_channel_number();
|
|
uint8_t channel_number = log_get_arch_channel_number();
|
|
|
|
|
|
@@ -436,5 +452,6 @@ void log_check_archive_cnt(void)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|