#60: avoid errors in the web ui when the rx fifo overflows (strange counter ids), add an error log for serial errors
This commit is contained in:
parent
41b629e17b
commit
f99d6ed2eb
|
@ -106,20 +106,34 @@ void GwChannel::setImpl(GwChannelInterface *impl){
|
||||||
}
|
}
|
||||||
void GwChannel::updateCounter(const char *msg, bool out)
|
void GwChannel::updateCounter(const char *msg, bool out)
|
||||||
{
|
{
|
||||||
char key[6];
|
char key[7];
|
||||||
|
key[0]=0;
|
||||||
if (msg[0] == '$')
|
if (msg[0] == '$')
|
||||||
{
|
{
|
||||||
strncpy(key, &msg[3], 3);
|
for (int i=0;i<6 && msg[i] != 0;i++){
|
||||||
|
if (i>=3) {
|
||||||
|
if (isalnum(msg[i]))key[i-3]=msg[i];
|
||||||
|
else key[i-3]='_';
|
||||||
|
}
|
||||||
|
key[i-2]=0;
|
||||||
|
}
|
||||||
key[3] = 0;
|
key[3] = 0;
|
||||||
}
|
}
|
||||||
else if (msg[0] == '!')
|
else if (msg[0] == '!')
|
||||||
{
|
{
|
||||||
strncpy(key, &msg[1], 5);
|
for (int i=0;i<6 && msg[i] != 0;i++){
|
||||||
|
if (i>=1) {
|
||||||
|
if (isalnum(msg[i]))key[i-1]=msg[i];
|
||||||
|
else key[i-1]='_';
|
||||||
|
}
|
||||||
|
key[i]=0;
|
||||||
|
}
|
||||||
key[5] = 0;
|
key[5] = 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (key[0] == 0) return;
|
||||||
if (out){
|
if (out){
|
||||||
countOut->add(key);
|
countOut->add(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class GwSerialStream: public Stream{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GwSerial::GwSerial(GwLog *logger, Stream *s, int id,bool allowRead):serial(s)
|
GwSerial::GwSerial(GwLog *logger, HardwareSerial *s, int id,bool allowRead):serial(s)
|
||||||
{
|
{
|
||||||
LOG_DEBUG(GwLog::DEBUG,"creating GwSerial %p id %d",this,id);
|
LOG_DEBUG(GwLog::DEBUG,"creating GwSerial %p id %d",this,id);
|
||||||
this->id=id;
|
this->id=id;
|
||||||
|
@ -54,6 +54,10 @@ GwSerial::GwSerial(GwLog *logger, Stream *s, int id,bool allowRead):serial(s)
|
||||||
this->readBuffer=new GwBuffer(logger, GwBuffer::RX_BUFFER_SIZE,bufName+"rd");
|
this->readBuffer=new GwBuffer(logger, GwBuffer::RX_BUFFER_SIZE,bufName+"rd");
|
||||||
}
|
}
|
||||||
buffer->reset("init");
|
buffer->reset("init");
|
||||||
|
serial->onReceiveError([this](hardwareSerial_error_t err){
|
||||||
|
GwLog *logger=this->logger;
|
||||||
|
LOG_DEBUG(GwLog::ERROR,"serial error on id %d: %d",this->id,(int)err);
|
||||||
|
});
|
||||||
initialized=true;
|
initialized=true;
|
||||||
}
|
}
|
||||||
GwSerial::~GwSerial()
|
GwSerial::~GwSerial()
|
||||||
|
|
|
@ -16,10 +16,10 @@ class GwSerial : public GwChannelInterface{
|
||||||
int id=-1;
|
int id=-1;
|
||||||
int overflows=0;
|
int overflows=0;
|
||||||
size_t enqueue(const uint8_t *data, size_t len,bool partial=false);
|
size_t enqueue(const uint8_t *data, size_t len,bool partial=false);
|
||||||
Stream *serial;
|
HardwareSerial *serial;
|
||||||
public:
|
public:
|
||||||
static const int bufferSize=200;
|
static const int bufferSize=200;
|
||||||
GwSerial(GwLog *logger,Stream *stream,int id,bool allowRead=true);
|
GwSerial(GwLog *logger,HardwareSerial *stream,int id,bool allowRead=true);
|
||||||
~GwSerial();
|
~GwSerial();
|
||||||
bool isInitialized();
|
bool isInitialized();
|
||||||
virtual size_t sendToClients(const char *buf,int sourceId,bool partial=false);
|
virtual size_t sendToClients(const char *buf,int sourceId,bool partial=false);
|
||||||
|
|
|
@ -346,11 +346,15 @@ function createCounterDisplay(parent,label,key,isEven){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function validKey(key){
|
||||||
|
if (! key) return;
|
||||||
|
return key.replace(/[^a-z_:A-Z0-9-]/g,'');
|
||||||
|
}
|
||||||
function updateMsgDetails(key, details) {
|
function updateMsgDetails(key, details) {
|
||||||
forEl('.msgDetails', function (frame) {
|
forEl('.msgDetails', function (frame) {
|
||||||
if (frame.getAttribute('id') !== key) return;
|
if (frame.getAttribute('id') !== key) return;
|
||||||
for (let k in details) {
|
for (let k in details) {
|
||||||
|
k=validKey(k);
|
||||||
let el = frame.querySelector("[data-id=\"" + k + "\"] ");
|
let el = frame.querySelector("[data-id=\"" + k + "\"] ");
|
||||||
if (!el) {
|
if (!el) {
|
||||||
el = addEl('div', 'row', frame);
|
el = addEl('div', 'row', frame);
|
||||||
|
|
Loading…
Reference in New Issue