none
Communicate with a FT232R device

    Question

  • I have installed the VCP driver for Windows 7 from here: http://www.ftdichip.com/Drivers/VCP.htmNow I want to communucate with the device so here is the code :

    FT_STATUS ftStatus;
    FT_HANDLE ftHandle;
    char Buf[64];
    
    // the device found is **FT232R USB UART**
    ftStatus = FT_ListDevices(0, Buf, FT_LIST_BY_INDEX | FT_OPEN_BY_DESCRIPTION); 
    ftHandle = FT_W32_CreateFile(Buf, GENERIC_READ | GENERIC_WRITE, 0, 0,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL | FT_OPEN_BY_DESCRIPTION,
        0);
    
    if (ftHandle == INVALID_HANDLE_VALUE) {
        //error
    }
    const char* cmd = "command"
    bool res = FT_W32_WriteFile(ftHandle, (LPVOID)cmd, strlen(cmd), &bytes_written, NULL);
    if (bytes_written != strlen(cmd)) {
        //error
    }
    FT_W32_CloseHandle(ftHandle);

    I can found the device and there is no error in CreateFile or WriteFile but when I send the command the device doesn't react(nothing happens). I created a Win32 Console application in Visual Studio Community 2015 in C++, so that is why I use FT_W32... Should I also open the serial port using CreateFile ?What am I missing or doing wrong ?

    Thanks

    Monday, August 22, 2016 12:15 PM

Answers

All replies