declare namespace ModbusRTU { interface IModbusRTU { new(port?: any): IModbusRTU; open(callback: Function): void; close(callback: Function): void; writeFC1(address: number, dataAddress: number, length: number, next: NodeStyleCallback): void; writeFC2(address: number, dataAddress: number, length: number, next: NodeStyleCallback): void; writeFC3(address: number, dataAddress: number, length: number, next: NodeStyleCallback): void; writeFC4(address: number, dataAddress: number, length: number, next: NodeStyleCallback): void; writeFC5(address: number, dataAddress: number, state: boolean, next: NodeStyleCallback): void; writeFC6(address: number, dataAddress: number, value: number, next: NodeStyleCallback): void; writeFC15(address: number, dataAddress: number, states: Array, next: NodeStyleCallback): void; writeFC16(address: number, dataAddress: number, values: Array, next: NodeStyleCallback): void; // Connection shorthand API connectRTU(path: string, options: SerialPortOptions, next: Function): Promise; connectTCP(ip: string, options: TcpPortOptions, next: Function): Promise; connectTcpDirectRTUBuffer(ip: string, options: TcpDirectRTUBufferPortOptions, next: Function): Promise; connectTcpRTUBuffered(ip: string, options: TcpRTUPortOptions, next: Function): Promise; connectTelnet(ip: string, options: TelnetPortOptions, next: Function): Promise; connectC701(ip: string, options: C701PortOptions, next: Function): Promise; connectRTUBuffered(path: string, options: SerialPortOptions, next: Function): Promise; connectAsciiSerial(path: string, options: SerialPortOptions, next: Function): Promise; // Promise API setID(id: number): void; getID(): number; setTimeout(duration: number): void; getTimeout(): number; readCoils(dataAddress: number, length: number): Promise; readDiscreteInputs(dataAddress: number, length: number): Promise; readHoldingRegisters(dataAddress: number, length: number): Promise; readInputRegisters(dataAddress: number, length: number): Promise; writeCoil(dataAddress: number, state: boolean): Promise; writeCoils(dataAddress: number, states: Array): Promise; writeRegister(dataAddress: number, value: number): Promise; writeRegisters(dataAddress: number, values: Array): Promise; // 16 } interface NodeStyleCallback { (err: NodeJS.ErrnoException, param: T): void; } interface ReadCoilResult { data: Array; buffer: Buffer; } interface ReadRegisterResult { data: Array; buffer: Buffer; } interface WriteCoilResult { address: number; state: boolean; } interface WriteRegisterResult { address: number; value: number; } interface WriteMultipleResult { address: number; length: number; } interface SerialPortOptions { baudRate?: number; dataBits?: number; stopBits?: number; parity?: 'none' | 'even' | 'mark' | 'odd' | 'space'; rtscts?: boolean; xon?: boolean; xoff?: boolean; xany?: boolean; flowControl?: boolean | Array; bufferSize?: number; parser?: any; platformOptions?: SerialPortUnixPlatformOptions; } interface SerialPortUnixPlatformOptions { vmin?: number; vtime?: number; } interface TcpPortOptions { port?: number; } interface TcpDirectRTUBufferPortOptions { port?: number; } interface TcpRTUPortOptions { port?: number; } interface TelnetPortOptions { port?: number; } interface C701PortOptions { port?: number; } } declare var ModbusRTU: ModbusRTU.IModbusRTU; export = ModbusRTU ;