I connect a FT232R device controlled by a VMX controller(http://www.velmex.com/Products/controls/VXM_Controller.htmll). The device is connected to the COM9 port and I use the ftd2xx.lib library. Here is my code:
FT_STATUS ftStatus;FT_HANDLE ftHandle;charBuf[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}constchar* cmd ="command"bool res = FT_W32_WriteFile(ftHandle,(LPVOID)cmd, strlen(cmd),&bytes_written, NULL);if(bytes_written != strlen(cmd)|| res ==false){//error}FT_W32_CloseHandle(ftHandle);
On Mac I can connect to the serial port and send the "command" to the device and everything works fine.
On Windows I can connect to the device, there is no error in FT_W32_CreateFile or FT_W32_WriteFile, but when I send "command" nothing happens, the device doesn't react.
After a long search I think that maybe the problem is in the terminational character. I tried adding \r and/or \n at the end, beginning and both(end and beginning) but still not working.
I also don't specify to which serial port it should connect because I think that is enough to give the device(see Buf in the code).
Any ideas on what could be the problem ?
Thanks