Click here to Skip to main content
12,889,437 members (51,442 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ USB
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
Tushar Srivastava
Posted 11-Jan-12 7:11am
Updated 11-Jan-12 8:06am
Albert Holguin 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 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 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 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 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
Please Sign up or sign in to vote.

Solution 3

Rate this: bad
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.

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.
Rate this: bad
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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

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