Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ USB interfaces
Hello Friends,
I am an electronics engineering student and currently I don't know about interfacing but I am required to interface one of my device to pc using USB since my lappy doesn't has any serial port. kindly help me by providing some very simple method to access USB port in visual C++ in in console mode application and NOT windows API since I am using opencv for some image processing part and it is designed as windows console application.
Thank you
Regards
Tushar Srivastava
Posted 11-Jan-12 7:11am
Edited 11-Jan-12 8:06am
Comments
Albert Holguin at 11-Jan-12 13:58pm
   
Does the device have a driver or are you supposed to write a driver? That's not all that clear from this...
Tushar Sriv at 11-Jan-12 14:05pm
   
Thank you for your valuable comments and replies. I will be using FT232R USB to serial converter. By the way tell me about very basic accessing after that since I haven't have any experience of interfacing.
Jochen Arndt at 11-Jan-12 14:58pm
   
The easiest way is to install the virtual serial port driver (VCP) and access the virtual COM port using standard file I/O commands. If you still want to access the device via the driver, download the D2XX Programmer's Guide and the D2XX driver containing the library. For the downloads, visit the FTDI web site.
Tushar Sriv at 11-Jan-12 14:10pm
   
Actually the device is completely made by me using most general ICs and component and no standard seems to follow with my device. I wanted to command my device simply using some binary codes that are recieved by my device and it does it's job I also have to check busy flag of my device ie one bit reading. Help me. Thank you.
Albert Holguin at 11-Jan-12 16:14pm
   
Do the ICs that you are using have a set of serial commands that are defined? If so (since you're using a USB to serial converter), you just have to access your chips through your virtual COM port. Look up on google how to pass serial data through a COM port and implement the commands that the ICs describe in their documentation (which is the API).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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

Solution 1

Usually the device manufacturer provides an API for interfacing the device with the PC (read the documentation). Very often (for low speed devices) they provide a serial port emulator, that is you communicate with the device using standard RS232 communication (again, check out your device documentation).
 
As about Windows API:
Windows is the Operative System, the API it provides are not only the ones used for 'the windows'. Specifically serial communication (USB included) functions are ready-to-use for console applications.
 

[update]
If you are using the FTDI chip a chip then (assuming the corrensponding driver is installed on your PC) you use standard RS232 API for communicating with it (see for instance: "Using Communication Resources" at MSDN[^]) on the PC side.
On the other side you typically have a, hopefully, a microcontroller with UART device.
[/update]
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

To access USB devices you must talk with the device specific USB driver using a library provided by the device manufacturer (or the manufacturer of the used USB interface chip). Whithout knowledge about the used device, nobody may help you here.
 
Console applications can call Windows API functions (and most existing console applications do so). How would you access a file or a serial port from a console application without using API functions?
 
If you don't know much about interface programming and your device has a serial port, you may buy an USB-to-RS232 converter. Such converters provide a virtual serial port interface that can be accessed like a physical port.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 355
1 _Amy 235
2 Peter Leow 185
3 Andreas Gieriet 180
4 Dave Kreskowiak 155
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,462
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,712


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 22 Jan 2014
Copyright © CodeProject, 1999-2014
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