From 0264ccd54ec76fde4bbddda33983a645797ecbc0 Mon Sep 17 00:00:00 2001 From: Razvalyaev Date: Thu, 6 Nov 2025 18:15:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20=D1=82=D0=B0?= =?UTF-8?q?=D0=B1=D1=83=D0=BB=D1=8F=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inc/__modbus_compat.h | 8 ++++---- Inc/modbus.h | 30 +++++++++++++++--------------- Inc/modbus_core.h | 8 ++++---- Src/__modbus_compat.c | 4 ++-- Src/modbus_slave.c | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Inc/__modbus_compat.h b/Inc/__modbus_compat.h index 9118837..67e1c6e 100644 --- a/Inc/__modbus_compat.h +++ b/Inc/__modbus_compat.h @@ -1,10 +1,10 @@ /** ************************************************************************** -* @file __modbus_compat.h -* @brief Модуль для совместимости библиотеки MODBUS. -************************************************************************** +* @file __modbus_compat.h +* @brief Модуль для совместимости библиотеки MODBUS. +************************************************************************** * @details Файл содержит API старых функций, а также заглушки для отключенных модулей: -******************************************************************************/ +*************************************************************************/ #include "modbus.h" diff --git a/Inc/modbus.h b/Inc/modbus.h index e9840a7..c8714da 100644 --- a/Inc/modbus.h +++ b/Inc/modbus.h @@ -41,21 +41,21 @@ RS_MsgTypeDef msg = MB_REQUEST_READ_HOLDING_REGS(1, 0, 10); MODBUS_MasterRequest(&hmodbus1, &msg, &callback_func); - void callback_func(RS_HandleTypeDef *hmodbus, RS_MsgTypeDef *modbus_msg) - { - // MB_RespGet_... Чтобы достать нужные данные из ответа - if(hmodbus->RS_STATUS == RS_OK) - { - for(int addr = MODBUS_MSG.Addr; addr < MODBUS_MSG.Addr + MODBUS_MSG.Qnt; addr++) - { - uint16_t value; - if(MB_RespGet_RegisterValue(&MODBUS_MSG, addr, &value)) - { - read_hold[i] = value; - } - } - } - } + void callback_func(RS_HandleTypeDef *hmodbus, RS_MsgTypeDef *modbus_msg) + { + // MB_RespGet_... Чтобы достать нужные данные из ответа + if(hmodbus->RS_STATUS == RS_OK) + { + for(int addr = MODBUS_MSG.Addr; addr < MODBUS_MSG.Addr + MODBUS_MSG.Qnt; addr++) + { + uint16_t value; + if(MB_RespGet_RegisterValue(&MODBUS_MSG, addr, &value)) + { + read_hold[i] = value; + } + } + } + } @endverbatim diff --git a/Inc/modbus_core.h b/Inc/modbus_core.h index d6d4a75..1e14879 100644 --- a/Inc/modbus_core.h +++ b/Inc/modbus_core.h @@ -174,11 +174,11 @@ typedef struct typedef struct // RS_MsgTypeDef { #ifdef MODBUS_PROTOCOL_TCP - uint16_t TransactionID; ///< Modbus TCP: ID Transaction - uint16_t ProtocolID; ///< Modbus TCP: ID Protocol - uint16_t PDULength; ///< Modbus TCP: PDU Length + uint16_t TransactionID; ///< Modbus TCP: ID Transaction + uint16_t ProtocolID; ///< Modbus TCP: ID Protocol + uint16_t PDULength; ///< Modbus TCP: PDU Length #endif - + uint8_t MbAddr; ///< Modbus Slave Address MB_FunctonTypeDef FuncCode; ///< Modbus Function Code MB_DevIdMsgTypeDef DevId; ///< Read Device Identifications Header struct diff --git a/Src/__modbus_compat.c b/Src/__modbus_compat.c index 9542f45..2c8e730 100644 --- a/Src/__modbus_compat.c +++ b/Src/__modbus_compat.c @@ -1,7 +1,7 @@ /** ************************************************************************** -* @file __modbus_compat.c -* @brief Модуль для совместимости библиотеки MODBUS. +* @file __modbus_compat.c +* @brief Модуль для совместимости библиотеки MODBUS. ************************************************************************** * @details Файл содержит API старых функций, а также заглушки для отключенных модулей: ******************************************************************************/ diff --git a/Src/modbus_slave.c b/Src/modbus_slave.c index 1f892ba..67ae099 100644 --- a/Src/modbus_slave.c +++ b/Src/modbus_slave.c @@ -336,7 +336,7 @@ RS_StatusTypeDef MB_Slave_Parse_Message(RS_HandleTypeDef *hmodbus, RS_MsgTypeDef //-----INFO ABOUT DATA/MESSAGE------- #ifdef MODBUS_PROTOCOL_TCP modbus_msg->TransactionID =modbus_uart_buff[ind++]<<8; - modbus_msg->TransactionID |=modbus_uart_buff[ind++]; + modbus_msg->TransactionID |=modbus_uart_buff[ind++]; modbus_msg->ProtocolID =modbus_uart_buff[ind++]<<8; modbus_msg->ProtocolID |=modbus_uart_buff[ind++];