Answer the question
In order to leave comments, you need to log in
Serial port communication method?
In general, you need to exchange information with a remote device using the MODBUS protocol, this protocol involves sending commands and receiving a response. I will send a lot of commands. To work with the port I use QSerialPort. This class has a slot that accepts data. All that came to my mind and I implemented it before it was announced
enum{
some_comand, //нормальные имена отражающие суть
some_comand1,
// other comand
};
Answer the question
In order to leave comments, you need to log in
Look towards ready-made libraries:
libmodbus.org
www.freemodbus.org
If you write in C, then it's better to do something like in libmodbus.
If you write in C ++, you can build a class hierarchy for sending / receiving data.
If you are already using Qt / C ++, then perhaps it is better to make a certain hierarchy of package classes. The data can be wrapped in a QByteArray and convenient functions for working with the package can be implemented - its creation / formation and its reading / parsing. For quick debugging and expansion, it's worth it.
You can also look at the Qt Modbus module, if the version of Qt you are using allows.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question