locked
Communicate with a FT232R device RRS feed

  • 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

  • Wrong forum, this is not related to the VS debugger or other tools.

    To test a serial device, connect something to the other side of the cable that can display the sent data. Maybe, another computer with a cross cable.

    Sometimes, adding CR or LF character after the command may help.

    Regards,

    -- pa


    • Edited by Pavel A Monday, August 22, 2016 1:53 PM
    Monday, August 22, 2016 1:51 PM
  • Hello,

    I'd ask the driver developer.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join('6D73646E5F6B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    Tuesday, August 30, 2016 8:42 PM
  • or try them over here.

    https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=whck%2Cwdk&filter=alltypes&sort=lastpostdesc

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Just Karl Tuesday, August 30, 2016 11:06 PM
    • Marked as answer by Just Karl Thursday, September 8, 2016 7:06 PM
    Tuesday, August 30, 2016 9:51 PM