FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  


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

Author Topic: FT_Write returning FT_OK but BytesWritten is 0  (Read 79 times)


  • Newbie
  • *
  • Posts: 1
    • View Profile
FT_Write returning FT_OK but BytesWritten is 0
« on: August 23, 2019, 03:02:45 PM »


We have a project using the FTDI driver (ftd2xx.dll) that generally works for loads of customers without problems. However I recently had a customer where communication between the software and device was failing, and it turns out that the FT_Write function was returning FT_OK but the 'BytesWritten' field was returned set to 0. 

Can anyone tell me under what possible conditions this could happen? I can't find anything online or in the documentation. It looks as if a failure to write any data should return an error code, but it doesn't. It's not something I've seen before - in the past we have seen FT_Write fail with an error code of 4 (FT_IO_ERROR) and it's because the device has been unplugged.

Re-plugging the device's USB connection seems to have solved the issue for now, but it has happened a couple of times for this customer and I'd like to get to the bottom of what is causing it.



FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 307
    • View Profile
Re: FT_Write returning FT_OK but BytesWritten is 0
« Reply #1 on: August 26, 2019, 04:42:38 PM »

Hello Liam,

Which driver version and IC are you using?

Has BytesWritten been initialised correctly first? This would be good practise.

You could also try FT_Purge.

What are your timeouts set to in FT_SetTimeouts? Could it be that it's timing out before there is enough time to send the data?
Remember USB is non-deterministic. There can be lots happening on a USB bus or with the OS which can cause delays.

See the D2XX Programmer's Guide for more information.

Also AN232B-04 Data Throughput, Latency & Handshaking provides some useful information and applies to all FTDI devices.

Best Regards,
FTDI Community