-
I'm writting to a serial port and i would like to read it back via the I am having trouble finding the Am I missing something? import { MockBinding, MockBindingInterface } from "@serialport/binding-mock";
import { SerialPortStream } from "@serialport/stream";
describe("stream", () => {
it("should write cbor", () => {
MockBinding.createPort("/dev/MOCK", {
echo: false,
record: true,
});
let port = new SerialPortStream<MockBindingInterface>({
binding: MockBinding,
path: "/dev/MOCK",
baudRate: 115200,
});
port.write("hello");
port.end();
console.log(port.binding.recording); // <-- error not found here..
});
}); |
Beta Was this translation helpful? Give feedback.
Answered by
TomzBench
Dec 19, 2022
Replies: 1 comment
-
have to wait for port to open... IE below: import { MockBinding, MockBindingInterface } from "@serialport/binding-mock";
import { SerialPortStream } from "@serialport/stream";
describe("stream", () => {
it("should write cbor", async () => {
MockBinding.createPort("/dev/MOCK", {
echo: false,
record: true,
});
let port = new SerialPortStream<MockBindingInterface>({
binding: MockBinding,
path: "/dev/MOCK",
baudRate: 115200,
});
await new Promise((resolve) => port.on("open", resolve));
await new Promise((resolve) => port.write("hello", resolve));
await new Promise((resolve) => port.end(resolve));
console.log(port.port.recording);
});
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
TomzBench
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
have to wait for port to open... IE below: