0.1.1 • Published 10 days ago

cp2102 v0.1.1

Weekly downloads
16
License
BSD-2-Clause
Repository
github
Last release
10 days ago

CP2102

Silicon Labs CP2102 user-space USB to serial adapter driver for Node.js and WebUSB in the browser

Usage

const CP2102 = require('cp2102');
const { webusb } = require('usb');

const opts = {
    baudRate : 38400
};

(async () => {
  const device = await webusb.requestDevice({
    filters: [
      {
        vendorId: 0x10c4,
        productId: 0x85a7,
      },
    ],
  });

  const connection = new CP2102(device, opts);

  connection.addEventListener('data', (res) => {
    console.log('Data:', res);
    connection.close(() => {});
  });

  connection.addEventListener('ready', () => {
    connection.write([0x01, 0x02, 0x02], (err) => {
      if (err) {
        console.log('Error sending command:', err);
      }
    });
  });
})().catch((error) => {
  console.log('Error: ', error);
});

Thanks

Thanks to Seiya Nuta who posted a WebUSB version as a GitHub gist.

0.1.0

10 days ago

0.1.1

10 days ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

6 years ago