Skip to content

Commit

Permalink
don't emit data events if there was no new data
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Oct 2, 2024
1 parent cc9af9c commit 9810a95
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions uart.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,15 @@ To do:
this.rxDataHandlerLastCh = ch;
}
}
// keep track of received data
if (this.received.length < 100000) // ensure we're not creating a memory leak
this.received += data;
this.hadData = true;
// forward any data
if (this.cb) this.cb(data);
this.emit('data', data);
if (data.length>0) {
// keep track of received data
if (this.received.length < 100000) // ensure we're not creating a memory leak
this.received += data;
this.hadData = true;
// forward any data
if (this.cb) this.cb(data);
this.emit('data', data);
}
}

/* Send a packet of type "RESPONSE/EVAL/EVENT/FILE_SEND/DATA" to Espruino
Expand Down

0 comments on commit 9810a95

Please sign in to comment.