@serialport/bindings
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.0.3](https://github.com/node-serialport/node-serialport/compare/@serialport/bindings@2.0.2...@serialport/bindings@2.0.3) (2018-11-27) | ||
### Bug Fixes | ||
* **packages/bindings#write:** do not call native binding for empty buffers ([d347f3b](https://github.com/node-serialport/node-serialport/commit/d347f3b)) | ||
<a name="2.0.2"></a> | ||
@@ -8,0 +19,0 @@ ## [2.0.2](https://github.com/node-serialport/node-serialport/compare/@serialport/bindings@2.0.1...@serialport/bindings@2.0.2) (2018-08-29) |
@@ -33,11 +33,3 @@ let platform | ||
const listFields = [ | ||
'comName', | ||
'manufacturer', | ||
'serialNumber', | ||
'pnpId', | ||
'locationId', | ||
'vendorId', | ||
'productId', | ||
] | ||
const listFields = ['comName', 'manufacturer', 'serialNumber', 'pnpId', 'locationId', 'vendorId', 'productId'] | ||
@@ -58,6 +50,3 @@ const bindingsToTest = ['mock', platform] | ||
bindingsToTest.forEach(bindingName => { | ||
const Binding = | ||
bindingName === 'mock' | ||
? require('@serialport/binding-mock') | ||
: require(`./${bindingName}`) | ||
const Binding = bindingName === 'mock' ? require('@serialport/binding-mock') : require(`./${bindingName}`) | ||
let testPort = process.env.TEST_PORT | ||
@@ -101,7 +90,3 @@ | ||
Object.keys(port).forEach(key => { | ||
assert.notEqual( | ||
port[key], | ||
'', | ||
'empty values should be undefined' | ||
) | ||
assert.notEqual(port[key], '', 'empty values should be undefined') | ||
assert.isNotNull(port[key], 'empty values should be undefined') | ||
@@ -136,5 +121,3 @@ }) | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -198,5 +181,3 @@ } | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -230,26 +211,18 @@ } | ||
}) | ||
testFeature( | ||
`baudrate.${testBaud}`, | ||
`opens at ${testBaud} baud`, | ||
() => { | ||
return binding.open(testPort, customRates).then(() => { | ||
assert.equal(binding.isOpen, true) | ||
testFeature(`baudrate.${testBaud}`, `opens at ${testBaud} baud`, () => { | ||
return binding.open(testPort, customRates).then(() => { | ||
assert.equal(binding.isOpen, true) | ||
return binding.close() | ||
}) | ||
}) | ||
testFeature(`baudrate.${testBaud}_check`, `sets ${testBaud} baud successfully`, () => { | ||
return binding | ||
.open(testPort, customRates) | ||
.then(() => binding.getBaudRate()) | ||
.then(res => { | ||
assert.equal(res.baudRate, customRates.baudRate) | ||
return binding.close() | ||
}) | ||
} | ||
) | ||
testFeature( | ||
`baudrate.${testBaud}_check`, | ||
`sets ${testBaud} baud successfully`, | ||
() => { | ||
return binding | ||
.open(testPort, customRates) | ||
.then(() => binding.getBaudRate()) | ||
.then(res => { | ||
assert.equal(res.baudRate, customRates.baudRate) | ||
return binding.close() | ||
}) | ||
} | ||
) | ||
}) | ||
}) | ||
@@ -269,9 +242,7 @@ }) | ||
.then(() => { | ||
return binding2 | ||
.open(testPort, defaultOpenOptions) | ||
.catch(err => { | ||
assert.instanceOf(err, Error) | ||
assert.equal(binding2.isOpen, false) | ||
return binding.close() | ||
}) | ||
return binding2.open(testPort, defaultOpenOptions).catch(err => { | ||
assert.instanceOf(err, Error) | ||
assert.equal(binding2.isOpen, false) | ||
return binding.close() | ||
}) | ||
}) | ||
@@ -309,5 +280,3 @@ }) | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -350,5 +319,3 @@ } | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -439,2 +406,7 @@ } | ||
}) | ||
it('resolves after an empty write', () => { | ||
const data = Buffer.from([]) | ||
return binding.write(data) | ||
}) | ||
}) | ||
@@ -457,5 +429,3 @@ | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -510,5 +480,3 @@ } | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -559,5 +527,3 @@ } | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -597,5 +563,3 @@ } | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -639,5 +603,3 @@ } | ||
if (!testPort) { | ||
it( | ||
'Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.' | ||
) | ||
it('Cannot be tested further. Set the TEST_PORT env var with an available serialport for more testing.') | ||
return | ||
@@ -644,0 +606,0 @@ } |
@@ -23,7 +23,3 @@ const binding = require('bindings')('bindings.node') | ||
super(opt) | ||
this.bindingOptions = Object.assign( | ||
{}, | ||
defaultBindingOptions, | ||
opt.bindingOptions || {} | ||
) | ||
this.bindingOptions = Object.assign({}, defaultBindingOptions, opt.bindingOptions || {}) | ||
this.fd = null | ||
@@ -63,27 +59,24 @@ this.writeOperation = null | ||
read(buffer, offset, length) { | ||
return super | ||
.read(buffer, offset, length) | ||
.then(() => unixRead.call(this, buffer, offset, length)) | ||
return super.read(buffer, offset, length).then(() => unixRead.call(this, buffer, offset, length)) | ||
} | ||
write(buffer) { | ||
this.writeOperation = super | ||
.write(buffer) | ||
.then(() => unixWrite.call(this, buffer)) | ||
.then(() => { | ||
this.writeOperation = null | ||
}) | ||
return this.writeOperation | ||
if (buffer.length > 0) { | ||
this.writeOperation = super | ||
.write(buffer) | ||
.then(() => unixWrite.call(this, buffer)) | ||
.then(() => { | ||
this.writeOperation = null | ||
}) | ||
return this.writeOperation | ||
} | ||
return Promise.resolve() | ||
} | ||
update(options) { | ||
return super | ||
.update(options) | ||
.then(() => promisify(binding.update)(this.fd, options)) | ||
return super.update(options).then(() => promisify(binding.update)(this.fd, options)) | ||
} | ||
set(options) { | ||
return super | ||
.set(options) | ||
.then(() => promisify(binding.set)(this.fd, options)) | ||
return super.set(options).then(() => promisify(binding.set)(this.fd, options)) | ||
} | ||
@@ -90,0 +83,0 @@ |
@@ -1,2 +0,2 @@ | ||
const debug = require('debug')('@serialport/bindings') | ||
const debug = require('debug')('serialport/bindings') | ||
@@ -3,0 +3,0 @@ switch (process.platform) { |
@@ -6,3 +6,3 @@ const childProcess = require('child_process') | ||
function checkPathOfDevice(path) { | ||
return /(tty(S|ACM|USB|AMA|MFD|O)|rfcomm)/.test(path) && path | ||
return /(tty(S|WCH|ACM|USB|AMA|MFD|O)|rfcomm)/.test(path) && path | ||
} | ||
@@ -9,0 +9,0 @@ |
@@ -23,7 +23,3 @@ const binding = require('bindings')('bindings.node') | ||
super(opt) | ||
this.bindingOptions = Object.assign( | ||
{}, | ||
defaultBindingOptions, | ||
opt.bindingOptions || {} | ||
) | ||
this.bindingOptions = Object.assign({}, defaultBindingOptions, opt.bindingOptions || {}) | ||
this.fd = null | ||
@@ -63,27 +59,24 @@ this.writeOperation = null | ||
read(buffer, offset, length) { | ||
return super | ||
.read(buffer, offset, length) | ||
.then(() => unixRead.call(this, buffer, offset, length)) | ||
return super.read(buffer, offset, length).then(() => unixRead.call(this, buffer, offset, length)) | ||
} | ||
write(buffer) { | ||
this.writeOperation = super | ||
.write(buffer) | ||
.then(() => unixWrite.call(this, buffer)) | ||
.then(() => { | ||
this.writeOperation = null | ||
}) | ||
return this.writeOperation | ||
if (buffer.length > 0) { | ||
this.writeOperation = super | ||
.write(buffer) | ||
.then(() => unixWrite.call(this, buffer)) | ||
.then(() => { | ||
this.writeOperation = null | ||
}) | ||
return this.writeOperation | ||
} | ||
return Promise.resolve() | ||
} | ||
update(options) { | ||
return super | ||
.update(options) | ||
.then(() => promisify(binding.update)(this.fd, options)) | ||
return super.update(options).then(() => promisify(binding.update)(this.fd, options)) | ||
} | ||
set(options) { | ||
return super | ||
.set(options) | ||
.then(() => promisify(binding.set)(this.fd, options)) | ||
return super.set(options).then(() => promisify(binding.set)(this.fd, options)) | ||
} | ||
@@ -96,5 +89,3 @@ | ||
getBaudRate() { | ||
return super | ||
.getBaudRate() | ||
.then(() => promisify(binding.getBaudRate)(this.fd)) | ||
return super.getBaudRate().then(() => promisify(binding.getBaudRate)(this.fd)) | ||
} | ||
@@ -101,0 +92,0 @@ |
const debug = require('debug') | ||
const logger = debug('@serialport/bindings:poller') | ||
const logger = debug('serialport/bindings/poller') | ||
const EventEmitter = require('events') | ||
@@ -4,0 +4,0 @@ const FDPoller = require('bindings')('bindings.node').Poller |
const fs = require('fs') | ||
const debug = require('debug') | ||
const logger = debug('@serialport/bindings:unixRead') | ||
const logger = debug('serialport/bindings/unixRead') | ||
@@ -12,8 +12,3 @@ module.exports = function unixRead(buffer, offset, length) { | ||
fs.read(this.fd, buffer, offset, length, null, (err, bytesRead) => { | ||
if ( | ||
err && | ||
(err.code === 'EAGAIN' || | ||
err.code === 'EWOULDBLOCK' || | ||
err.code === 'EINTR') | ||
) { | ||
if (err && (err.code === 'EAGAIN' || err.code === 'EWOULDBLOCK' || err.code === 'EINTR')) { | ||
if (!this.isOpen) { | ||
@@ -20,0 +15,0 @@ return reject(new Error('Port is not open')) |
const fs = require('fs') | ||
const debug = require('debug') | ||
const logger = debug('@serialport/bindings:unixWrite') | ||
const logger = debug('serialport/bindings/unixWrite') | ||
@@ -8,10 +8,3 @@ module.exports = function unixWrite(buffer, offset) { | ||
const bytesToWrite = buffer.length - offset | ||
logger( | ||
'Starting write', | ||
buffer.length, | ||
'bytes offset', | ||
offset, | ||
'bytesToWrite', | ||
bytesToWrite | ||
) | ||
logger('Starting write', buffer.length, 'bytes offset', offset, 'bytesToWrite', bytesToWrite) | ||
if (!this.isOpen) { | ||
@@ -23,8 +16,3 @@ return Promise.reject(new Error('Port is not open')) | ||
logger('write returned', err, bytesWritten) | ||
if ( | ||
err && | ||
(err.code === 'EAGAIN' || | ||
err.code === 'EWOULDBLOCK' || | ||
err.code === 'EINTR') | ||
) { | ||
if (err && (err.code === 'EAGAIN' || err.code === 'EWOULDBLOCK' || err.code === 'EINTR')) { | ||
if (!this.isOpen) { | ||
@@ -31,0 +19,0 @@ return reject(new Error('Port is not open')) |
@@ -69,21 +69,20 @@ const binding = require('bindings')('bindings.node') | ||
write(buffer) { | ||
this.writeOperation = super | ||
.write(buffer) | ||
.then(() => promisify(binding.write)(this.fd, buffer)) | ||
.then(() => { | ||
this.writeOperation = null | ||
}) | ||
return this.writeOperation | ||
if (buffer.length > 0) { | ||
this.writeOperation = super | ||
.write(buffer) | ||
.then(() => promisify(binding.write)(this.fd, buffer)) | ||
.then(() => { | ||
this.writeOperation = null | ||
}) | ||
return this.writeOperation | ||
} | ||
return Promise.resolve() | ||
} | ||
update(options) { | ||
return super | ||
.update(options) | ||
.then(() => promisify(binding.update)(this.fd, options)) | ||
return super.update(options).then(() => promisify(binding.update)(this.fd, options)) | ||
} | ||
set(options) { | ||
return super | ||
.set(options) | ||
.then(() => promisify(binding.set)(this.fd, options)) | ||
return super.set(options).then(() => promisify(binding.set)(this.fd, options)) | ||
} | ||
@@ -90,0 +89,0 @@ |
{ | ||
"name": "@serialport/bindings", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"main": "lib", | ||
"keywords": [ | ||
"serialport-binding" | ||
], | ||
"dependencies": { | ||
"@serialport/binding-abstract": "^2.0.1", | ||
"@serialport/parser-readline": "^2.0.1", | ||
"@serialport/binding-abstract": "^2.0.2", | ||
"@serialport/parser-readline": "^2.0.2", | ||
"bindings": "^1.3.0", | ||
"debug": "^3.1.0", | ||
"nan": "^2.9.2", | ||
"prebuild-install": "^5.1.0" | ||
"debug": "^4.1.0", | ||
"nan": "^2.11.0", | ||
"prebuild-install": "^5.2.1" | ||
}, | ||
"devDependencies": { | ||
"@serialport/binding-mock": "^2.0.1" | ||
"@serialport/binding-mock": "^2.0.2" | ||
}, | ||
@@ -45,3 +48,3 @@ "engines": { | ||
}, | ||
"gitHead": "4017f61620a845713f711576ba05bd47ae7601b6" | ||
"gitHead": "d59fe44fcc1ba52a51805375481ef339f3f83de4" | ||
} |
# @serialport/Bindings | ||
This package does some neat stuff. | ||
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 ["serialport-binding" at npm](https://www.npmjs.com/search?q=serialport-binding). | ||
This is why you'd use it. | ||
This is how you use it. | ||
```js | ||
const bindings = new Bindings() | ||
``` | ||
Learn more at our [bindings documentation](https://serialport.io/docs/api-bindings) page. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122127
1276
6
- Removeddebug@3.2.7(transitive)
Updateddebug@^4.1.0
Updatednan@^2.11.0
Updatedprebuild-install@^5.2.1