Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tidepool-org/cp2102
Silicon Labs CP2102 user-space USB driver for Node.js
https://github.com/tidepool-org/cp2102
cp210x driver nodejs silicon-labs usb user-space
Last synced: 20 days ago
JSON representation
Silicon Labs CP2102 user-space USB driver for Node.js
- Host: GitHub
- URL: https://github.com/tidepool-org/cp2102
- Owner: tidepool-org
- License: bsd-2-clause
- Created: 2018-07-19T16:10:32.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2024-06-18T15:56:40.000Z (7 months ago)
- Last Synced: 2024-11-11T20:15:45.559Z (about 2 months ago)
- Topics: cp210x, driver, nodejs, silicon-labs, usb, user-space
- Language: JavaScript
- Homepage:
- Size: 139 KB
- Stars: 16
- Watchers: 14
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/nuta) who posted a WebUSB version as a [GitHub gist](https://gist.github.com/nuta/2c70ba8855f50c536a51f0c5993c1e4c).