Skip to content

Commit

Permalink
don't resolve immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Nov 28, 2024
1 parent 8c1ab7a commit eb1a20c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions uart.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,11 @@ To do:
}
function onACK(ok) {
tidy();
resolve();
setTimeout(resolve,0);
}
function onNAK(ok) {
tidy();
reject();
setTimeout(reject,0);
}
if (!options.noACK) {
connection.parsePackets = true;
Expand All @@ -501,7 +501,7 @@ To do:
connection.write(String.fromCharCode(/*DLE*/16,/*SOH*/1,(flags>>8)&0xFF,flags&0xFF)+data, function() {
// write complete
if (options.noACK) {
resolve(); // if not listening for acks, just resolve immediately
setTimeout(resolve,0); // if not listening for acks, just resolve immediately
}
}, err => {
tidy();
Expand Down Expand Up @@ -582,7 +582,7 @@ To do:
if (type!=0x8000) return; // ignore things that are not DATA packet
if (data.length==0) { // 0 length packet = EOF
cleanup();
resolve(fileContents);
setTimeout(resolve,0,fileContents);
} else {
fileContents += data;
scheduleTimeout();
Expand Down Expand Up @@ -625,7 +625,7 @@ To do:
function onPacket(type,data) {
if (type!=0) return; // ignore things that are not a response
cleanup();
resolve(parseRJSON(data));
setTimeout(resolve,0,parseRJSON(data));
}
connection.parsePackets = true;
connection.on("packet", onPacket);
Expand Down

0 comments on commit eb1a20c

Please sign in to comment.