njs-modbus
Version:
A pure JavaScript implemetation of Modbus for NodeJS.
27 lines (26 loc) • 1.18 kB
TypeScript
import type { ApplicationDataUnit } from '../../types';
import type { TcpClientPhysicalLayer, TcpServerPhysicalLayer, UdpPhysicalLayer } from '../physical';
import type { SerialPhysicalLayer } from '../physical';
import { AbstractApplicationLayer } from './abstract-application-layer';
export declare class RtuApplicationLayer extends AbstractApplicationLayer {
private _waitingResponse?;
private _timerThreePointFive?;
private _bufferRx;
private _removeAllListeners;
constructor(physicalLayer: SerialPhysicalLayer | TcpServerPhysicalLayer | TcpClientPhysicalLayer | UdpPhysicalLayer,
/**
* The time interval between two frames, support two formats:
* - bit: `48bit` as default
* - millisecond: `20ms`
*/
intervalBetweenFrames?: `${number}bit` | `${number}ms`);
private framing;
startWaitingResponse(preCheck: ((frame: ApplicationDataUnit & {
buffer: Buffer;
}) => boolean | number | undefined)[], callback: (error: Error | null, frame?: ApplicationDataUnit & {
buffer: Buffer;
}) => void): void;
stopWaitingResponse(): void;
encode(data: ApplicationDataUnit): Buffer;
destroy(): void;
}