I am a free software developer, focused on embedded development.
Currently I work at Intel Corporation, as an embedded software developer, on the new secure IP inside latest Xeon CPU.
High level C++17 library for creating, manipulating, decoding and encoding Modbus protocol packets. It is designed to be used in cross platform environment, with ease of use in mind. Library is released under MIT license and can be freely used in any project. It serves as an alternative for Qt Modbus implementation, that is coupled with Qt framework.
To quickly learn about this library, please see the following C++ example:
#include <modbusRequest.hpp>
// Create simple request
MB::ModbusRequest request(1, MB::utils::ReadDiscreteOutputCoils, 100, 10);
std::cout << "Stringed Request: " << request.toString() << std::endl;
std::cout << "Raw request:" << std::endl;
// Get raw represenatation for request
std::vector<uint8_t> rawed = request.toRaw();
// Create CRC and pointer to its bytes
uint16_t CRC = MB::utils::calculateCRC(rawed);
auto CRCptr = reinterpret_cast<uint8_t *>(&CRC);
auto request1 = MB::ModbusRequest::fromRaw(rawed);
std::cout << "Stringed Request 1 after rawed: " << request1.toString() << std::endl;
// Add CRC to the end of raw request so that it can be loaded with CRC check
rawed.insert(rawed.end() , CRCptr, CRCptr + 2);
auto request2 = MB::ModbusRequest::fromRawCRC(rawed); // Throws on invalid CRC
std::cout << "Stringed Request 2 after rawed: " << request2.toString() << std::endl;