K]      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcd]^_`abcd]^_`abcd@Representation of a baud rate. The most interesting part is the  instance for e. fghijkTransmitter on / Transmitter off Data-Terminal-Ready / Data-Set-Ready Request-To-Send / Clear-To-Send CModem status information. The modem status is send as a header for = each read access. In the absence of data the FTDI chip will " generate the status every 40 ms. 7The modem status can be explicitely requested with the  V function.  Clear to send (CTS) Data set ready (DTS) Ring indicator (RI) "Receive line signal detect (RLSD) Data ready (DR) Overrun error (OE) Parity error (PE) Framing error (FE) Break interrupt (BI) $Transmitter holding register (THRE) Transmitter empty (TEMT) Error in RCVR FIFO The parity bit is always 0. The parity bit is always 1. >The parity bit is set to one if the number of ones in a given @ set of bits is odd (making the total number of ones, including  the parity bit, even). >The parity bit is set to one if the number of ones in a given A set of bits is even (making the total number of ones, including  the parity bit, odd). !MPSSE bitbang modes "9Single Channel Synchronous FIFO Mode, available on 2232H  chips. #;Bit-Bang on CBus pins of R-type chips, configure in EEPROM  before use. $=Fast Opto-Isolated Serial Interface Mode, available on 2232x  chips. %0MCU Host Bus Emulation Mode, available on 2232x 1 chips. CPU-style fifo mode gets set via EEPROM. &9Synchronous Bit-Bang Mode, available on 2232x and R-type  chips. '=Multi-Protocol Synchronous Serial Engine, available on 2232x  chips. (<Classical asynchronous bitbang mode, introduced with B-type  chips. )/Switch off bitbang mode, back to regular serial/FIFO. l#The type of a USB control request. *mn+opqrs,1You need a handle in order to communicate with a 9. tuvw-@A device interface. You can imagine an interface as a port or a @ communication channel. Some devices support communication over ' multiple interfaces at the same time. ./012The type of FTDI chip in a 9. The capabilities of a device  depend on its chip type. 3456789$A representation of an FTDI device. xyz{|}~:CDefault USB timeout. The timeout can be set per device handle with  the A function. ;<=@Promote a USB device to an FTDI device. You are responsible for B supplying the correct USB device and specifying the correct chip E type. There is no failsafe way to automatically determine whether a - random USB device is an actual FTDI device.  USB device  FTDI device >?Tries to guess the type of the FTDI chip by looking at the USB " device release number of a device'"s descriptor. Each FTDI chip uses 1 a specific release number to indicate its type. ?Perform a USB device reset. @2Returns the USB timeout associated with a handle. A3Modifies the USB timeout associated with a handle. BCOpen a device handle to enable communication. Only use this if you  can't use D for some reason. CRelease a device handle. DAThe recommended way to acquire a handle. Ensures that the handle A is released when the monadic computation is completed. Even, or * especially, when an exception is thrown. EFGHIJ/Run the ChunkedReaderT given an initial state. GThe initial state represents excess bytes carried over from a previous Prun. When invoking runChunkedReaderT for the first time you can safely pass the " bytestring as the initial state. IA contrived example showing how you can manually thread the excess bytes 5through subsequent invocations of runChunkedReaderT:    example "7 + ! IO ()  example ifHnd = do  (packets1, rest1) ! runChunkedReaderT (K ifHnd (return ) 400)   print $  BS.concat packets1  (packets2, rest2) ! runChunkedReaderT (K ifHnd (return  ) 200) rest1  print $  BS.concat packets2 "However, it is much easier to let *s monad instance handle the  plumbing:   example "7 + ! IO ()  example ifHnd =  let reader = do packets1 ! K ifHnd (return ) 400 % liftIO $ print $  BS.concat packets1  packets2 ! K ifHnd (return ) 200 % liftIO $ print $  BS.concat packets1  in runChunkedReaderT reader  KCReads data from the given FTDI interface by performing bulk reads. (This function produces an action in the ChunkedReaderT monad that =will read exactly the requested number of bytes unless it is .explicitly asked to stop early. Executing the readData action will block until either:  All data are read $ The given checkStop action returns  5The result value is a list of chunks, represented as  ByteString;s. This representation was choosen for efficiency reasons. GData are read in packets. The function may choose to request more than Eneeded in order to get the highest possible bandwidth. The excess of "bytes is kept as the state of the ChunkedReaderT monad. A subsequent invocation of readData/ will first return bytes from the stored state Ebefore requesting more from the device itself. A consequence of this Dbehaviour is that even when you request 100 bytes the function will >actually request 512 bytes (depending on the packet size) and block Funtil all 512 bytes are read! There is no workaround since requesting -less bytes than the packet size is an error.  USB timeouts will not interrupt readData. In case of a timeout readData: will simply resume reading data. A small USB timeout can degrade performance. GThe FTDI latency timer can cause poor performance. If the FTDI chip can't fill Ka packet before the latency timer fires it is forced to send an incomplete Hpacket. This will cause a stream of tiny packets instead of a few large Ipackets. Performance will suffer horribly, but the request will still be  completed. NIf you need to make a lot of small requests then a small latency can actually improve performance. OModem status bytes are filtered from the result. Every packet send by the FTDI Mchip contains 2 modem status bytes. They are not part of the data and do not Hcount for the number of bytes read. They will not appear in the result.  Example:  $ -- Read 100 data bytes from ifHnd  (packets, rest) ! J (K ifHnd (return ) 100)  Check stop action Number of bytes to read LPerform a bulk read. 4Returns the bytes that where read (in the form of a  ) and a flag ? which indicates whether a timeout occured during the request. Number of bytes to read MPerform a bulk write. JReturns the number of bytes that where written and a flag which indicates / whether a timeout occured during the request. Data to be written 1Generic FTDI control request with explicit index Index NReset the FTDI device. OClear the on-chip read buffer. P Clear the on-chip write buffer. Q5Returns the current value of the FTDI latency timer. R9Set the FTDI latency timer. The latency is the amount of ; milliseconds after which the FTDI chip will send a packet 2 regardless of the number of bytes in the packet. S2The bitmode controls the method of communication. TASets the baud rate. Internally the baud rate is represented as a ? fraction. The maximum baudrate is the numerator and a special  divisor6 is used as the denominator. The maximum baud rate is  given by the  instance for e. The divisor D consists of an integral part and a fractional part. Both parts are D limited in range. As a result not all baud rates can be accurately C represented. This function returns the nearest representable baud = rate relative to the requested baud rate. According to FTDI < documentation the maximum allowed error is 3%. The nearest 4 representable baud rate can be calculated with the  \ function. USet RS232 line characteristics Number of bits Number of stop bits Optional parity mode Break V#Manually request the modem status. W,Set the flow control for the FTDI chip. Use  to disable flow  control. XSet DTR line. YSet RTS line. Z%Set the special event character. Use  to disable the event  character. [Set the error character. Use ! to disable the error character. \0Calculates the nearest representable baud rate. HFinds the divisors that most closely represent the requested baud rate. :Calculates the baud rate from a divisor and a subdivisor. fghijk  !"#$%&'()l*mn+opqrs,tuvw-./0123456789xyz{|}~:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\fghghijkjk     !)('&%$#""#$%&'()l*mnmn+opqrsopqrs,tuvwtuvw-10/../0128765433456789xyz{xyz{|}~:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]92876543;<=>-10/.,?@ABCD+EFGHI*JKLMNOPQR!)('&%$#"S U\T VWXYZ[:       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijjkllmn,o-pqrs.tuv;wxyz{|}~gftdi-0.2 System.FTDISystem.FTDI.UtilsSystem.FTDI.InternalBaudRate unBaudRateFlowCtrlXOnXOffDTR_DSRRTS_CTS ModemStatus msClearToSendmsDataSetReadymsRingIndicatormsReceiveLineSignalDetect msDataReadymsOverrunError msParityErrormsFramingErrormsBreakInterruptmsTransmitterHoldingRegistermsTransmitterEmptymsErrorInReceiverFIFOStopBits StopBit_2 StopBit_15 StopBit_1 BitDataFormatBits_8Bits_7Parity Parity_Space Parity_Mark Parity_Even Parity_OddBitModeBitMode_SyncFIFO BitMode_CBus BitMode_Opto BitMode_MCUBitMode_SyncBitBang BitMode_MPSSEBitMode_BitBang BitMode_ResetChunkedReaderTInterfaceHandle DeviceHandle Interface Interface_D Interface_C Interface_B Interface_AChipTypeChipType_4232HChipType_2232H ChipType_RChipType_2232C ChipType_BM ChipType_AMDevicedefaultTimeout getChipType setChipType fromUSBDevice guessChipTyperesetUSB getTimeout setTimeout openDevice closeDevicewithDeviceHandlegetDeviceHandle getInterface openInterfacecloseInterfacewithInterfaceHandlerunChunkedReaderTreadDatareadBulk writeBulkresetpurgeReadBufferpurgeWriteBuffergetLatencyTimersetLatencyTimer setBitMode setBaudRatesetLinePropertypollModemStatussetFlowControlsetDTRsetRTSsetEventCharactersetErrorCharacternearestBaudRate genFromEnumorBitsandBitsclampatLeastatMostdivRndUpbetweenbaseGHC.EnumBoundedBRSubDiv unBRSubDivBRDivunBRDiv USBControlunCR ifHndDevHndifHndInterface ifHndInEPDescifHndOutEPDesc devHndUSB devHndDev devHndTimeoutdevUSB devUSBConf devChipType RequestValue RequestCode FTDIExceptionInterfaceNotFoundreqResetreqSetModemCtrlreqSetFlowCtrlreqSetBaudRate reqSetDatareqPollModemStatusreqSetEventCharreqSetErrorCharreqSetLatencyTimerreqGetLatencyTimer reqSetBitMode reqReadPins reqReadEEPROMreqWriteEEPROMreqEraseEEPROM valResetSIOvalPurgeReadBuffervalPurgeWriteBuffer valSetDTRHigh valSetDTRLow valSetRTSHigh valSetRTSLowinterfaceIndexinterfaceToUSBinterfaceEndPointIninterfaceEndPointOutbytestring-0.9.1.7Data.ByteStringemptyghc-primGHC.BoolFalseTrueData.ByteString.Internal ByteString genControlcontrol readControl writeControlmarshalBitModemarshalModemStatusunmarshalModemStatusmarshalFlowControl Data.MaybeNothinggenSetCharacterencodeBaudRateDivisorscalcBaudRateDivisors calcBaudRate