Skip to content

Commit

Permalink
Improved read() and write() behavior
Browse files Browse the repository at this point in the history
Re-read head and tail of RTT buffers on every call to read() or write(), to avoid issues when target restarts and resets RTT buffers' state between calls.
  • Loading branch information
ccattuto authored and thegecko committed Jul 19, 2022
1 parent 3269ed1 commit 1ae30bc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/rtt/rtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class RTT {
async read (bufId) {
var buf = this.bufUp[bufId];

buf.RdOff = await this.processor.readMem32(buf.bufAddr + 16);
buf.WrOff = await this.processor.readMem32(buf.bufAddr + 12);

if (buf.WrOff > buf.RdOff) {
Expand All @@ -136,6 +137,7 @@ class RTT {
var buf = this.bufDown[bufId];

buf.RdOff = await this.processor.readMem32(buf.bufAddr + 16);
buf.WrOff = await this.processor.readMem32(buf.bufAddr + 12);

if (buf.WrOff >= buf.RdOff)
var num_avail = buf.SizeOfBuffer - (buf.WrOff - buf.RdOff);
Expand Down

0 comments on commit 1ae30bc

Please sign in to comment.