mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Keep RF log indexes traffic-only
This commit is contained in:
1 parent
fc12a35418
commit
0567f01786
1 file changed
+27
-37
+27
-37
@@ -477,9 +477,6 @@ static void RXTX_LOG_StepViewCacheScan(void)
|
|||||||
!RXTX_LOG_MatchesFlags(flashEntry.flags))
|
!RXTX_LOG_MatchesFlags(flashEntry.flags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Traffic entries carry their own absolute rank (trafficSeq); the
|
|
||||||
// distance from the newest one bounds how far back browsing goes,
|
|
||||||
// no running counter needed to reconstruct it during the scan.
|
|
||||||
if (RXTX_LOG_IsTrafficFlags(flashEntry.flags) &&
|
if (RXTX_LOG_IsTrafficFlags(flashEntry.flags) &&
|
||||||
(gNextTrafficSequence - 1u - flashEntry.trafficSeq) >= RXTX_LOG_VISIBLE_COUNT) {
|
(gNextTrafficSequence - 1u - flashEntry.trafficSeq) >= RXTX_LOG_VISIBLE_COUNT) {
|
||||||
capReached = true;
|
capReached = true;
|
||||||
@@ -702,9 +699,9 @@ static void RXTX_LOG_WriteSessionMarker(void)
|
|||||||
RXTX_LogEntry_t entry;
|
RXTX_LogEntry_t entry;
|
||||||
|
|
||||||
memset(&entry, 0, sizeof(entry));
|
memset(&entry, 0, sizeof(entry));
|
||||||
// Markers take a rank in the traffic sequence so the K5Viewer stream
|
// Markers share the ordinal of the next traffic row. Their flash
|
||||||
// can order and page them along with the RX/TX rows they separate.
|
// sequence remains unique and is used to order them in K5Viewer.
|
||||||
entry.trafficSeq = gNextTrafficSequence++;
|
entry.trafficSeq = gNextTrafficSequence;
|
||||||
entry.channel = RXTX_LOG_CHANNEL_NONE;
|
entry.channel = RXTX_LOG_CHANNEL_NONE;
|
||||||
entry.flags = RXTX_LOG_FLAG_SESSION;
|
entry.flags = RXTX_LOG_FLAG_SESSION;
|
||||||
entry.sMeter = RXTX_LOG_SMETER_UNKNOWN;
|
entry.sMeter = RXTX_LOG_SMETER_UNKNOWN;
|
||||||
@@ -791,7 +788,7 @@ static void RXTX_LOG_SetK5ViewerChannelName(RXTX_LogK5ViewerRow_t *row, uint16_t
|
|||||||
static void RXTX_LOG_CopyK5ViewerRow(RXTX_LogK5ViewerRow_t *dst, const RXTX_LogFlashEntry_t *src)
|
static void RXTX_LOG_CopyK5ViewerRow(RXTX_LogK5ViewerRow_t *dst, const RXTX_LogFlashEntry_t *src)
|
||||||
{
|
{
|
||||||
dst->frequency = src->frequency;
|
dst->frequency = src->frequency;
|
||||||
dst->trafficSeq = src->trafficSeq;
|
dst->trafficSeq = src->sequence;
|
||||||
dst->durationSeconds = src->durationSeconds;
|
dst->durationSeconds = src->durationSeconds;
|
||||||
dst->channel = src->channel;
|
dst->channel = src->channel;
|
||||||
dst->flags = src->flags;
|
dst->flags = src->flags;
|
||||||
@@ -800,9 +797,9 @@ static void RXTX_LOG_CopyK5ViewerRow(RXTX_LogK5ViewerRow_t *dst, const RXTX_LogF
|
|||||||
RXTX_LOG_SetK5ViewerChannelName(dst, src->channel);
|
RXTX_LOG_SetK5ViewerChannelName(dst, src->channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send up to `count` rows whose trafficSeq is below `beforeSeq`, newest
|
// Send up to `count` rows whose flash sequence is below `beforeSeq`, newest
|
||||||
// first, scanning the ring backwards from the write head and zero-padding
|
// first, scanning the ring backwards from the write head and zero-padding
|
||||||
// past the last valid entry. Returns the trafficSeq of the oldest row
|
// past the last valid entry. Returns the sequence of the oldest row
|
||||||
// sent when more visible history remains below it, 0 otherwise: feeding
|
// sent when more visible history remains below it, 0 otherwise: feeding
|
||||||
// that value back as the next `beforeSeq` pages through the whole
|
// that value back as the next `beforeSeq` pages through the whole
|
||||||
// visible history without duplicating or skipping rows, even while new
|
// visible history without duplicating or skipping rows, even while new
|
||||||
@@ -813,6 +810,7 @@ static uint32_t RXTX_LOG_SendK5ViewerRows(uint32_t beforeSeq, uint8_t count,
|
|||||||
RXTX_LogK5ViewerRow_t row;
|
RXTX_LogK5ViewerRow_t row;
|
||||||
uint8_t rowsSent = 0;
|
uint8_t rowsSent = 0;
|
||||||
uint32_t nextBefore = 0;
|
uint32_t nextBefore = 0;
|
||||||
|
bool trafficLimitReached = false;
|
||||||
|
|
||||||
if (gLogHasTraffic && beforeSeq > 0) {
|
if (gLogHasTraffic && beforeSeq > 0) {
|
||||||
uint16_t slot = RXTX_LOG_AddressToSlot(gNextFlashAddress);
|
uint16_t slot = RXTX_LOG_AddressToSlot(gNextFlashAddress);
|
||||||
@@ -827,28 +825,25 @@ static uint32_t RXTX_LOG_SendK5ViewerRows(uint32_t beforeSeq, uint8_t count,
|
|||||||
break;
|
break;
|
||||||
if (!RXTX_LOG_IsValidFlashEntry(&flashEntry))
|
if (!RXTX_LOG_IsValidFlashEntry(&flashEntry))
|
||||||
continue;
|
continue;
|
||||||
if ((gNextTrafficSequence - 1u - flashEntry.trafficSeq) >= RXTX_LOG_VISIBLE_COUNT) {
|
|
||||||
// The backwards scan only guarantees decreasing ranks for
|
|
||||||
// traffic rows: a session marker written before markers
|
|
||||||
// carried a rank reads as 0, skip it without ending the
|
|
||||||
// scan or it would truncate the remaining history.
|
|
||||||
if (RXTX_LOG_IsTrafficFlags(flashEntry.flags))
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (flashEntry.trafficSeq >= beforeSeq)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
if (RXTX_LOG_IsTrafficFlags(flashEntry.flags) &&
|
||||||
|
(gNextTrafficSequence - 1u - flashEntry.trafficSeq) >= RXTX_LOG_VISIBLE_COUNT) {
|
||||||
|
trafficLimitReached = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flashEntry.sequence < beforeSeq) {
|
||||||
RXTX_LOG_CopyK5ViewerRow(&row, &flashEntry);
|
RXTX_LOG_CopyK5ViewerRow(&row, &flashEntry);
|
||||||
send((const uint8_t *)&row, sizeof(row));
|
send((const uint8_t *)&row, sizeof(row));
|
||||||
rowsSent++;
|
rowsSent++;
|
||||||
nextBefore = flashEntry.trafficSeq;
|
nextBefore = flashEntry.sequence;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A short page means the log ran out; a full page ending on the
|
// A short page means the log ran out. Reaching 512 traffic rows is
|
||||||
// oldest visible entry is equally final.
|
// equally final; session markers never consume one of those rows.
|
||||||
if (rowsSent < count || (gNextTrafficSequence - nextBefore) >= RXTX_LOG_VISIBLE_COUNT)
|
if (rowsSent < count || trafficLimitReached)
|
||||||
nextBefore = 0;
|
nextBefore = 0;
|
||||||
|
|
||||||
memset(&row, 0, sizeof(row));
|
memset(&row, 0, sizeof(row));
|
||||||
@@ -877,7 +872,7 @@ void RXTX_LOG_SendK5ViewerPacket(void (*send)(const uint8_t *data, uint16_t size
|
|||||||
send(header, sizeof(header));
|
send(header, sizeof(header));
|
||||||
|
|
||||||
row.frequency = gSessionFrequency;
|
row.frequency = gSessionFrequency;
|
||||||
row.trafficSeq = gNextTrafficSequence;
|
row.trafficSeq = gNextSequence;
|
||||||
row.durationSeconds = (gSessionTicks500ms + 1u) / 2u;
|
row.durationSeconds = (gSessionTicks500ms + 1u) / 2u;
|
||||||
row.channel = gSessionChannel;
|
row.channel = gSessionChannel;
|
||||||
row.flags = gSessionFlags;
|
row.flags = gSessionFlags;
|
||||||
@@ -885,17 +880,16 @@ void RXTX_LOG_SendK5ViewerPacket(void (*send)(const uint8_t *data, uint16_t size
|
|||||||
row.battVolt = gSessionBattVolt;
|
row.battVolt = gSessionBattVolt;
|
||||||
RXTX_LOG_SetK5ViewerChannelName(&row, gSessionChannel);
|
RXTX_LOG_SetK5ViewerChannelName(&row, gSessionChannel);
|
||||||
send((const uint8_t *)&row, sizeof(row));
|
send((const uint8_t *)&row, sizeof(row));
|
||||||
RXTX_LOG_SendK5ViewerRows(gNextTrafficSequence, RXTX_LOG_K5VIEWER_ROW_COUNT, send);
|
RXTX_LOG_SendK5ViewerRows(gNextSequence, RXTX_LOG_K5VIEWER_ROW_COUNT, send);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RXTX_LOG_SendK5ViewerHistoryPage(uint32_t beforeSeq, void (*send)(const uint8_t *data, uint16_t size))
|
uint32_t RXTX_LOG_SendK5ViewerHistoryPage(uint32_t beforeSeq, void (*send)(const uint8_t *data, uint16_t size))
|
||||||
{
|
{
|
||||||
// First page of a dump: start right below the rows the live packet
|
// Flash sequence counts every stored row, including session markers,
|
||||||
// already covers. A log shorter than the live packet leaves nothing
|
// so subtracting the live page size lands directly below that page.
|
||||||
// to dump (the subtraction would wrap).
|
|
||||||
if (beforeSeq == RXTX_LOG_K5VIEWER_HISTORY_START)
|
if (beforeSeq == RXTX_LOG_K5VIEWER_HISTORY_START)
|
||||||
beforeSeq = gNextTrafficSequence > RXTX_LOG_K5VIEWER_ROW_COUNT
|
beforeSeq = gNextSequence > RXTX_LOG_K5VIEWER_ROW_COUNT
|
||||||
? gNextTrafficSequence - RXTX_LOG_K5VIEWER_ROW_COUNT
|
? gNextSequence - RXTX_LOG_K5VIEWER_ROW_COUNT
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
return RXTX_LOG_SendK5ViewerRows(beforeSeq, RXTX_LOG_K5VIEWER_HISTORY_ROW_COUNT, send);
|
return RXTX_LOG_SendK5ViewerRows(beforeSeq, RXTX_LOG_K5VIEWER_HISTORY_ROW_COUNT, send);
|
||||||
@@ -961,17 +955,13 @@ void RXTX_LOG_Init(void)
|
|||||||
if (!RXTX_LOG_IsValidFlashEntry(&flashEntry))
|
if (!RXTX_LOG_IsValidFlashEntry(&flashEntry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (RXTX_LOG_IsTrafficFlags(flashEntry.flags))
|
if (RXTX_LOG_IsTrafficFlags(flashEntry.flags)) {
|
||||||
gLogHasTraffic = true;
|
gLogHasTraffic = true;
|
||||||
|
|
||||||
// Session markers consume a trafficSeq too: restore the counter
|
|
||||||
// from every ranked entry, or a reboot would hand the rank the
|
|
||||||
// boot marker just took to the next traffic entry. Markers written
|
|
||||||
// before they carried a rank read as 0 and never win.
|
|
||||||
if (!foundTraffic || flashEntry.trafficSeq > maxTrafficSeq) {
|
if (!foundTraffic || flashEntry.trafficSeq > maxTrafficSeq) {
|
||||||
foundTraffic = true;
|
foundTraffic = true;
|
||||||
maxTrafficSeq = flashEntry.trafficSeq;
|
maxTrafficSeq = flashEntry.trafficSeq;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!found || flashEntry.sequence > maxSequence) {
|
if (!found || flashEntry.sequence > maxSequence) {
|
||||||
found = true;
|
found = true;
|
||||||
|
|||||||
Reference in new issue
Block a user