Olek's blog

To content | To menu | To search

Tag - WinAPI

Entries feed

Tuesday, August 21 2012

Opening serial ports above COM9 (under Windows)

When you use WinAPI to open serial port with number larger than 9 (e.g.: COM10) the CreateFile function may (will?) fail, if the port name is given straight.

The proper way to specify the port is to provide the \\.\ sequence before port name, e.g.: \\.\COM10

C/C++ example: handle = CreateFile("\\\\.\\COM11", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

Sunday, July 29 2012

WriteFile reports wrong transfer sizes with FT232

There is an interesting issue that may appear when you try to communicate with FT232R virtual serial port using WinAPI. The problem probably persists for other access methods too.

Problem description: - The function WriteFile reports unusually large transfers (e.g. 4104 bytes instead of 1 byte) - It reports 'success', and GetLastError() shows nothing - Actually it sends the amount of data reported, or instead skips sending completely

If you experience the problems mentioned above - ask yourself one simple question. Haven't you connected the FTDI chip to the USB 3.0 port ?

Yes - in my case connecting it to USB 2.0 solved the problem.

(Observed on: Samsung RF711, Windows 7 64-bit, FT232RL)