Skip to content

Commit

Permalink
Add signal quality for 4-wire comms
Browse files Browse the repository at this point in the history
When logging using /debug-on/
  • Loading branch information
visualapproach committed Jun 8, 2024
1 parent a8beaea commit 1b98abe
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Code/lib/BWC_unified/FW_VERSION.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define FW_VERSION "2024-06-06-0950"
#define FW_VERSION "2024-06-08-1820"
26 changes: 22 additions & 4 deletions Code/lib/BWC_unified/bwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,17 @@ void BWC::_log()
// Serial.println(F("Failed to save states.txt"));
return;
}
if(++writes > 1000) return;
file.print(_timestamp_secs);
file.printf_P(PSTR("SW:%s \nCIO-ESP:"), FW_VERSION);
if(++writes > 1000)
{
file.printf_P(PSTR("\n**** MAX LENGTH OF FILE REACHED. DELETE FILE TO LOG AGAIN"));
return;
}

tm * p_time_tm = gmtime((time_t*) &_timestamp_secs);
char tm_string[64];
strftime(tm_string, 64, "%F %T", p_time_tm);
file.print(tm_string);
file.printf_P(PSTR("UTC. SW:%s \nCIO-ESP:"), FW_VERSION);
for(unsigned int i = 0; i< fromcio.size(); i++)
{
if(i>0)file.print(',');
Expand All @@ -278,7 +286,17 @@ void BWC::_log()
if(i>0)file.print(',');
file.print(todsp[i], HEX);
}
file.printf_P(PSTR("\nCIO msg count: %d DSP msg count: %d\n"), cio->good_packets_count, dsp->good_packets_count);
file.printf_P(PSTR("\nCIO msg count: %d DSP msg count: %d"), cio->good_packets_count, dsp->good_packets_count);
float CIO_quality, DSP_quality;
if(cio->good_packets_count == 0 && cio->bad_packets_count == 0)
CIO_quality = 0;
else
CIO_quality = 100 * cio->good_packets_count / (cio->good_packets_count + cio->bad_packets_count);
if(dsp->good_packets_count == 0 && dsp->bad_packets_count == 0)
DSP_quality = 0;
else
DSP_quality = 100 * dsp->good_packets_count / (dsp->good_packets_count + dsp->bad_packets_count);
file.printf_P(PSTR("\nCIO msg quality: %f%% DSP msg quality: %f%% (Only useful in 4 wire pumps)\n\n"), CIO_quality, DSP_quality);
file.close();
}

Expand Down
2 changes: 1 addition & 1 deletion Code/lib/cio/CIO_4W.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void CIO_4W::updateStates()
calculatedChecksum = tempbuffer[1]+tempbuffer[2]+tempbuffer[3]+tempbuffer[4];
if(tempbuffer[CIO_CHECKSUMINDEX] != calculatedChecksum)
{
//badCIO_checksum++;
bad_packets_count++;
return;
}
/*message is good if we get here. Continue*/
Expand Down
1 change: 1 addition & 0 deletions Code/lib/cio/CIO_BASE.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CIO
sToggles cio_toggles;
int _button_que_len = 0; //length of buttonQ
uint32_t good_packets_count = 0;
uint32_t bad_packets_count = 0;
std::vector<uint8_t> _raw_payload_to_cio = {0,0,0,0,0,0,0,0,0,0,0};
int write_msg_count = 0;

Expand Down
1 change: 1 addition & 0 deletions Code/lib/dsp/DSP_4W.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void DSP_4W::updateToggles()
calculatedChecksum = tempbuffer[1]+tempbuffer[2]+tempbuffer[3]+tempbuffer[4];
if(tempbuffer[DSP_CHECKSUMINDEX] != calculatedChecksum)
{
bad_packets_count++;
return;
}
/*message is good if we get here. Continue*/
Expand Down
1 change: 1 addition & 0 deletions Code/lib/dsp/DSP_BASE.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class DSP
std::vector<uint8_t> _raw_payload_to_dsp = {0,0,0,0,0,0,0,0,0,0,0};
int audiofrequency = 0;
uint32_t good_packets_count = 0;
uint32_t bad_packets_count = 0;
int write_msg_count = 0;

/*
Expand Down
6 changes: 3 additions & 3 deletions Code/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ platform = espressif8266@^4
board = nodemcuv2
framework = arduino
lib_deps =
bblanchon/[email protected]
bblanchon/[email protected] ; v7 is using more memory
; mcxiaoke/ESPDateTime
links2004/WebSockets
knolleary/PubSubClient
me-no-dev/ESPAsyncTCP
; khoih-prog/ESP_WifiManager@^1.12.1
tzapu/WifiManager
https://github.com/dok-net/ghostl ; << Fix missing circular_queue.h in plerup/[email protected]
tzapu/WifiManager
https://github.com/dok-net/ghostl ; << Fix missing circular_queue.h in plerup/[email protected]
plerup/EspSoftwareSerial
milesburton/DallasTemperature
board_build.filesystem = littlefs
Expand Down

0 comments on commit 1b98abe

Please sign in to comment.