pylibftdi - python wrapper for libftdi
Copyright (c) 2010-2013 Ben Bass <benbass@codedstructure.net> See LICENSE file for details and (absence of) warranty
pylibftdi: http://bitbucket.org/codedstructure/pylibftdi
Neither libftdi nor Intra2net are associated with this project; if something goes wrong here, it’s almost definitely my fault rather than a problem with the libftdi library.
pylibftdi - python wrapper for libftdi
Copyright (c) 2010-2013 Ben Bass <benbass@codedstructure.net> See LICENSE file for details and (absence of) warranty
pylibftdi - python wrapper for libftdi
Copyright (c) 2010-2013 Ben Bass <benbass@codedstructure.net> See LICENSE file for details and (absence of) warranty
pylibftdi: http://bitbucket.org/codedstructure/pylibftdi
Bases: pylibftdi.driver.Device
simple subclass to support bit-bang mode
Internally uses async mode at the moment, but provides a ‘sync’ flag (defaulting to True) which controls the behaviour of port reading and writing - if set, the FIFOs are ignored (read) or cleared (write) so operations will appear synchronous
get or set the direction of each of the IO lines. LSB=D0, MSB=D7 1 for output, 0 for input
latch property - the output latch (in-memory representation of output pin state)
Note _latch is not masked by direction (except on initialisation), as otherwise a loop incrementing a mixed input/output port would not work, as it would ‘stop’ on input pins. This is the primary use case for ‘latch’. It’s basically a port which ignores input.
Returns: | the state of the output latch |
---|
pylibftdi - python wrapper for libftdi
Copyright (c) 2010-2013 Ben Bass <benbass@codedstructure.net> See LICENSE file for details and (absence of) warranty
pylibftdi: http://bitbucket.org/codedstructure/pylibftdi
Bases: object
Represents a connection to a single FTDI device
get or set the baudrate of the FTDI device. Re-read after setting to ensure baudrate was accepted by the driver.
Instruct the FTDI device to flush its FIFO buffers
By default both the input and output buffers will be flushed, but the caller can selectively chose to only flush the input or output buffers using flush_what:
FLUSH_BOTH - (default) FLUSH_INPUT - (just the rx buffer) FLUSH_OUTPUT - (just the tx buffer)
this allows the vast majority of libftdi functions which are called with a pointer to a ftdi_context struct as the first parameter to be called here preventing the need to leak self.ctx into the user code (and import byref from ctypes):
>>> with Device() as dev:
... # set 8 bit data, 2 stop bits, no parity
... dev.ftdi_fn.ftdi_set_line_property(8, 2, 0)
...
read upto length bytes from the FTDI device :param length: maximum number of bytes to read :return: value read from device :rtype: bytes if self.mode is ‘b’, else decode with self.encoding
readline() for file-like compatibility.
Parameters: | size – maximum amount of data to read looking for a line |
---|---|
Returns: | a line of text, or size bytes if no line-ending found |
This only works for mode=’t’ on Python3
Bases: object
This is where it all happens... We load the libftdi library, and use it.
pylibftdi - python wrapper for libftdi
Copyright (c) 2010-2013 Ben Bass <benbass@codedstructure.net> See LICENSE file for details and (absence of) warranty