Skip to content

Commit

Permalink
Matches command with response first line
Browse files Browse the repository at this point in the history
  • Loading branch information
jLynx committed Jan 27, 2024
1 parent 2b4d6e2 commit 671795b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/SerialProvider/SerialProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,16 @@ const useWebSerial = ({
);

if (lastCommandIndex) {
lastCommandIndex.response = completeString;
lastProcessedCommand = lastProcessedCommand + 1;
if (completeString.startsWith(lastCommandIndex.command)) {
lastCommandIndex.response = completeString;
lastProcessedCommand = lastProcessedCommand + 1;
} else {
console.log(
"Command does not match the response, skipping",
lastCommandIndex.command,
lastCommandIndex.response
);
}
}
completeString = "";
isIncomingMessage.current = false;
Expand Down Expand Up @@ -422,6 +430,10 @@ const useWebSerial = ({
return id;
};

// useEffect(() => {
// console.log(commandResponseMap.current);
// }, [commandResponseMap.current]);

const queueWriteAndResponse = async (message: string) => {
const id = commandCounter.current++;
message = message + "\r";
Expand Down

0 comments on commit 671795b

Please sign in to comment.