当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SerialPort.list函数代码示例

本文整理汇总了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();
	  });
    });
  });
 
}
开发者ID:dwd31415,项目名称:NodeArduinoComServer,代码行数:27,代码来源:server-main.ts

示例2: setInterval

 setInterval(() => {
     serialport.list(function (err: any, ports: SerialPortInfo[]) {
         ports.filter(filterPort)
             .filter(info => !serialPorts[info.pnpId])
             .forEach((info) => open(info));
     });
 }, 5000);
开发者ID:kleopatra999,项目名称:pxt,代码行数:7,代码来源:server.ts

示例3: function

exports.ports = function (req, res) {
  serialPort.list(function (err, ports) {
    res.json({
      ports: _.map(ports, function(port) { return port.comName; })
    });
  });
};
开发者ID:chutungwnz,项目名称:gyro3d,代码行数:7,代码来源:api.ts

示例4: Promise

 return new Promise(function(fulfill, reject) {
     serialport.list((error: string, ports: serialport.portConfig[]) => {
         if (error != null) {
             reject(error);
         }
         else {
             fulfill(ports);
         }
     });            
 });
开发者ID:fduman,项目名称:vscode-nodemcu,代码行数:10,代码来源:ComPortAutoCompleteProvider.ts

示例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);
     }
 });
开发者ID:husqvarnagroup,项目名称:hcp,代码行数:13,代码来源:hcp-device.ts

示例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);
            }
        });
    }
开发者ID:fduman,项目名称:vscode-nodemcu,代码行数:21,代码来源:nodeMcuCommunication.ts

示例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);
            }
        });
    }
开发者ID:UmairB,项目名称:makeblock,代码行数:21,代码来源:Serialport.ts

示例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);
                      });
                  }
开发者ID:nattlip,项目名称:nodejswebapp1,代码行数:22,代码来源:Hueserver.ts

示例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);


            });
          
        });
     
       
    };
开发者ID:nattlip,项目名称:nodejswebapp1,代码行数:22,代码来源:jillesrfxcom.ts

示例10: test_list_ports

function test_list_ports() {
    SerialPort.list((err: string, ports: SerialPort.portConfig[]) => {});
}
开发者ID:enlight,项目名称:DefinitelyTyped,代码行数:3,代码来源:serialport-tests.ts


注:本文中的SerialPort.list函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。