Skip to content

how to access "recording" when using MockBinding #2581

Answered by TomzBench
TomzBench asked this question in Q&A
Discussion options

You must be logged in to vote

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);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TomzBench
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant