本文整理匯總了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[]) => {});
}