简体   繁体   中英

Com port : Serial communication on Windows 8

I need to send 8 bits (a byte) to a device via serial communication. This message is just a number between 0 and 255 encoded on 8 bits (nothing more complicated than that). I do not need to read any anwer nor anything coming from the device. And I need to do that on Windows.

The solution I'm trying to implement on Windows 8 is currently not working. I'm trying to use CreateFile .

Here is my code :

static HANDLE handle;

//[...]

handle = CreateFile("\\\\.\\COM4", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (handle == INVALID_HANDLE_VALUE)
{
    //  Handle the error.
    printf ("CreateFile failed with error %d.\n", GetLastError());
}

The console output is :

CreateFile failed with error 2.

Finally (a part of) my device manager ( screenshot ):

Port (COM et LPT)
--> Communications Port (COM1)
--> Prolific USB-to-Serial Comm Port (COM4)

From what I've understood the "error 2" is "file not found".

That's it. You can either help me solving this problem or give me another different solution (because, in fact, what I want to do should not be that complicated).

Thanks for your attention.

It was a driver problem, the one that windows installed by default isn't working ( screenshot ).

I installed this driver . And everything works perfectly fine.

Prolific has a big problem with fake chips. So they added authentication to their newer chips, and newer driver versions. If the hardware doesn't pass authentication, the driver goes into Code 10 status.

Prolific's older chips don't have the authentication either, so the driver treats them like fakes. Not a very good experience for the user. Those chip versions are officially listed as "not supported on Windows 8" on Prolific's site. However, there's no actual incompatibility with the OS, and reverting to a driver version before the authentication feature works around the issue. But then you are stuck on an old buggy driver version.

(End technical explanation, begin economic one)

The solution is for hardware manufacturers to vote with their feet and not continue purchasing chips from a company that

  • punishes innocent consumers who bought hardware with fake chips, for something done early in the supply chain that the consumer had no knowledge of
  • disables genuine product as collateral damage in their private war on knockoffs

Of course, hardware manufacturers increase sales when consumers have to replace working peripherals with new ones with the authentication-enabled chips. But it's a scummy tactic.

Ultimately, then, consumers have to refuse to spend money on products that have planned obsolescence.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM