COM Ports
  • 30 Aug 2024
  • 1 読む分

COM Ports


The content is currently unavailable in Ja - 日本語. You are viewing the default English version.
記事の要約

The TemplateFramework supports platform-independent serial-communication through the same API.

Currently Linux and Windows are supported.

The API has a single method in TemplateController, connectToSerial(). This accepts a COMOptions object:

export interface COMPortOptions {
  port: number | string;
  baudSpeed: number;
  byteSize: number;
  parity: number;
  stopBits: number;
  minSendInterval?: number; // ms between send commands. Optional.
}

connectToSerial() returns a ICOMConnector object:

interface ICOMConnector {
  portId: number;

  onData?: (data: any) => void;
  onClose?: () => void;
  send(data: string): Promise<void>;
  close(): void;
}

Behavior on different platforms may vary. For example, onClose may not always be called until the next attempted send(). Whether calls to close() will in turn call back onClose is undefined.

Currently text payloads are supported.

Example:

See the ‘Nexmosphere XY240-241’ sample project.

Developing a COM-dependent Template using PlayerSimulator

A NodeJS-project is available that exposes COM-traffic to and from a WebSocket-server. The PlayerSimulator supports this on ‘ws://localhost:7501’.

This module is available here - https://bitbucket.org/diseinc/com2ws.

If real-hardware is unavailable to test on the COM0COM driver can be used to emulate a "Null modem cable" in combination with COM2WS.

The signed COM0COM can be found here - https://code.google.com/archive/p/powersdr-iq/downloads.


この記事は役に立ちましたか?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.