Communicating with USB Port in C##
-
Would you please give me a simple example regard sending and receiving data by means of USB Port?
Mansureh Shahraki Moghaddam
Normally you don't talk to the USB port, you talk to a device that is connected via the USB. example: a USB printer uses a printer driver, you talk to that driver which presents itself as a printer (you don't have to be aware there is USB involved at all). same is true if you have a USB-to-RS232C cable, or a USB-to-Ethernet cable. When I bought my USB-to-serial cable, it came with a CD-ROM containing a driver. When I installed it, it turned the port into a regular serial port, so it shows up in all serial port enumerations, and most/all serial apps can use it, whether HyperTerminal or some .NET based app using SerialPort class. The app never is aware the USB-based serial port is connected in a different manner, all the nasty details are hidden by Windows and the device drivers. If the above does not satisfy you, you can build your own electronics target (say a microcontroller based design), give it a USB interface, an operating system and a USB driver; at PC side you would also need your own device driver so you can support read and write operations from and to your device. Most often it is not worth the effort, why reinvent the existing protocols as used on serial ports, Ethernet, etc? :)
Luc Pattyn [Forum Guidelines] [My Articles]
Happy 2008!
-
Normally you don't talk to the USB port, you talk to a device that is connected via the USB. example: a USB printer uses a printer driver, you talk to that driver which presents itself as a printer (you don't have to be aware there is USB involved at all). same is true if you have a USB-to-RS232C cable, or a USB-to-Ethernet cable. When I bought my USB-to-serial cable, it came with a CD-ROM containing a driver. When I installed it, it turned the port into a regular serial port, so it shows up in all serial port enumerations, and most/all serial apps can use it, whether HyperTerminal or some .NET based app using SerialPort class. The app never is aware the USB-based serial port is connected in a different manner, all the nasty details are hidden by Windows and the device drivers. If the above does not satisfy you, you can build your own electronics target (say a microcontroller based design), give it a USB interface, an operating system and a USB driver; at PC side you would also need your own device driver so you can support read and write operations from and to your device. Most often it is not worth the effort, why reinvent the existing protocols as used on serial ports, Ethernet, etc? :)
Luc Pattyn [Forum Guidelines] [My Articles]
Happy 2008!
Hi again, Here again I want to learn USB connection between a PC and a MCU. I know that there are some chips like FT232 or SDM-USB_QS-S that should be placed between PC and USB. As I know these chips are called USB-to RS232 drivers or converters. The thing I need to know is not about hardwired connection between PC USB cable and MCU. I need to know how to write a C# program to establish a send and receive pipe between the PC and the MCU. May you please help me again, as you helped me for serial port?
Sourie
-
Hi again, Here again I want to learn USB connection between a PC and a MCU. I know that there are some chips like FT232 or SDM-USB_QS-S that should be placed between PC and USB. As I know these chips are called USB-to RS232 drivers or converters. The thing I need to know is not about hardwired connection between PC USB cable and MCU. I need to know how to write a C# program to establish a send and receive pipe between the PC and the MCU. May you please help me again, as you helped me for serial port?
Sourie
Hi, if there is a USB-to-serial cable involved, it is a serial port for all intents and purposes to both the PC and the peripheral. Please reread my previous reply. if it is a strict USB connection (PCB-USB-microprocessor) without a serial port involved, then it requires special software on both sides. You may be lucky and get such software from your microprocessor vendor (i.e. both source code for the uP side, and a working driver for the PC side); if not, you would have to develop both, which seems unrealistic to me. For sure I would not do such thing. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|