Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Experts,
After spending my whole last night on google i doesn't found any thing useful to solve my problem.
so my last choice is all of you guys,
now problem start when,
I improves my window based application from serial communication to USB communication for hardware device communication.

When i deal with hardware from my pc .i need intermadiate for communication.need to avoid this with direct USB communication..
Like,
When i connect a USB pen drive to PC my software detect it and allows me to write any data on it.

please provide any interface, library , class or any think in c++ or mfc that helps me to read and write data on USB PORT.

Thanks.
Posted
Comments
Jochen Arndt 21-Sep-12 4:15am    
What kind of USB device you are using? The device usually comes with drivers that can be used to access it. These drivers often provide a virtual COM port that can be accessed by your aplication like physical serial ports. You may also identify the chip of your USB device and use the library provided by the chip manufacturer.

1 solution

First of all, sleep (it helps keeping you healthy).

Using virtual serial port on USB is often fine. If you need to write data on a pen drive the I believe the easier way is (by far) using OS file functions (you only need to detect when the pen drive is plugged in, using, for instance WMI[^]).

On the other hand, if you really need high speed communication with a USB device then, be warned, it wouldn't be (as far as I know) a simple task (see for instance, here[^]).
 
Share this answer
 
Comments
Coder Block 21-Sep-12 8:07am    
thank u so much for valueable guid but,
i am new bee in usb communication i don't known even how to write data on usb ,
is there is any mechanism or code in mfc or vc++ that allows me to write data on port...
and really its defficult to me to understand the WMI
CPallini 21-Sep-12 8:13am    
If you just need to write/read on a pen drive the use the standard OS file functions (e.g. CreateFile). As about WMI I'm a newbie myself, but you may find many samples on the web, just Google for.
Good luck.
Coder Block 5-Oct-12 2:18am    
Hey is WDK (Window Driver Kit)is useful while communicating USB device.
i can communincate with USB port using same but,
while using it..
Now i got problem ,
Result=SetupDiEnumDeviceInterfaces
(hDevInfo,
0,
&HidGuid,
MemberIndex,
&devInfoData);
DWORD Error = GetLastError();
where this function return 0 which is invalide and GetLastError() returns 259
please give me little hint why this is happening..
CPallini 5-Oct-12 3:31am    
259 means (according to Winerror.h): "no more items".
Coder Block 5-Oct-12 4:05am    
means??
how to handle it..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900