Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware flow control not working on Mac in 9.0.7 #2232

Closed
ChristiaanWillemsen opened this issue Mar 24, 2021 · 1 comment
Closed

Hardware flow control not working on Mac in 9.0.7 #2232

ChristiaanWillemsen opened this issue Mar 24, 2021 · 1 comment
Labels
macOS Mac OS X / OS X stale-issue

Comments

@ChristiaanWillemsen
Copy link

ChristiaanWillemsen commented Mar 24, 2021

Summary of Problem

(Please answer all 3)

  • What are you trying to do?

Open and use a port using rtscts: true

  • What happens?

It opens the port, writing data does not seem to work, even when calling drain, the drain event is never called

  • What should have happened?

It should've worked ;) Any terminal works just fine (Coolterm for instance)

Code to Reproduce the Issue

export class Modem {
  portName: String;
  port: SerialPort;
  parser: any;
  acceptOpen: () => void | null = null;
  constructor(portName: string) {
    this.portName = portName;
    logger.info(`Starting port ${this.portName}..`);
    this.port = new SerialPort(portName, {
      baudRate: 115200,
      rtscts: true
    }, (err) => {
      this.port.set({ cts: true })
    });
    
  
    this.port.on("data", (buffer:Buffer) => {
      logger.info(`Serial data ${buffer.toString()}`)
    })
    this.port.on("error", (err) => {
      logger.info(`Serial err ${err}`)
    })
    this.port.on("drain", () => {
      logger.info(`Serial drained`)
    })
    this.port.on("open", () => {
      logger.info("Port opened");
      this.port.flush();
      if (this.acceptOpen!=null) {
        this.acceptOpen();
      }
    });
    
    /*this.parser = this.port.pipe(new Readline({ delimiter: '\r\n' }));
    this.parser.on("data", (line) => {
      logger.info("Serial data: " + line);
    });*/
  }

  async open(): Promise<void>{
    logger.info(`Opening port ${this.portName}`)
    if (this.port.isOpen) {
      Promise.resolve();
    } else {
      return new Promise((accept, reject) => {
        this.port.open(() => {});
        this.acceptOpen = accept;
      })
    }
  }

  isOpen(): boolean {
    return this.port.isOpen;
  }

  async doCommand(command: string): Promise<string> {
    logger.info(`Execute moden command [${command}]`)
    return new Promise<string>((accept, reject) => {
      this.port.write(command+"\r\n" ,"ascii");
      this.port.drain((err) => {
        if (err) {
          logger.error("Error writing data" + err);
          reject(err);
        }
      });
      accept("OK");
    })
  }

  static listPorts(): Promise<string[]>{
    return SerialPort.list().then((ports) => ports.map(p => p.path));
  }

}

const modem = new Modem("/dev/tty.usbserial-xxxx");

(async () => {
  await modem.open();
  const res = await modem.doCommand("AT");
  logger.info(res);
  // function body
})()

The "data" event is never called, nor the "drain"

Versions, Operating System and Hardware

  • SerialPort@? 9.0.7 and 8.0.8
  • Node.js v? v14.15.4, v10.15.3
  • MacOS 11.2.1
  • Hardware and chipset? (Prolific/FTDI/Other) "Silicon Laboratories, Inc. CP2102N USB to UART Bridge Controller"
@GazHank GazHank added the macOS Mac OS X / OS X label Jul 5, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week no further activity occurs. Feel free continue the discussion or ask for a never-stale label to keep it open. If this is a support issue, consider sharing it on stack overflow to get more eyes on your problem.

@stale stale bot added the stale-issue label Apr 16, 2022
@stale stale bot closed this as completed Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS Mac OS X / OS X stale-issue
Development

No branches or pull requests

2 participants