Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

CreateFile with both GENERIC_READ and GENERIC_WRITE

$
0
0

Hello,

I'm writing a program to talk to a PIC18F14K50 via USB. First there were two seperate functions for creating a read handle and a write handle like

DeviceHandleLocal=CreateFile(DevicePath,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL);


Because I need the read and the write function regularly alternating I want to create one read-write-handle with both access options like

DeviceHandleLocal=CreateFile(DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL);

Using the first two seperate handles works fine but uses too much time for my application. With the second options the CreateFile isn't succesfull.

With GetLastError I get a error number of 230 (decimal).

Do I have to consider something else in addition to add the second access option?

I'm using Visual Studio Ultimate 2013, Version 12.0.30110.00 Update 1. The endpoint in the µController are initialized in and out, so there should be no problem as the separate functions are working.

I appreciate your comments and suggestions and try to give you more informations if needed.

Regards, lh


Viewing all articles
Browse latest Browse all 15302

Trending Articles