Cleaned up debugging output

This commit is contained in:
Jon Little 2019-03-25 18:33:29 -05:00
parent d375d95529
commit fb81b65bbc

View File

@ -138,7 +138,7 @@ void hreEvery50ms(void)
switch (hre_state) switch (hre_state)
{ {
case hre_sync: case hre_sync:
if (uptime < 15) if (uptime < 10)
break; break;
sync_run = 0; sync_run = 0;
sync_counter = 0; sync_counter = 0;
@ -148,9 +148,8 @@ void hreEvery50ms(void)
case hre_syncing: case hre_syncing:
// Find the header, a string of 62 '1's // Find the header, a string of 62 '1's
// Note that on startup, this could take a a whole block (46 bytes) // Since each bit taks 2 ms, we just read 20 bits at a time
// before we start seeing the header for (int i=0; i<20; i++)
for (int i=0; i<8; i++)
{ {
if (hreReadBit()) if (hreReadBit())
sync_run++; sync_run++;
@ -173,7 +172,7 @@ void hreEvery50ms(void)
// Start reading the data block // Start reading the data block
case hre_read: case hre_read:
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE " sync_run:%d, sync_counter:%d"), sync_run, sync_counter); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "sync_run:%d, sync_counter:%d"), sync_run, sync_counter);
read_counter = 0; read_counter = 0;
parity_errors = 0; parity_errors = 0;
curr_start = uptime; curr_start = uptime;
@ -186,15 +185,14 @@ void hreEvery50ms(void)
// are looking for... // are looking for...
case hre_reading: case hre_reading:
//KG44?Q45484=0444444V;RB000000022;IB018435683 // Read two characters at a time...
// RB003119173;IB018435683 buff[read_counter++] = hreReadChar(parity_errors);
buff[read_counter] = hreReadChar(parity_errors); buff[read_counter++] = hreReadChar(parity_errors);
read_counter++;
if (read_counter == 46) if (read_counter == 46)
{ {
//buff[33]='\0'; AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "pe:%d, re:%d, buff:%s"),
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE " pe:%d, buff:%s"), parity_errors, buff); parity_errors, hre_read_errors, buff);
if (parity_errors == 0) if (parity_errors == 0)
{ {
float curr_usage; float curr_usage;
@ -207,7 +205,7 @@ void hreEvery50ms(void)
hre_usage = curr_usage; hre_usage = curr_usage;
hre_usage_time = curr_start; hre_usage_time = curr_start;
hre_good = true; hre_good = true;
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE " usage:%d, rate:%d"), int(100*hre_usage), int(100*hre_rate));
hre_state = hre_sleep; hre_state = hre_sleep;
} }
else else
@ -224,7 +222,9 @@ void hreEvery50ms(void)
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_sleeping")); AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_sleeping"));
case hre_sleeping: case hre_sleeping:
if (uptime - hre_usage_time > 27) // If there isn't some delay between readings, rate calculations
// aren't as accurate. 27 seconds will give about a 30 second refresh rate
if (uptime - hre_usage_time >= 27)
hre_state = hre_sync; hre_state = hre_sync;
} }
} }
@ -236,8 +236,8 @@ void hreShow(boolean json)
const char *id = "HRE"; const char *id = "HRE";
char usage[33]; char usage[16];
char rate[33]; char rate[16];
dtostrfd(hre_usage, 2, usage); dtostrfd(hre_usage, 2, usage);
dtostrfd(hre_rate, 3, rate); dtostrfd(hre_rate, 3, rate);