- 30 Aug 2024
- 1 読む分
- 印刷する
COM Ports
- 更新日 30 Aug 2024
- 1 読む分
- 印刷する
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:
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.