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


Author Topic: FT60X C++ Example not working  (Read 324 times)

Daniel123

  • Newbie
  • *
  • Posts: 7
    • View Profile
FT60X C++ Example not working
« on: July 20, 2018, 08:36:17 AM »

Dear all,
I tried a simple c++ example, which is provided in pieces with the d3xx api programming guide. I want to use ReadPipe for synchronous read of FT60X-Q.
I can compile it with visual studio. However running the exe file gives me back ftStatus = 32, so this means FT_OTHER_ERROR.
Here is the used code snippet:


Code: [Select]

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>
#include <Windows.h>
#include <iostream>
#include <string>
#include <chrono>
#include <fstream>
#include <thread>


//
// Include D3XX library
//
#include "FTD3XXLibrary\FTD3XX.h"
//#pragma comment(lib, "FTD3XX.lib")


int main()
{
int n;
//UCHAR acBuf[NUM_BUFFERS][BUFFER_SIZE] = { 0xFF };
//UCHAR acBufs[BUFFER_SIZE] = { 0xFF };
UCHAR Buffer[2048] = {};
OVERLAPPED vOverlapped[NUM_BUFFERS];





bool noDevice = false;

FT_STATUS ftStatus;
FT_HANDLE ftHandle;
DWORD numDevs = 0;

ftStatus = FT_CreateDeviceInfoList(&numDevs);
FT_DEVICE_LIST_INFO_NODE *devInfo = (FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE_LIST_INFO_NODE)* numDevs);
if (!FT_FAILED(ftStatus && numDevs > 0))
{


ftStatus = FT_GetDeviceInfoList(devInfo, &numDevs);
if (!FT_FAILED(ftStatus))
{
printf("List of Connected Devices!\n\n");
for (DWORD i = 0; i < numDevs; i++)
{
printf("Device[%d]\n", i);
printf("\tFlags: 0x%x %s | Type: %d | ID: 0x%08X | ftHandle=0x%x\n",
devInfo[i].Flags,
devInfo[i].Flags & FT_FLAGS_SUPERSPEED ? "[USB 3]" :
devInfo[i].Flags & FT_FLAGS_HISPEED ? "[USB 2]" :
devInfo[i].Flags & FT_FLAGS_OPENED ? "[OPENED]" : "",
devInfo[i].Type,
devInfo[i].ID,
devInfo[i].ftHandle);
printf("\tSerialNumber=%s\n", devInfo[i].SerialNumber);
printf("\tDescription=%s\n", devInfo[i].Description);


}
}
}
else
{
noDevice = true;
}

if (noDevice == false)
{
ftStatus = FT_Create(devInfo[0].SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &ftHandle);
std::cout << "Device Created";
}



ULONG transferBytes = 1 * 1024 * 1024;
int anzahl = 2048;
int anzahl_alt = 0;
int durchgang = 0;
long bytesTotal = 0;
ULONG ulBytesTransferred = 0;
long maxTransfer = 2147483648;
long transfer = 0;
bool isRunning = true;

ftStatus = FT_ReadPipe(ftHandle, 0x82, Buffer, transferBytes, &ulBytesTransferred, NULL);
std::cout << ftStatus;

std::cin >> i;
if (noDevice == false)
{
ftStatus = FT_Close(ftHandle);
}



    return 0;
}

Running the exe gives me first information of connected FT60X-Q, then "Device Created" and after this ftstatus 32 when FT_ReadPipe is called. Can you help me solving this issue.
Do I have to compile with Common Language Runtime common environment or CLI? I now used native c++. I have the same program in C#, there it works without problems.
Thank you.


Daniel
« Last Edit: July 20, 2018, 09:26:11 AM by Daniel123 »
Logged

casper

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: FT60X C++ Example not working
« Reply #1 on: October 23, 2018, 12:34:33 PM »

Hello, (I am not good at English.)

I had same error of FT_OTHER_ERROR. But I solved the problem.
In my case, I used more high performance, more new PC.
Both are compatible with USB 3.0, same C program,
But the two are behaved differently.

If you can, trying on another PC might work.
Logged