ioBuster framework v25.02.4 documentation


ftdi

ftdi

Collection of Ftdi related functions

Methods

(static) close(devIdx)

Close the FTDI device.

Parameters:
Name Type Description
devIdx Number

device index

(static) flushBuffer(devIdx, offsetopt)

flush read buffer.

Parameters:
Name Type Attributes Default Description
devIdx Number

device Index

offset Number <optional>
0

if non-zero offset is provided, data in the read buffer before the offset will be flushed and the rest will be retained.

(static) getDeviceList(options) → {ftdi.DeviceInfo}

Get all device List

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
vendor Number <optional>
0

Filter by Vendor ID Selects all FTDI vendors when 0.

product Number <optional>
0

Filter by Product ID. Selects all FTDI products when 0.

Available Product Number list:

  • FT232BM/L/Q, FT245BM/L/Q: 0x6001
  • FT232RL/Q, FT245RL/Q: 0x6001
  • FT2232C/D/L: 0x6010
  • FT2232HL/Q: 0x6010
  • FT4232HL/Q: 0x6011
  • FT232HL/Q: 0x6014
  • VNC1L with VDPS Firmware: 0x6001
  • VNC2 with FT232Slave: 0x6001
Returns:
  • All devices list
Type
ftdi.DeviceInfo

(static) getErrorCode(devIdx) → {Number}

Get Error code from the FTDI device.

Parameters:
Name Type Description
devIdx Number

device index

Returns:
  • the error code of the device
Type
Number

(static) open(deviceInfo, options) → {Number}

Open a FTDI device with Interface.

Parameters:
Name Type Description
deviceInfo Object

device information to open

Properties
Name Type Attributes Default Description
vendor Number

Vendor Number FTDI Vendor ID: 0x0403

product Number

Product Number Product Number list:

  • FT232BM/L/Q, FT245BM/L/Q: 0x6001
  • FT232RL/Q, FT245RL/Q: 0x6001
  • FT2232C/D/L: 0x6010
  • FT2232HL/Q: 0x6010
  • FT4232HL/Q: 0x6011
  • FT232HL/Q: 0x6014
  • VNC1L with VDPS Firmware: 0x6001
  • VNC2 with FT232Slave: 0x6001
interface Number <optional>
INTERFACE_ANY

Device's interface Interface List:

  • INTERFACE_ANY: 0x0
  • INTERFACE_A: 0x1
  • INTERFACE_B: 0x2
  • INTERFACE_C: 0x3
  • INTERFACE_D: 0x4
description string <optional>
""

Device's description

  • Find the device with description.
serial string <optional>
""

Device's serial number

  • Find the device with serial number.
readInterval Number <optional>
50

Read interval for buffered read

options Object
Properties
Name Type Attributes Default Description
errorWhenAlreadyOpen Boolean <optional>
true

Throws an exception if the device is already open when this is set to true. Returns the device index if the device is already open when this is set to false.

Returns:

device index

Type
Number

(static) pipe(devIdx, logname) → {Boolean}

Pipe data to a file.

Parameters:
Name Type Description
devIdx Number

device Index

logname String

A log descriptor name.

Returns:
  • Returns true if piping to a file was successful
Type
Boolean

(static) read(devIdx, size, buffered) → {Buffer}

Read data from the FTDI device.

Parameters:
Name Type Description
devIdx Number

A device index.

size Number

The number of read size.

buffered Boolean

Returns data from a read buffer. A read buffer accumulates all received data until flush a flush command is issued

Returns:
  • read data
Type
Buffer

(static) setBaudRate(devIdx, baudRate)

Set baud rate to the FTDI device.

Parameters:
Name Type Description
devIdx Number

device index

baudRate Number

baudRate

(static) setBitmode(devIdx, bitmode)

Set bitmode to the FTDI device.

Parameters:
Name Type Description
devIdx Number

device index

bitmode Object

bitmode

Properties
Name Type Description
bitmask Number

bitmask

mode Number

MPSSE mode Available List:

  • BITMODE_RESET: 0x00, switch off bitbang mode, back to regular serial/FIFO
  • BITMODE_BITBANG: 0x01, classical asynchronous bitbang mode, introduced with B-type chips
  • BITMODE_MPSSE: 0x02, MPSSE mode, available on 2232x chips
  • BITMODE_SYNCBB: 0x04, synchronous bitbang mode, available on 2232x and R-type chips
  • BITMODE_MCU: 0x08, MCU Host Bus Emulation mode, available on 2232x chips CPU-style fifo mode gets set via EEPROM
  • BITMODE_OPTO: 0x10, Fast Opto-Isolated Serial Interface Mode, available on 2232x chips
  • BITMODE_CBUS: 0x20, Bitbang on CBUS pins of R-type chips, configure in EEPROM before
  • BITMODE_SYNCFF: 0x40, Single Channel Synchronous FIFO mode, available on 2232H chips
  • BITMODE_FT1284: 0x80, FT1284 mode, available on 232H chips

(static) setParity(devIdx, parity)

Set parity to the FTDI device.

Parameters:
Name Type Description
devIdx Number

device index

parity String

parity

Allowed values are:

  • "none"
  • "odd"
  • "even"

(static) unpipe(devIdx)

Unpipe FTDI device from a log file.

Parameters:
Name Type Description
devIdx Number

device Index

(static) useBinaryMode(devIdx)

Use binary mode for read data.

Under the binary mode, the data received from the device will not be piped to a log file.

Parameters:
Name Type Description
devIdx Number

device Index

(static) useTextMode(devIdx)

Use text mode for read data.

\r\n and \r will be changed to \n.

Parameters:
Name Type Description
devIdx Number

device Index

(static) write(devIdx, data) → {Number}

Write data to the FTDI device.

Parameters:
Name Type Description
devIdx Number

device Index

data Array | Buffer

data

Returns:
  • The number of written bytes.
Type
Number

Type Definitions

DeviceInfo

Properties:
Name Type Description
vendorId Number

Vendor ID

productId Number

Product ID

description String

Product Description

serial String

Serial Number

vendor String

Vendor Description

Type:
  • object