本文整理汇总了TypeScript中SerialPort.list函数的典型用法代码示例。如果您正苦于以下问题:TypeScript list函数的具体用法?TypeScript list怎么用?TypeScript list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了list函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: main
function main(params:string[]) {
var currentPort : any = undefined;
console.log("Available ports:")
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();
});
});
});
}
示例2: setInterval
setInterval(() => {
serialport.list(function (err: any, ports: SerialPortInfo[]) {
ports.filter(filterPort)
.filter(info => !serialPorts[info.pnpId])
.forEach((info) => open(info));
});
}, 5000);
示例3: function
exports.ports = function (req, res) {
serialPort.list(function (err, ports) {
res.json({
ports: _.map(ports, function(port) { return port.comName; })
});
});
};
示例4: Promise
return new Promise(function(fulfill, reject) {
serialport.list((error: string, ports: serialport.portConfig[]) => {
if (error != null) {
reject(error);
}
else {
fulfill(ports);
}
});
});
示例5: reject
return new Promise<string[]>((resolve, reject) => {
try {
SerialPort.list((error, ports) => {
if (error) {
reject(error);
} else {
resolve(ports.map((port) => port.comName));
}
});
} catch (error) {
reject(error);
}
});
示例6: detectPort
/**
*
*/
public static detectPort(cfgPort: string, callback: (error: string, ports: PortInformation[]) => void): void {
serialport.list((error: string, ports: serialport.portConfig[]) => {
if (error != null) {
callback(error, null);
}
else {
let filteredPorts = ports.filter((port: serialport.portConfig) => {
if (cfgPort == null || cfgPort == "auto") {
return port.pnpId.includes("VID_1A86") || port.pnpId.includes("VID_10C4");
}
return (port.comName == cfgPort);
});
callback(error, filteredPorts);
}
});
}
示例7: list
public static list(callback: (err: string | null, ports: IPort[] | null) => void) {
list((err, portConfigs) => {
if (err) {
callback(err, null);
} else {
let ports = portConfigs.map(p => {
return {
comName: p.comName,
manufacturer: p.manufacturer,
serialNumber: p.serialNumber,
pnpId: p.pnpId,
locationId: p.locationId,
vendorId: p.vendorId,
productId: p.productId
};
});
callback(null, ports);
}
});
}
示例8: function
var a = function ()
{
serialPort.list(function (err, ports)
{
var portseffective = [];
ports.forEach(function (port)
{
if (port.pnpId !== "")
{
portseffective.push(port.comName);
}
});
scpjson = JSON.stringify(portseffective)
var jil = 5;
socketclient.emit("comports1", scpjson);
});
}
示例9: function
export var listserialports = function (err,ports)
{
var c;
serialPort.list(function (err, ports)
{
// serialcomarray = ports;
var jil = 5;
serialcomarray = ports;
c = ports;
ports.forEach(function (port)
{
console.log(port.comName);
console.log(port.pnpId);
console.log(port.manufacturer);
});
});
};
示例10: test_list_ports
function test_list_ports() {
SerialPort.list((err: string, ports: SerialPort.portConfig[]) => {});
}