简体   繁体   中英

How to Read Register Map From COM serial port using Modbus Protocol? (c++)

I have a hardware device that connects to the computer's COM port using a usb to RS232 connector. It uses the Modbus RTU protocol. I'm trying to read the registers using C++ on Visual Studio, do I need an external library for this (if so where could I find one)? Or are there default libraries in C++ that can do this?

I've googled Modbus libraries for C++ but only found results for specific hardware like Arduino.

To write your own software that communicates with Modbus devices you need a library.

Libmodbus works very well. It's written in C but you can use it in C++. There is a Visual Studio project file included in the repo.

Otherwise, if you are familiar with Qt, you can take a look at this master example .

In case you don't want to start from scratch you can take a look at QModMaster , which uses libmodbus and Qt. If you want to start testing your device right away before you get busy coding you can download the binary files for Windows or compile the project with Qt Studio if you're on Linux.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM