Commit c3743160 authored by Guillaume Slizewicz's avatar Guillaume Slizewicz

last changes

parent aa3f251f
No preview for this file type
No preview for this file type
../detect-libc/bin/detect-libc.js
\ No newline at end of file
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.4](https://github.com/node-serialport/node-serialport/compare/@serialport/binding-abstract@2.0.3...@serialport/binding-abstract@2.0.4) (2019-01-08)
**Note:** Version bump only for package @serialport/binding-abstract
## [2.0.3](https://github.com/node-serialport/node-serialport/compare/@serialport/binding-abstract@2.0.2...@serialport/binding-abstract@2.0.3) (2018-12-19)
**Note:** Version bump only for package @serialport/binding-abstract
## [2.0.2](https://github.com/node-serialport/node-serialport/compare/@serialport/binding-abstract@2.0.1...@serialport/binding-abstract@2.0.2) (2018-11-27)
**Note:** Version bump only for package @serialport/binding-abstract
<a name="2.0.1"></a>
## [2.0.1](https://github.com/node-serialport/node-serialport/compare/@serialport/binding-abstract@2.0.0...@serialport/binding-abstract@2.0.1) (2018-08-29)
**Note:** Version bump only for package @serialport/binding-abstract
<a name="2.0.0"></a>
# 2.0.0 (2018-08-26)
**Note:** Version bump only for package @serialport/binding-abstract
The MIT License (MIT)
Copyright 2010 Christopher Williams. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
# @serialport/BindingAbstract
This Abstract binding class is the base for all serialport bindings. You wouldn't use this class directly but instead extend it to make a new binding for a different platform or underling technology.
This is currently used for the win32, linux, darwin and mock bindings.
This is how you use it.
```js
class MockBinding extends AbstractBinding {
constructor(opt) {
super(opt)
}
}
```
const debug = require('debug')('serialport/binding-abstract')
/**
* @name Binding
* @type {AbstractBinding}
* @since 5.0.0
* @description 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 by searching at [npm](https://npmjs.org/).
Prevent auto loading the default bindings by requiring SerialPort with:
```js
var SerialPort = require('@serialport/stream');
SerialPort.Binding = MyBindingClass;
```
*/
/**
* You never have to use `Binding` objects directly. SerialPort uses them to access the underlying hardware. This documentation is geared towards people who are making bindings for different platforms. This class can be inherited from to get type checking for each method.
* @class AbstractBinding
* @param {object} options options for the binding
* @property {boolean} isOpen Required property. `true` if the port is open, `false` otherwise. Should be read-only.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
* @since 5.0.0
*/
class AbstractBinding {
/**
* Retrieves a list of available serial ports with metadata. The `comName` must be guaranteed, and all other fields should be undefined if unavailable. The `comName` is either the path or an identifier (eg `COM1`) used to open the serialport.
* @returns {Promise} resolves to an array of port [info objects](#module_serialport--SerialPort.list).
*/
static list() {
debug('list')
return Promise.resolve()
}
constructor(opt) {
if (typeof opt !== 'object') {
throw new TypeError('"options" is not an object')
}
}
/**
* Opens a connection to the serial port referenced by the path.
* @param {string} path the path or com port to open
* @param {openOptions} options openOptions for the serialport
* @returns {Promise} Resolves after the port is opened and configured.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
open(path, options) {
if (!path) {
throw new TypeError('"path" is not a valid port')
}
if (typeof options !== 'object') {
throw new TypeError('"options" is not an object')
}
debug('open')
if (this.isOpen) {
return Promise.reject(new Error('Already open'))
}
return Promise.resolve()
}
/**
* Closes an open connection
* @returns {Promise} Resolves once the connection is closed.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
close() {
debug('close')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Request a number of bytes from the SerialPort. This function is similar to Node's [`fs.read`](http://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback) except it will always return at least one byte.
The in progress reads must error when the port is closed with an error object that has the property `canceled` equal to `true`. Any other error will cause a disconnection.
* @param {buffer} buffer Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object.
* @param {integer} offset The offset in the buffer to start writing at.
* @param {integer} length Specifies the maximum number of bytes to read.
* @returns {Promise} Resolves with the number of bytes read after a read operation.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
read(buffer, offset, length) {
if (!Buffer.isBuffer(buffer)) {
throw new TypeError('"buffer" is not a Buffer')
}
if (typeof offset !== 'number') {
throw new TypeError('"offset" is not an integer')
}
if (typeof length !== 'number') {
throw new TypeError('"length" is not an integer')
}
debug('read')
if (buffer.length < offset + length) {
return Promise.reject(new Error('buffer is too small'))
}
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Write bytes to the SerialPort. Only called when there is no pending write operation.
The in progress writes must error when the port is closed with an error object that has the property `canceled` equal to `true`. Any other error will cause a disconnection.
* @param {buffer} buffer - Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object.
* @returns {Promise} Resolves after the data is passed to the operating system for writing.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
write(buffer) {
if (!Buffer.isBuffer(buffer)) {
throw new TypeError('"buffer" is not a Buffer')
}
debug('write', buffer.length, 'bytes')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Changes connection settings on an open port. Only `baudRate` is supported.
* @param {object=} options Only supports `baudRate`.
* @param {number=} [options.baudRate] If provided a baud rate that the bindings do not support, it should reject.
* @returns {Promise} Resolves once the port's baud rate changes.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
update(options) {
if (typeof options !== 'object') {
throw TypeError('"options" is not an object')
}
if (typeof options.baudRate !== 'number') {
throw new TypeError('"options.baudRate" is not a number')
}
debug('update')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Set control flags on an open port.
* @param {object=} options All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. All options are always provided.
* @param {Boolean} [options.brk=false] flag for brk
* @param {Boolean} [options.cts=false] flag for cts
* @param {Boolean} [options.dsr=false] flag for dsr
* @param {Boolean} [options.dtr=true] flag for dtr
* @param {Boolean} [options.rts=true] flag for rts
* @returns {Promise} Resolves once the port's flags are set.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
set(options) {
if (typeof options !== 'object') {
throw new TypeError('"options" is not an object')
}
debug('set')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Get the control flags (CTS, DSR, DCD) on the open port.
* @returns {Promise} Resolves with the retrieved flags.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
get() {
debug('get')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Get the OS reported baud rate for the open port.
* Used mostly for debugging custom baud rates.
* @returns {Promise} Resolves with the current baud rate.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
getBaudRate() {
debug('getbaudRate')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Flush (discard) data received but not read, and written but not transmitted.
* @returns {Promise} Resolves once the flush operation finishes.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
flush() {
debug('flush')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
/**
* Drain waits until all output data is transmitted to the serial port. An in progress write should be completed before this returns.
* @returns {Promise} Resolves once the drain operation finishes.
* @throws {TypeError} When given invalid arguments, a `TypeError` is thrown.
*/
drain() {
debug('drain')
if (!this.isOpen) {
return Promise.reject(new Error('Port is not open'))
}
return Promise.resolve()
}
}
module.exports = AbstractBinding
{
"_from": "@serialport/binding-abstract@^2.0.4",
"_id": "@serialport/binding-abstract@2.0.4",
"_inBundle": false,
"_integrity": "sha512-0ZcSB6Gdxal55R/5McB0O359coXrO/GrmJlZ13cwN67gLsvmhmexCsd8b+H9CQ7dAbLih4HZSbfG9v8crrB0Gg==",
"_location": "/@serialport/binding-abstract",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@serialport/binding-abstract@^2.0.4",
"name": "@serialport/binding-abstract",
"escapedName"