當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript SerialPort.SerialPort類代碼示例

本文整理匯總了TypeScript中SerialPort.SerialPort的典型用法代碼示例。如果您正苦於以下問題:TypeScript SerialPort類的具體用法?TypeScript SerialPort怎麽用?TypeScript SerialPort使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SerialPort類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: SerialPort

        let run = (self: SerialPortRelay, resolve, reject) => {
            this._handle = new SerialPort(port, {}, false);
            this._handle.on('open', () => {
                resolve(self);
                super.connect(port);
            });

            this._handle.on('close', () => {
                super.disconnect(port);
            });

            this._handle.on('error', (error) => {
                super.error(error, port);
            });

            this._handle.on('data', (data) => {
                super.data(data, data.length, port);
            });

            try {
                this._handle.open();
            } catch (error) {
                reject(error);
            }
        };
開發者ID:adamarvid,項目名稱:hcp,代碼行數:25,代碼來源:stream-relay.ts

示例2: function

 	serialport.list(function (err, ports) {
    	ports.forEach(function(port) {
        	ports += port.comName + "\n";
        	console.log(port.comName);
     		if(port.comName === params[2])
    		{
        		currentPort = port;
      		}
   	 });
	console.log("Port " + currentPort.comName + " selected");
    var activeSerialPort = new serialport.SerialPort(currentPort.comName, {
        baudrate: 9600
    });
    activeSerialPort.on("open", function () {
      var comInServer = new ComInServer();
	  comInServer.setSerialPort(activeSerialPort);
	  comInServer.setCallback(function (data) {
		  console.log(data.toString());
		  currentLog += data.toString();
	  });
    });
  });
開發者ID:dwd31415,項目名稱:NodeArduinoComServer,代碼行數:22,代碼來源:server-main.ts

示例3: test_events

function test_events() {
    let port = new serialport.SerialPort("");
    port.on('open', function () { });
}
開發者ID:1drop,項目名稱:DefinitelyTyped,代碼行數:4,代碼來源:serialport-tests.ts

示例4: test_write

function test_write() {
    let port = new serialport.SerialPort("");
    port.write('main screen turn on', (err, bytesWritten) => {
    });
}
開發者ID:1drop,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:serialport-tests.ts

示例5: Serial

    ports.forEach((port) => {
        var serial = new Serial(port.comName, {}, false);

        serial.open((err) => {
            if (err) return console.dir(err);

            console.log('serial port opened');
            console.dir(port);

            serial.on('data', onData);
        });

        serials.push(serial);
    });
開發者ID:tae-jun,項目名稱:slms,代碼行數:14,代碼來源:serial.ts

示例6:

        serial.open((err) => {
            if (err) return console.dir(err);

            console.log('serial port opened');
            console.dir(port);

            serial.on('data', onData);
        });
開發者ID:tae-jun,項目名稱:slms,代碼行數:8,代碼來源:serial.ts

示例7: function

    serialPort.open(function (error)
    {
        if (error)
        {
            console.log('failed to open: ' + error);
        }
        else
        {
            console.log('open');
            serialPort.on('data', function (data)
            {
                console.log("Received: %s", dumpHex(data));
                console.log("recieved:  " + dumpHex(data));
            });
            buffer = [0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
            serialPort.write(buffer, function (err, results)
            {
                console.log("Sent    : %s", dumpHex(buffer));
                rfxtrx.delay(500);
                serialPort.flush(function ()
                {
                    buffer = [0x0D, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
                    serialPort.write(buffer, function (err, results)
                    {
                        console.log("Sent    : %s", dumpHex(buffer));
                    }
                        );



                    console.log('err ' + err);
                    console.log('results ' + results);

                    var jil = 5;
                });
            })
        }


    } );
開發者ID:nattlip,項目名稱:nodejswebapp1,代碼行數:40,代碼來源:jillesrfxcom.ts

示例8: write

 public write(request : TifRequest): void {
     this._handle.write(Buffer.from(request.data, 0, request.size));
 }
開發者ID:adamarvid,項目名稱:hcp,代碼行數:3,代碼來源:stream-relay.ts


注:本文中的SerialPort.SerialPort類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。