Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 VC7 VC7.1 C++ Visual-Studio MFC , +
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 20-Sep-12 23:06pm
Comments
Jochen Arndt at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]).
  Permalink  
Comments
Coder Block at 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 at 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 at 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 at 5-Oct-12 3:31am
   
259 means (according to Winerror.h): "no more items".
Coder Block at 5-Oct-12 4:05am
   
means??
how to handle it..
CPallini at 5-Oct-12 4:14am
   
That stops the enumeration, as far as I understand.
Coder Block at 5-Oct-12 4:26am
   
yup but what wrong with code??

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

  Print Answers RSS
0 Maciej Los 184
1 Sergey Alexandrovich Kryukov 154
2 Sascha Lefévre 120
3 Abhinav S 104
4 Jörgen Andersson 75
0 Sergey Alexandrovich Kryukov 6,628
1 OriginalGriff 6,298
2 Peter Leow 2,534
3 Maciej Los 2,437
4 Abhinav S 2,378


Advertise | Privacy | Mobile
Web01 | 2.8.150414.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100