FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Show Posts

You can view here all posts made by this member. Note that you can only see posts made in areas to which you currently have access.

Topics - sachin0005

Pages: [1]
1
Hi there,

I am trying to develop a windows application with C# language for communication with a device containing FTDI chip 232R UART.

I am using FTD2XX_NET class.

This class is showing that device is connected properly but i am unable to write my command and read response from it.

I tried to use C# Loop back sample code existing in FTDI website but the same code is not working for me.

I tried many times and one time i got the result but after that i am still trying and did not get any response from the device.


Please help and give sample code how to write command and read response with a FTDI device using C#.

Thanks in advance

Below is my code


public class FTDI
{
public FTDI myFtdiDevice;

public string command="?I_SCAN";

private void writecommand()
{

      ftStatus = myFtdiDevice.Write(command,command.length, ref numBytesWritten)
                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                {
                    MessageBox.Show("Failed to write to device (error " + ftStatus.ToString() + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }

                numBytesAvailable = 0;

                do
                {
                    ftStatus = myFtdiDevice.GetRxBytesAvailable(ref numBytesAvailable);
                    myFtdiDevice.GetLineStatus(ref data);
                    var st = Encoding.ASCII.GetString(new byte[] { data });
                    if (ftStatus != FTDI.FT_STATUS.FT_OK)
                    {
                        MessageBox.Show("Failed to get number of bytes available to read (error " + ftStatus.ToString() + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return false;
                    }
                    Thread.Sleep(16);
                } while (numBytesAvailable < FTDICommands.GETNUMBEROFSCAN.Length);
}

Pages: [1]