You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.2 KiB
C
83 lines
2.2 KiB
C
4 weeks ago
|
/*
|
||
|
* WeinbusSlave.h
|
||
|
*
|
||
|
* Author: Aleksey Gerasimenko
|
||
|
* gerasimenko.aleksey.n@gmail.com
|
||
|
*/
|
||
|
|
||
|
#include <math.h>
|
||
|
#include <stdint.h>
|
||
|
|
||
|
|
||
|
#include "WEINBUS/WeinbusDefines.h"
|
||
|
#include "WEINBUS/WeinbusBuffer.h"
|
||
|
#include "WEINBUS/WeinbusBufferRegister.h"
|
||
|
#include "WEINBUS/WeinbusBufferInputRegister.h"
|
||
|
#include "WEINBUS/WeinbusBufferOutputRegister.h"
|
||
|
#include "WEINBUS/WeinbusBufferCoil.h"
|
||
|
#include "WEINBUS/WeinbusBufferInputCoil.h"
|
||
|
#include "WEINBUS/WeinbusBufferOutputCoil.h"
|
||
|
|
||
|
#include "MODBUSRTU/ModbusRTUCRC.h"
|
||
|
#include "MODBUSRTU/ModbusRTUDefines.h"
|
||
|
|
||
|
|
||
|
|
||
|
#ifndef WEINBUS_WEINBUSSLAVE_H_
|
||
|
#define WEINBUS_WEINBUSSLAVE_H_
|
||
|
|
||
|
namespace WEINBUS
|
||
|
{
|
||
|
|
||
|
class WeinbusSlave
|
||
|
{
|
||
|
public:
|
||
|
// Function 0x01 read coil
|
||
|
//WEINBUS::WeinbusBufferOutputCoil outputCoils;
|
||
|
// Function 0x05, 0x0F write single/multiple coil
|
||
|
//WEINBUS::WeinbusBufferInputCoil inputCoils;
|
||
|
// Function 0x03 read register
|
||
|
WEINBUS::WeinbusBufferOutputRegister outputRegisters;
|
||
|
// Function 0x06, 0x10 write single/multiple register
|
||
|
WEINBUS::WeinbusBufferInputRegister inputRegisters;
|
||
|
public:
|
||
|
uint16_t rxStack[256];
|
||
|
uint16_t txStack[256];
|
||
|
uint16_t rxLength;
|
||
|
uint16_t txLength;
|
||
|
//
|
||
|
private:
|
||
|
uint16_t m_function;
|
||
|
REGISTER_16 m_start_address;
|
||
|
REGISTER_16 m_length;
|
||
|
REGISTER_32 m_value;
|
||
|
uint16_t m_counter;
|
||
|
uint16_t m_counter_length;
|
||
|
uint16_t m_point;
|
||
|
uint16_t m_cursor;
|
||
|
uint16_t m_byte_length;
|
||
|
uint16_t m_byte_counter;
|
||
|
private:
|
||
|
WEINBUS::WeinbusTableRegister m_aux_register;
|
||
|
private:
|
||
|
MODBUSRTU::ModbusRTUCRC& m_crc;
|
||
|
public:
|
||
|
WeinbusSlave(MODBUSRTU::ModbusRTUCRC& crc);
|
||
|
public:
|
||
|
void execute();
|
||
|
private:
|
||
|
inline void _function_broadcast();
|
||
|
inline void _function_read_coil_status();
|
||
|
inline void _function_read_input_status();
|
||
|
inline void _function_read_holding_registers();
|
||
|
inline void _function_read_input_registers();
|
||
|
inline void _function_force_single_coil();
|
||
|
inline void _function_preset_single_register();
|
||
|
inline void _function_force_multiple_coils();
|
||
|
inline void _function_preset_multiple_registers();
|
||
|
};
|
||
|
|
||
|
} /* namespace WEINBUS */
|
||
|
|
||
|
#endif /* WEINBUS_WEINBUSSLAVE_H_ */
|