本文整理汇总了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;未经允许,请勿转载。 |
请发表评论