Menu

绑定


id: api-bindings
title: Bindings

The Binding is how Node-SerialPort talks to the underlying system. By default, we auto-detect Windows, Linux and OS X, and load the appropriate module for your system. You can assign SerialPort.Binding to any binding you like. Find more bindings by searching "serialport-binding" at npm.

You can prevent auto-loading of the default bindings by requiring the SerialPort Stream package.

  var SerialPort = require('@serialport/stream');
  SerialPort.Binding = MyBindingClass;

You never have to use Binding objects directly. @serialPort/stream uses them to access the underlying hardware. This documentation is geared towards people who are making bindings for different platforms. The AbstractBinding class from the @serialport/binding-abstract package can be inherited to get the base API.

There is also a MockBinding package to assist with testing.

To see the binding api take a look at @serialport/binding-abstract.

上一篇 下一篇
讨论数量: 0

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
刻意练习,每日精进。
~
点赞
223
浏览
0
讨论