<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          node-serialportNode.js 串口讀寫包

          聯(lián)合創(chuàng)作 · 2023-09-23 17:01

          node-serialport 是一個 Node.js 的包,用來對串口數(shù)據(jù)進(jìn)行讀寫操作。

          基本示例代碼:

          var SerialPort = require("serialport").SerialPort
          var serialPort = new SerialPort("/dev/tty-usbserial1", {
            baudrate: 57600
          }, false); // this is the openImmediately flag [default is true]
          
          serialPort.open(function (error) {
            if ( error ) {
              console.log('failed to open: '+error);
            } else {
              console.log('open');
              serialPort.on('data', function(data) {
                console.log('data received: ' + data);
              });
              serialPort.write("ls\n", function(err, results) {
                console.log('err ' + err);
                console.log('results ' + results);
              });
            }
          });

          羅列所有串口:

          var serialPort = require("serialport");
          serialPort.list(function (err, ports) {
            ports.forEach(function(port) {
              console.log(port.comName);
              console.log(port.pnpId);
              console.log(port.manufacturer);
            });
          });

          串口配置:

          • baudRate

          • dataBits

          • stopBits

          • parity

          • rtscts

          • xon

          • xoff

          • xany

          • flowControl

          • bufferSize

          • parser

          • encoding

          • dataCallback

          • disconnectedCallback

          • platformOptions - sets platform specific options, see below.

          目前已有很多項目在使用這個包進(jìn)行串口處理:

          • Johnny-Five - Firmata based Arduino Framework.

          • Cylon.js - JavaScript Robotics, By Your Command.

          • node-l8smartlight (source) A node library to control the L8 Smartlight via Bluetooth or USB port

          • firmata Talk natively to Arduino using the firmata protocol.

          • tmpad source - a DIY midi pad using infrared, arduino, and nodejs. Video

          • duino - A higher level framework for working with Arduinos in node.js.

          • Arduino Drinking Game Extravaganza - AKA "The Russian" a hexidecimal drinking game for geeks by Uxebu presented at JSConf EU 2011.

          • Arduino controlling popcorn.js - Controlling a popcorn.js video with an Arduino kit.

          • Robotic JavaScript - The first live presentation of the node-serialport code set as presented at JSConf EU 2010.

          • devicestack - This module helps you to represent a device and its protocol.

          • reflecta A communication protocol that combines Arduino Libraries and NodeJS into an integrated system.

          • rc4pt-node - Control Popcorntime with an Infrared receiver and Arduino.

          瀏覽 21
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚洲婷婷网 | 爆肏女主播 | 美女操逼逼 | 一区二区三区四区精品视频 | aaa国产精品 |