liblightmodbus 3.0
A lightweight, header-only, hardware-agnostic Modbus RTU/TCP library
Loading...
Searching...
No Matches
lightmodbus.hpp File Reference

(Very) experimental liblightmodbus C++ interface More...

#include <stdexcept>
#include "lightmodbus.h"
+ Include dependency graph for lightmodbus.hpp:

Go to the source code of this file.

Data Structures

class  llm::RequestError
 Request error exception class. More...
 
class  llm::ResponseError
 Response error exception class. More...
 
class  llm::GeneralError
 General error exception class. More...
 
class  llm::Slave
 Represents a Modbus slave device. More...
 
class  llm::Master
 Represents a Modbus master device. More...
 

Namespaces

namespace  llm
 The liblightmodbus C++ namepsace.
 

Macros

#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(f_suffix, ...)    void buildRequest##f_suffix##PDU(__VA_ARGS__)
 
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY(f_suffix, ...)
 
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(f_suffix, ...)    void buildRequest##f_suffix##RTU(uint8_t address, __VA_ARGS__)
 
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY(f_suffix, ...)
 
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(f_suffix, ...)    void buildRequest##f_suffix##TCP(uint16_t transactionID, uint8_t unitID, __VA_ARGS__)
 
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY(f_suffix, ...)
 

Functions

static void llm::throwErrorInfo (ModbusErrorInfo err)
 Throws an exception based on ModbusErrorInfo.
 

Detailed Description

(Very) experimental liblightmodbus C++ interface

Warning
THIS INTERFACE IS EXPERIMENTAL, NOT TESTED AND MAY CHANGE AT ANY TIME.

Macro Definition Documentation

◆ LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY

#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY (   f_suffix,
  ... 
)
Value:
{ \
ModbusErrorInfo err = modbusBuildRequest##f_suffix##PDU(&m_master, __VA_ARGS__); \
m_ok = modbusIsOk(err); \
throwErrorInfo(err); \
}
static uint8_t modbusIsOk(ModbusErrorInfo err)
Checks if ModbusErrorInfo contains an error.
Definition base.h:442
Richer error represenation - source and type of error.
Definition base.h:126

◆ LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER

#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER (   f_suffix,
  ... 
)     void buildRequest##f_suffix##PDU(__VA_ARGS__)

◆ LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY

#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY (   f_suffix,
  ... 
)
Value:
{ \
ModbusErrorInfo err = modbusBuildRequest##f_suffix##RTU(&m_master, address, __VA_ARGS__); \
m_ok = modbusIsOk(err); \
throwErrorInfo(err); \
}

◆ LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER

#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER (   f_suffix,
  ... 
)     void buildRequest##f_suffix##RTU(uint8_t address, __VA_ARGS__)

◆ LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY

#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY (   f_suffix,
  ... 
)
Value:
{ \
ModbusErrorInfo err = modbusBuildRequest##f_suffix##TCP(&m_master, transactionID, unitID, __VA_ARGS__); \
m_ok = modbusIsOk(err); \
throwErrorInfo(err); \
}

◆ LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER

#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER (   f_suffix,
  ... 
)     void buildRequest##f_suffix##TCP(uint16_t transactionID, uint8_t unitID, __VA_ARGS__)