|
Code Examples |
|
|
|
C# Examples |
|
This page contains examples of communicating
with FTDI devices through the D2XX drivers and FTD2XX.DLL using C#.
FTDI have provided a
managed .NET
wrapper class for the FTD2XX DLL on the Windows platform.
The managed wrapper DLL (FTD2XX_NET.DLL)
is provided as a free download with Intellisense documentation provided
in the FTD2XX_NET.XML file - this is viewable in the Visual Studio
Object Browser and also provides hints as the code is written.
Examples 3 and 4 below both show how to use
the FTD2XX_NET
interface DLL. A reference should be added to the
FTD2XX_NET.DLL file in the Solution Explorer. Simply right-click
on the References item in the Solution Explorer in your Visual Studio
project, select "Add Reference" then "Browse" and locate the DLL.
The XML file should be placed in the same location.
To download the .NET Wrapper source code,
click here
|
|
Example 1 |
|
KOPF GmbH have developed an application
example in C# called "USBTransfer" which can be downloaded by
clicking here.
It requires the addition of a secondary DLL (AID.DLL) in C#
style. To download this DLL from the FTDI web site,
click here.
Alternatively, please visit the KOPF GmbH web site
http://www.kopfweb.de
for up to date information (in German) and the latest downloads.
Our thanks
to Oliver Kopf of
KOPF GmbH for making this example
available.
These
programs and examples are provided "as-is" and neither FTDI or KOPF GmbH
warrant their suitability for any purpose. |
|
Example 2 |
|
This
variant of FTDI's D2XXAccess example for Windows CE uses C# to list
devices, return description strings, open devices, set Baud rates, read
data and write data. This example is also available in
VB.NET and
C++ for Windows CE
platforms.
This code
requires that FTDI's D2XX drivers
for Windows CE be installed.
These can be obtained through our
Drivers page.
To download
the C# version of D2XXAccess for Windows CE,
click here.
|
|
Example 3 |
|
This code
provides a data loopback example showing how to write to and read from a
device using the
FTD2XX_NET interface DLL. "Hello World!" is written to
the device and read back from it - note that note that TXD must be shorted to RXD, and CTS# shorted to RTS#, for this example to work.
This code
requires that
FTDI's D2XX drivers for Windows be installed. These can
be obtained through our
Drivers page.
To download
the C# version of LoopBack for Windows,
click here.
|
|
Example 4 |
|
This code
provides an example of changing the serial number in a device EEPROM
using the
FTD2XX_NET interface DLL. The EEPROM is read and the
serial number is changed to an empty string (which allows the FTD2XX DLL
to generate a serial number) before programming the EEPROM with the new
contents.
This code
requires that
FTDI's D2XX drivers for Windows be installed. These can
be obtained through our
Drivers page.
To download
the C# version of EEPROM for Windows,
click here.
|
|
Example 5 |
|
A sample
VCP application using the .NET SerialPort component. The
VCPTestCENET application waits on the received character event to read
the available data from the in buffer. Text can be written out to
the device by typing in the top text box.
Source
code and the
executable are both available.
|
|
Example 6 |
|
A sample demonstrating the use of the C# wrapper with the D2xx driver, for the
FT232H,
FT2232H and
FT4232H devices to create an I2C master through the MPSSE mode as described in
AN_411 is provided for users to experiment with, and extend into their own applications.
To download this example,
please click here.
|
|
Example 7 |
|
Source code for the
FT4232H factory test utility which provides a user interface to program and test FTDI FT4232H devices.
More information can be found in AN_128
User Guide For FT4232H Factory Test Utility.
To download the source code, please click
here.
|
|