39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
/*
|
|
* modbusSlave.h
|
|
*
|
|
* Created on: Oct 27, 2022
|
|
* Author: controllerstech.com
|
|
*/
|
|
|
|
#ifndef INC_MODBUSSLAVE_H_
|
|
#define INC_MODBUSSLAVE_H_
|
|
|
|
#include "main.h"
|
|
|
|
typedef union {
|
|
float value;
|
|
uint16_t u16[2];
|
|
} FloatToUint16;
|
|
uint32_t get_register_u32(uint16_t index);
|
|
void set_slaveid(uint8_t val);
|
|
uint8_t get_slaveid();
|
|
void set_register_range(uint16_t start, uint16_t size, uint16_t *buf);
|
|
void set_register_range_u8(uint16_t start, uint16_t size, uint8_t *buf);
|
|
void set_register_u32(uint16_t index, uint32_t value);
|
|
void set_register(uint16_t index, uint16_t value);
|
|
void set_register_float(uint16_t index, float value);
|
|
|
|
uint16_t get_register(uint16_t index);
|
|
void get_register_range(uint16_t start, uint16_t size, uint16_t *buf);
|
|
void get_register_range_to_u8(uint16_t start, uint16_t count, uint8_t *buf);
|
|
float get_register_float(uint16_t index);
|
|
|
|
uint8_t handleModbusRtu(uint8_t *rx_buf, uint8_t *tx_buf);
|
|
void handleModbusRtu_NEW(uint8_t *rx_buf, uint8_t *tx_buf, uint8_t rxSize, UART_HandleTypeDef *huart);
|
|
uint16_t handleModbusTcp(uint8_t* rx_buf, uint8_t* tx_buf);
|
|
uint16_t readHoldingRegs_tcp (uint8_t* rx_buf, uint8_t* tx_buf);
|
|
uint16_t writeSingleReg_tcp (uint8_t* rx_buf, uint8_t* tx_buf);
|
|
uint16_t writeMultiRegs_tcp (uint8_t* rx_buf, uint8_t* tx_buf);
|
|
|
|
#endif
|