Error Code 87 - WinXP WriteFile()

Writing code in MS Visual C++…
I’m communicating via the virtual comport to a jrk 21v3 motor controller. The comport opens without error using ::CreateFile(), however the ::WriteFile() will not transfer any bytes and instead generates an error 87 (INVALID PARAMETER)…BUT none of the parameters are invalid. If I set the comport to the hardware COM1 in my PC there are no errors. However comport COM9, the virtual COM->USB->jrk 21v3 motor controller doe snot work at all. There seems to be a problem with that “virtual” port. Anyone else encounter similar problems? …better yet, any solutions?

If you’re using Visual C++ then I recommend using the System.IO.Ports.SerialPort class to communicate with the jrk.

But if you would rather use CreateFile/WriteFile, could you try simplifying your code down to the simplest possible thing that fails and post the code here?


Also, what service pack level (e.g. SP2 or SP3) or Windows XP do you have? Have you been able to communicate with the Jrk’s COM port using any other serial program, such as the Pololu Serial Transmitter utility?

Thanks for the quick response, David.
FYI: My Win-XP is SP2, and I’m using Visual Studio 2005.

I just tried the Pololu Serial Transmitter utility. It generates an “unhandled exception” and the same error that my code generates, i.e. “The parameter is incorrect”. Based on the “exception text” dump from the Pololu Serial Transmitter utility, it appears that utility uses the System.IO.Ports.SerialPort class, and the same problem occurs as with my ::WriteFile().

Thanks for the suggestions.

One other note…
“The Pololu Jrk 21v3 Command Port (COM9)” installs without error, however I do get an error whemn Windows tries to install the “Pololu Jrk 21v3 TTL Port (COM10)” . The Device Manager indicates an error for the device, and states “The device cannot start (Code 10)”.

Although I am not accessing that port (COM10), I wonder if this error could have something to do with my comm problem?


The jrk is not compatible with SP2. Is there a reason you are not upgrading?


Re: Win-SP3…
I did not see that “SP3” requirement. My computer is currently being upgraded to SP3 as I type. I shall soon know if that fixes my problem.
I suspect it will!
Thanks a lot Paul.

FYI: SP3 fixed my problem.
Thanks, again.

1 Like