Loading...
Searching...
No Matches
modbus_core.h File Reference

Ядро Modbus протокола - определения и структуры More...

`#include "modbus_config.h"`
`#include "modbus_data.h"`
`#include "__crc_algs.h"`
`#include "__modbus_compat.h"`
Include dependency graph for modbus_core.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes

struct | MB_DevIdMsgTypeDef
| Structure for device identifications message type. More...
struct | RS_MsgTypeDef
| Structure for modbus messsage. More...

## Macros

#define | TransactionID_size 2
| size of (Transaction ID)
#define | ProtocolID_size 2
| size of (Protocol ID)
#define | PDULength_size 2
| size of (PDU Length)
#define | MbAddr_SIZE 1
| size of (Slave Addr)
#define | Func_Code_SIZE 1
| size of (Function Code)
#define | Addr_SIZE 2
| size of (Address)
#define | Qnt_SIZE 2
| size of (Quantity)
#define | ByteCnt_SIZE 1
| size of (Byte Count)
#define | DATA_SIZE 125
| maximum number of data: DWORD (NOT MESSAGE SIZE)
#define | CRC_SIZE 2
| size of (MbCRC) in bytes
#define | INFO_SIZE_MAX (MbAddr_SIZE+Func_Code_SIZE+Addr_SIZE+Qnt_SIZE+ByteCnt_SIZE)
| Size of whole RTU message.
#define | RX_FIRST_PART_SIZE INFO_SIZE_MAX
| Size of first part of message that will be received first receive info part of message, than defines size of rest message.
#define | MSG_SIZE_MAX (INFO_SIZE_MAX + DATA_SIZE*2 + CRC_SIZE)
| Size of buffer: max size of whole message.
#define | FC_ERR_VALUES_START 0x80U
| from this value starts error func codes
#define | MB_Set_Arr16_Ptr(_arr_)
| Macros to set pointer to 16-bit array.
#define | MB_Set_Register_Ptr(_parr_, _addr_)
| Macros to set pointer to register.
#define | MB_Set_Coil_Reg_Ptr(_parr_, _coil_)
| Макрос для установки указателя на регистр, содержащий запрашиваемый коил
#define | MB_Set_Coil_Mask(_coil_)
| Макрос для установки маски, чтобы выделить запрашиваемый коил из регистра
#define | RegisterType_Holding 0
#define | RegisterType_Input 1
#define | RegisterType_Discrete 2

## Enumerations

enum | MB_ExceptionTypeDef { ET_NO_ERRORS = 0x00 , ET_ILLEGAL_FUNCTION = 0x01 , ET_ILLEGAL_DATA_ADDRESS = 0x02 , ET_ILLEGAL_DATA_VALUE = 0x03 , ET_SLAVE_DEVICE_FAILURE = 0x04 }
| Enum for modbus exception codes. More...

enum

MB_FunctonTypeDef {
FC_R_COILS = 0x01 , FC_R_DISC_IN = 0x02 , FC_R_HOLD_REGS = 0x03 , FC_R_IN_REGS = 0x04 ,
FC_W_COIL = 0x05 , FC_W_HOLD_REG = 0x06 , FC_W_COILS = 0x0F , FC_W_HOLD_REGS = 0x10 ,
FC_R_DIAGNOSTICS = 0x08 , FC_R_DEVICE_ID = 0x2B , FC_ERR_R_COILS = FC_R_COILS + FC_ERR_VALUES_START , FC_ERR_R_DISC_IN = FC_R_DISC_IN + FC_ERR_VALUES_START ,
FC_ERR_R_IN_REGS = FC_R_IN_REGS + FC_ERR_VALUES_START , FC_ERR_R_HOLD_REGS = FC_R_HOLD_REGS + FC_ERR_VALUES_START , FC_ERR_W_COIL = FC_W_COIL + FC_ERR_VALUES_START , FC_ERR_W_HOLD_REG = FC_W_HOLD_REG + FC_ERR_VALUES_START ,
FC_ERR_W_COILS = FC_W_COILS + FC_ERR_VALUES_START , FC_ERR_W_HOLD_REGS = FC_W_HOLD_REGS + FC_ERR_VALUES_START , FC_ERR_R_DIAGNOSTIC = FC_R_DIAGNOSTICS + FC_ERR_VALUES_START , FC_ERR_R_DEVICE_INFO = FC_R_DEVICE_ID + FC_ERR_VALUES_START
}

| Enum for modbus func codes. More...
enum | MB_MEITypeDef { MEI_DEVICE_IDENTIFICATIONS = 0x0E }
| Enum for MEI func codes. More...
enum | ReadDevId { RID_BASIC_IDENTIFICATIONS = 0x01 , RID_REGULAR_IDENTIFICATIONS = 0x02 , RID_EXTENDED_IDENTIFICATIONS = 0x03 , RID_SPEDIFIC_IDENTIFICATIONS = 0x04 }
| Enum for Read Device Id codes. More...

## Functions

MB_ExceptionTypeDef | MB_Check_Address_For_Arr (uint16_t Addr, uint16_t Qnt, uint16_t R_ARR_ADDR, uint16_t R_ARR_NUMB)
| Check is address valid for certain array.
MB_ExceptionTypeDef | MB_DefineRegistersAddress (uint16_t **pRegs, uint16_t Addr, uint16_t Qnt, uint8_t RegisterType)
| Define Address Origin for Input/Holding Registers.
MB_ExceptionTypeDef | MB_DefineCoilsAddress (uint16_t **pCoils, uint16_t Addr, uint16_t Qnt, uint16_t *start_shift, uint8_t WriteFlag)
| Define Address Origin for coils.

## Variables

RS_MsgTypeDef | MODBUS_MSG
| Default Message Struct for Modbus.

## Detailed Description

Ядро Modbus протокола - определения и структуры

Definition in file modbus_core.h.