mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 11:02:11 +08:00
Add more definitions based on documentation.
This commit is contained in:
@@ -8,8 +8,31 @@
|
||||
|
||||
import * as serialport from 'serialport';
|
||||
|
||||
this.port = new serialport.SerialPort("", {
|
||||
baudrate: 0,
|
||||
disconnectedCallback: function () { },
|
||||
parser: serialport.parsers.readline("\n")
|
||||
});
|
||||
function test_basic_connect() {
|
||||
let port = new serialport.SerialPort("");
|
||||
}
|
||||
|
||||
function test_connect_config() {
|
||||
let port = new serialport.SerialPort("", {
|
||||
baudrate: 0,
|
||||
disconnectedCallback: function () { },
|
||||
parser: serialport.parsers.readline("\n")
|
||||
});
|
||||
}
|
||||
|
||||
function test_write() {
|
||||
let port = new serialport.SerialPort("");
|
||||
port.write('main screen turn on', (err, bytesWritten) => {
|
||||
});
|
||||
}
|
||||
|
||||
function test_events() {
|
||||
let port = new serialport.SerialPort("");
|
||||
port.on('open', function () { });
|
||||
}
|
||||
|
||||
function test_list_ports() {
|
||||
serialport.list( (err:string, ports:serialport.portConfig[]) => {
|
||||
|
||||
});
|
||||
}
|
||||
20
serialport/serialport.d.ts
vendored
20
serialport/serialport.d.ts
vendored
@@ -1,19 +1,20 @@
|
||||
// Type definitions for serialport
|
||||
// Project: https://github.com/EmergingTechnologyAdvisors/node-serialport
|
||||
// Definitions by: Jeremy Foster <https://github.com/codefoster>
|
||||
// Definitions by: Jeremy Foster <https://github.com/codefoster>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'serialport' {
|
||||
module parsers {
|
||||
function readline(delimiter: string):void;
|
||||
function raw(emitter:any, buffer:string):void
|
||||
}
|
||||
|
||||
export class SerialPort {
|
||||
constructor(path: string, options?: Object, openImmediately?: boolean, callback?: () => {})
|
||||
constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err:string) => void)
|
||||
isOpen: boolean;
|
||||
on(event: string, callback?: (data?:any) => void):void;
|
||||
open(callback?: () => void):void;
|
||||
write(buffer: any, callback?: () => void):void
|
||||
write(buffer: any, callback?: (err:string, bytesWritten:number) => void):void
|
||||
pause():void;
|
||||
resume():void;
|
||||
disconnected(err: Error):void;
|
||||
@@ -22,7 +23,18 @@ declare module 'serialport' {
|
||||
set(options: setOptions, callback: () => void):void;
|
||||
drain(callback?: () => void):void;
|
||||
update(options: updateOptions, callback?: () => void):void;
|
||||
list(callback?: () => void):void;
|
||||
}
|
||||
|
||||
export function list(callback: (err: string, ports:portConfig[]) => void): void;
|
||||
|
||||
interface portConfig {
|
||||
comName: string,
|
||||
manufacturer: string,
|
||||
serialNumber: string,
|
||||
pnpId: string,
|
||||
locationId: string,
|
||||
vendorId: string,
|
||||
productId: string
|
||||
}
|
||||
|
||||
interface setOptions {
|
||||
|
||||
Reference in New Issue
Block a user