Pavel Shaydo > Device-FTDI-0.05 > Device::FTDI

Download:
Device-FTDI-0.05.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.05   Source  

NAME ^

Device::FTDI - perl extension to talk to FTDI chips

VERSION ^

Version 0.05

SYNOPSIS ^

    use Device::FTDI;

    my $dev = Device::FTDI->new();
    ...

DESCRIPTION ^

WARNING: this is an alpha version

This is Perl bindings to libftdi library. It allows you to communicate with FTDI chips supported by this library.

CLASS METHODS ^

$class->find_all(%params)

Finds all connected devices with specified vendor and product codes. Returns list of hashes describing devices. Following parameters are accepted:

vendor

vendor code. Default 0x0403.

product

product code. Default 0x6001.

$class->new(%params)

Opens specified device and returns the corresponding object refference. Dies if an attempt to open the device has failed. Accepts following parameters:

vendor

vendor code. Default 0x0403.

product

product code. Default 0x6001.

description

device description string. By default undefined.

serial

device serial ID. By default undefined.

index

device index. By default 0.

DEVICE METHODS ^

Most of device methods return negative value in case of error. You can get error description using "error_string" method.

$dev->error_string

Returns string describing error after last operation

$dev->reset

Resets the device

set_interface($interface)

Open selected channels on a chip, otherwise use first channel. $interface may be one of: INTERFACE_A, INTERFACE_B, INTERFACE_C, INTERFACE_D, or INTERFACE_ANY.

$dev->purge_rx_buffer

Clears the read buffer on the chip and the internal read buffer. Returns 0 on success or negative error code otherwise.

$dev->purge_tx_buffer

Clears the write buffer on the chip. Returns 0 on success or negative error code otherwise.

$dev->purge_buffers

Clears the buffers on the chip and the internal read buffer. Returns 0 on success or negative error code otherwise.

$dev->setflowctrl($flowctrl)

Set flow control for ftdi chip. Allowed values for $flowctrl are: FLOW_RTS_CTS, FLOW_DTR_DSR, FLOW_XON_XOFF, FLOW_DISABLE. Returns 0 on success or negative error code otherwise.

$dev->set_line_property($bits, $stop_bit, $parity, $break)

Sets line characteristics. Last parameters may be ommited. Following values are acceptable for parameters (* marks default value):

$bits

BITS_7, BITS_8 (*)

$stop_bit

STOP_BIT_1, STOP_BIT_2, STOP_BIT_15 (*)

$parity

PARITY_NONE (*), PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE

$parity

BREAK_OFF (*), BREAK_ON

Note, that you have to import constants you need. You can import all constants using :all tag.

Returns 0 on success or negative error code otherwise.

$dev->set_baudrate($baudrate)

Sets the chip baudrate. Returns 0 on success or negative error code otherwise.

$dev->set_latency_timer($latency)

Sets latency timer. The FTDI chip keeps data in the internal buffer for a specific amount of time if the buffer is not full yet to decrease load on the usb bus. Latency must be between 1 and 255.

Returns 0 on success or negative error code otherwise.

$dev->get_latency_timer

Returns latency timer value or negative error code.

$dev->write_data_set_chunksize($chunksize)

Sets write buffer chunk size. Default 4096. Returns 0 on success or negative error code otherwise.

$dev->write_data_get_chunksize

Returns write buffer chunk size or negative error code.

$dev->read_data_set_chunksize($chunksize)

Sets read buffer chunk size. Default 4096. Returns 0 on success or negative error code otherwise.

$dev->read_data_get_chunksize

Returns read buffer chunk size or negative error code.

$dev->write_data($data)

Writes data to the chip in chunks. Returns number of bytes written on success or negative error code otherwise.

$dev->read_data($buffer, $size)

Reads data from the chip (up to $size bytes) and stores it in $buffer. Returns when at least one byte is available or when the latency timer has elapsed. Automatically strips the two modem status bytes transfered during every read.

Returns number of bytes read on success or negative error code otherwise. Note, that if no data available it will return 0.

$dev->set_bitmode($mask, $mode)

Enable/disable bitbang modes. $mask -- bitmask to configure lines, High/ON value configures a line as output. $mode may be one of the following: BITMODE_RESET, BITMODE_BITBANG, BITMODE_MPSSE, BITMODE_SYNCBB, BITMODE_MCU, BITMODE_OPTO, BITMODE_CBUS, BITMODE_SYNCFF.

SEE ALSO ^

FTDI, Win32::FTDI::FTD2XX, http://www.intra2net.com/en/developer/libftdi/

AUTHOR ^

Pavel Shaydo, <zwon at cpan.org>

BUGS ^

Please report any bugs or feature requests via GitHub bugtracker for this project: https://github.com/trinitum/perl-Device-FTDI/issues.

LICENSE AND COPYRIGHT ^

Copyright 2012 Pavel Shaydo.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: