Jump to content

Communication between C++ and COM port

RTX 3090

Hi, just wanted to ask a question

What is the easiest library to use to communicate with a COM port in C++. I am making a UI for a multimeter, which gives the following COM input

Quote

id_1:0.56

id_x: is the id of the probe, so you can measure multiple voltages at once. The number after that is the volts in this case 0.56

What I need to do is read the COM line, display the voltage in a GUI which I will make in qt designer, and then read the next line, and keep repeating and updating the voltage. I will also have other ID's e.g. for resistance, so I need to read the serial output from the COM port, but all the libraries I have found online look complicated and I want to know which one will be the easiest to implement. Thanks (btw I'm making the application for Windows)

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

34 minutes ago, RTX 3090 said:

btw I'm making the application for Windows

Eh, that makes things a bit more complicated, but this should work: https://github.com/wjwwood/serial

 

Haven't tested it though, with linux it's as easy as just reading the serial file as a regular text file, or using pyserial with python instead of cpp.

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, James Evens said:

Likley you don't need a additional library and can use the default one.

Which library is that though. If you could send me a link to the docs for it, I would greatly appreciate it, thanks

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, igormp said:

with linux it's as easy as just reading the serial file as a regular text file, or using pyserial with python instead of cpp.

unfortunately most people use windows, I want to use QT designer so python is not really an option

Please tag me @RTX 3090 so I can see your reply

Link to comment
Share on other sites

Link to post
Share on other sites

12 minutes ago, RTX 3090 said:

I want to use QT designer so python is not really an option

It is tho: https://www.qt.io/qt-for-python

qt has bindings for many languages.

 

Anyway, the lib I mentioned in my first post should hopefully work.

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to comment
Share on other sites

Link to post
Share on other sites

On 3/5/2021 at 6:09 PM, RTX 3090 said:

Hi, just wanted to ask a question

What is the easiest library to use to communicate with a COM port in C++. I am making a UI for a multimeter, which gives the following COM input

id_x: is the id of the probe, so you can measure multiple voltages at once. The number after that is the volts in this case 0.56

What I need to do is read the COM line, display the voltage in a GUI which I will make in qt designer, and then read the next line, and keep repeating and updating the voltage. I will also have other ID's e.g. for resistance, so I need to read the serial output from the COM port, but all the libraries I have found online look complicated and I want to know which one will be the easiest to implement. Thanks (btw I'm making the application for Windows)

For windows, the WIN32 api has supported COM ports since nearly forever:

https://www.xanthium.in/Serial-Port-Programming-using-Win32-API

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×