The operating system I am working with is Windows 7. I am needing to grab data at certain intervals from a broadband card. This car sends data to two separate COM ports. COM 3 and COM 4. Every interval I will need to query the line of info on both serial ports and write them to a file.
How do I read from two COM ports? Do I have to use threading? Is it good practice opening both at the same time?
Take a look at this tutorial. If you open up the com port and then make a call to WaitComEvent in overlapped IO you’ll get a handle in the OVERLAPPED that can be used in WaitForMultipleObjects.
You should be able to do it in a single thread with the general outline below:
Heavily edited due to feedback from @JimRhodes