Documentation
¶
Index ¶
- Constants
- Variables
- func GetLibraryVersion() uint32
- func Init() error
- type BitMode
- type Device
- func (d *Device) Close() (e error)
- func (d *Device) GetStatus() (rx_queue, tx_queue, events int32, e error)
- func (d *Device) Purge(flags PurgeFlag) (e error)
- func (d *Device) Read(p []byte) (n int, e error)
- func (d *Device) Reset() (e error)
- func (d *Device) SetBaudRate(baud uint) (e error)
- func (d *Device) SetBitMode(mode BitMode) (e error)
- func (d *Device) SetBreakOff(props LineProperties) (e error)
- func (d *Device) SetBreakOn(props LineProperties) (e error)
- func (d *Device) SetChars(event, err byte) (e error)
- func (d *Device) SetFlowControl(f FlowControl) (e error)
- func (d *Device) SetLatency(latency int) (e error)
- func (d *Device) SetLineProperty(props LineProperties) (e error)
- func (d *Device) SetTimeout(read_timeout, write_timeout int) (e error)
- func (d *Device) SetTransferSize(read_size, write_size int) (e error)
- func (d *Device) Write(p []byte) (n int, e error)
- type DeviceInfo
- type EventMask
- type FlowControl
- type LineProperties
- type PurgeFlag
Constants ¶
const ( BITS_8 bitsPerWord = 8 BIST_7 bitsPerWord = 7 STOP_1 stopBits = 0 STOP_2 stopBits = 2 NONE parity = 0 ODD parity = 1 EVEN parity = 2 MARK parity = 3 SPACE parity = 4 )
const ( FT_OK = 0 FT_INVALID_HANDLE = 1 FT_DEVICE_NOT_FOUND = 2 FT_DEVICE_NOT_OPENED = 3 FT_IO_ERROR = 4 FT_INSUFFICIENT_RESOURCES = 5 FT_INVALID_PARAMETER = 6 FT_INVALID_BAUD_RATE = 7 FT_DEVICE_NOT_OPENED_FOR_ERASE = 8 FT_DEVICE_NOT_OPENED_FOR_WRITE = 9 FT_FAILED_TO_WRITE_DEVICE = 10 FT_EEPROM_READ_FAILED = 11 FT_EEPROM_WRITE_FAILED = 12 FT_EEPROM_ERASE_FAILED = 13 FT_EEPROM_NOT_PRESENT = 14 FT_EEPROM_NOT_PROGRAMMED = 15 FT_INVALID_ARGS = 16 FT_NOT_SUPPORTED = 17 FT_OTHER_ERROR = 18 )
FT_STATUS (DWORD)
const (
CHECK_RX_DELAY_MS = 200
)
Variables ¶
var ( ErrInvalidHandle = errors.New("FTDI :: Invalid device handle") ErrDeviceNotFound = errors.New("FTDI :: Device not found") ErrDeviceNotOpened = errors.New("FTDI :: Device not opened") ErrIO = errors.New("FTDI :: IO failed") ErrInsufficientResources = errors.New("FTDI :: Insufficient resources") ErrInvalidParameter = errors.New("FTDI :: Invalid parameter") ErrInvalidBaudRate = errors.New("FTDI :: Invalid baud rate") ErrDeviceNotOpenedForErase = errors.New("FTDI :: Device not opened for erase") ErrDeviceNotOpenedForWrite = errors.New("FTDI :: Device not opened for write") ErrFailedToWriteDevice = errors.New("FTDI :: Failed to write device") ErrEReadFailed = errors.New("FTDI :: EEPROM read failed") ErrEWriteFailed = errors.New("FTDI :: EEPROM write failed") ErrEEraseFailed = errors.New("FTDI :: EEPROM erase failed") ErrENotPresent = errors.New("FTDI :: EEPROM not present") ErrENotProgrammed = errors.New("FTDI :: EEPROM not programmed") ErrInvalidArgs = errors.New("FTDI :: Invalid arguments") ErrNotSupported = errors.New("FTDI :: Device not supported") ErrOther = errors.New("FTDI :: Unknown FTDI error") )
Functions ¶
func GetLibraryVersion ¶
func GetLibraryVersion() uint32
Return Library version, formatted to match D2XX
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device serializes each data direction on its own lock: libftdi's read and write paths touch disjoint context state and libusb allows concurrent transfers, so a reader blocked in its ~latency-timer USB poll doesn't hold up writes (as D2XX on Windows doesn't). Everything else takes both.
func Open ¶
func Open(di DeviceInfo, pid int) (d *Device, e error)
Open opens the FTDI device with di's serial number and product id pid. libftdi detaches the ftdi_sio kernel driver while the device is open (its /dev/ttyUSBn disappears); Close re-attaches it.
func (*Device) SetBaudRate ¶
func (*Device) SetBitMode ¶
func (*Device) SetBreakOff ¶
func (d *Device) SetBreakOff(props LineProperties) (e error)
func (*Device) SetBreakOn ¶
func (d *Device) SetBreakOn(props LineProperties) (e error)
func (*Device) SetFlowControl ¶
func (d *Device) SetFlowControl(f FlowControl) (e error)
func (*Device) SetLatency ¶
func (*Device) SetLineProperty ¶
func (d *Device) SetLineProperty(props LineProperties) (e error)
func (*Device) SetTimeout ¶
func (*Device) SetTransferSize ¶
type DeviceInfo ¶
type DeviceInfo struct {
Index uint64
ID uint64 // VID<<16 | PID, as D2XX reports it
SerialNumber string
Description string
Manufacturer string
}
func GetDeviceList ¶
func GetDeviceList() (dl []DeviceInfo, e error)
GetDeviceList lists the FTDI devices libftdi knows by default PID (0x6001/6010/6011/6014/6015). Devices whose strings can't be read (no permission on the USB node) are skipped rather than failing the scan.
type FlowControl ¶
type FlowControl uint16
const ( DISABLED FlowControl = 0x0000 RTS_CTS FlowControl = 0x0100 DTR_DSR FlowControl = 0x0200 XON_XOFF FlowControl = 0x0400 )
type LineProperties ¶
type LineProperties struct {
Bits bitsPerWord
StopBits stopBits
Parity parity
}
type PurgeFlag ¶
type PurgeFlag uint8
const ( FT_PURGE_RX PurgeFlag = 0x01 FT_PURGE_TX PurgeFlag = 0x02 FT_PURGE_BOTH PurgeFlag = FT_PURGE_RX | FT_PURGE_TX )