Search code examples
c++ports

"How To" : Listen for data coming in via RS232 to USB


Language: C++ IDE: Microsoft Visual Studio 2010

Hardware setup: Machine[rs232]---> [rs232 to usb] ---> [usb]Computer

Data being sent: Result information as ascii text.

I am trying to access the ascii data that is coming in from the machine's rs232 port into the computer's usb port.

How do I open the connection and start listening for this data?

I have some experience with network programming, which was as simple as listening on the correct port# for packets from the server. But, I'm unsure what to do to listen for data coming in on usb or from rs232 for that matter... Very new to receiving data in this fashion.


Solution

  • The CreateFile and ReadFile APIs are used to open and read a serial port (even if it comes from USB). See the MSDN article titled "Serial Communications in Win32"