forked from wirenboard/wb-mqtt-serial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodbus_common.h
30 lines (24 loc) · 863 Bytes
/
modbus_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include "port.h"
#include "serial_config.h"
#include "register.h"
#include <ostream>
#include <bitset>
#include <array>
namespace Modbus // modbus protocol common utilities
{
enum RegisterType {
REG_HOLDING = 0, // used for 'setup' regsb
REG_INPUT,
REG_COIL,
REG_DISCRETE,
REG_HOLDING_SINGLE,
REG_HOLDING_MULTI,
};
std::list<PRegisterRange> SplitRegisterList(const std::list<PRegister> & reg_list, PDeviceConfig deviceConfig, bool debug, bool enableHoles);
}; // modbus protocol common utilities
namespace ModbusRTU // modbus rtu protocol utilities
{
void WriteRegister(PPort port, uint8_t slaveId, PRegister reg, uint64_t value, int shift = 0);
void ReadRegisterRange(PPort port, uint8_t slaveId, PRegisterRange range, int shift = 0);
}; // modbus rtu protocol utilities