New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

libftdi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libftdi

Bindings for ftdi library

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

node-libftdi

Binding for ftdi library calls.

Written and tested with node.js v0.12.7 on linux.

Requires ftdi development headers. Installing headers on Ubuntu:

$ sudo apt-get install libftdi-dev

Permissions may need to be changed to access the USB devices as a standard user. Example udev rule to set the group permissions for ftdi devices:

SUBSYSTEM=="usb",ATTR{idVendor}=="0403",ATTR{idProduct}=="6001",GROUP="plugdev"

A specific device can be targeted by serial number as shown in the 'Example usage' section.

Installation

$ npm install libftdi

Available methods

  • create_context()
  • ftdi_usb_open_desc(context, vendor, product, description, serial)
  • ftdi_set_bitmode(context, bitmask, mode)
  • ftdi_set_baudrate(context, baudrate)
  • ftdi_get_error_string(context)
  • ftdi_read_data(context, buf)
  • ftdi_write_data(context, buf, size)
  • ftdi_usb_purge_tx_buffer(context)

Example usage

var libftdi = require('libftdi')

// FTDI USB identifiers
var usbVendor = 0x0403;
var usbProduct = 0x6001;

// Read buffer size
var rxBufSize = 2048;

// Read baud rate
var rxBaudRate = 9600;

// Serial number of device
var serial = 'FT123456';

// Context
var ctx = libftdi.create_context();

libftdi.ftdi_usb_open_desc(ctx, usbVendor, usbProduct, null, serial);
console.log(libftdi.ftdi_get_error_string(ctx));

libftdi.ftdi_set_baudrate(ctx, rxBaudRate);
console.log(libftdi.ftdi_get_error_string(ctx));

// Buffer
var buf = new Buffer(rxBufSize);

// Read data
var data = libftdi.ftdi_read_data(ctx, buf);
console.log(libftdi.ftdi_get_error_string(ctx));
console.log('Byte count: ' + data);
console.log(buf);

// etc

To Do

  • Look at using NAN
  • Add further error checking to function arguments
  • Support for operating systems other than linux
  • Add other functions from c version of libftdi

Keywords

libftdi ftdi

FAQs

Package last updated on 24 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts