當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。