Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 11-Jan-12 8:06am
Comments
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...
Er. Tushar Srivastava 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.
Er. Tushar Srivastava 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).

 
Share this answer
 
v2
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]
 
Share this answer
 
v3
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.
 
Share this answer
 

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