New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cp2102

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cp2102 - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

package-lock.json

4

.eslintrc.json

@@ -5,4 +5,6 @@ {

"no-bitwise": 0,
"max-len": "warn"
"max-len": "warn",
"no-restricted-syntax": 0,
"no-await-in-loop": 0
}
}

@@ -22,6 +22,69 @@ /*

class cp2102 extends EventEmitter {
constructor(vendorId, productId, opts) {
constructor(vendorId, productId, opts, setup) {
super();
this.device = usb.findByIds(vendorId, productId);
this.opts = opts;
const dataBits = this.opts.dataBits || 8;
let stopBits;
if (this.opts.stopBits === 1 || this.opts.stopBits == null) {
stopBits = 0x0000;
} else {
stopBits = 0x0002;
}
let parity;
switch (this.opts.parity) {
case 'even':
parity = 0x0020;
break;
case 'odd':
parity = 0x0010;
break;
case 'none':
default:
parity = 0x0000;
}
this.setup = setup || [{
transfer: {
requestType: 'vendor',
recipient: 'device',
request: 0x00,
index: 0x00,
value: 0x01,
},
data: undefined,
},
{
transfer: {
requestType: 'vendor',
recipient: 'device',
request: 0x07,
index: 0x00,
value: 0x03 | 0x0100 | 0x0200,
},
data: undefined,
},
{
transfer: {
requestType: 'vendor',
recipient: 'device',
request: 0x01,
index: 0x00,
value: 0x384000 / this.opts.baudRate,
},
data: undefined,
},
{
transfer: {
requestType: 'vendor',
recipient: 'device',
request: 0x03,
index: 0x00,
value: (dataBits << 8) | parity | stopBits,
},
data: undefined,
}];
this.device.open(false); // don't auto-configure

@@ -33,5 +96,8 @@ const self = this;

self.iface.claim();
self.inEndpoint = self.iface.endpoint(0x81);
self.inEndpoint.startPoll();
self.inEndpoint = self.iface.endpoint(opts.inEndpointAddress || 0x81);
if (opts.transfers != null && opts.wordLength != null) {
self.inEndpoint.startPoll(opts.transfers, opts.wordLength);
} else {
self.inEndpoint.startPoll();
}
self.inEndpoint.on('data', (data) => {

@@ -43,29 +109,8 @@ self.emit('data', data);

try {
await this.controlTransferOut({
requestType: 'vendor',
recipient: 'device',
request: 0x00,
index: 0x00,
value: 0x01,
});
await this.controlTransferOut({
requestType: 'vendor',
recipient: 'device',
request: 0x07,
index: 0x00,
value: 0x03 | 0x0100 | 0x0200,
});
await this.controlTransferOut({
requestType: 'vendor',
recipient: 'device',
request: 0x01,
index: 0x00,
value: 0x384000 / this.opts.baudRate,
});
for (const parameter of self.setup) {
await this.controlTransferOut(parameter.transfer, parameter.data);
}
} catch (err) {
console.log('Error during CP2102 setup:', err);
}
self.emit('ready');

@@ -72,0 +117,0 @@ })();

{
"name": "cp2102",
"version": "0.0.5",
"version": "0.0.6",
"description": "Silicon Labs CP2102 user-space USB to serial driver",

@@ -27,3 +27,3 @@ "main": "index.js",

"dependencies": {
"usb": "1.6.5"
"usb": "1.6.3"
},

@@ -30,0 +30,0 @@ "devDependencies": {

@@ -32,2 +32,2 @@ # CP2102

Thanks to [Seiya Nuta](https://github.com/seiyanuta) who posted a WebUSB version as a [GitHub gist](https://gist.github.com/seiyanuta/2c70ba8855f50c536a51f0c5993c1e4c).
Thanks to [Seiya Nuta](https://github.com/nuta) who posted a WebUSB version as a [GitHub gist](https://gist.github.com/nuta/2c70ba8855f50c536a51f0c5993c1e4c).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc