Explorar el Código

写了点测试报告,增加了提升单数个寄存器读取效率的功能

deepseek
ywh hace 1 mes
padre
commit
d49b1f3663
Se han modificado 5 ficheros con 20 adiciones y 6 borrados
  1. BIN
      Document/my_document/测试大纲.docx
  2. BIN
      Document/my_document/测试报告.docx
  3. +3
    -3
      EWARM/Modbus.ewp
  4. +17
    -3
      Modbus/Src/modbus_rtu_slave.c
  5. BIN
      Touchwin/工程11.txp

BIN
Document/my_document/测试大纲.docx Ver fichero


BIN
Document/my_document/测试报告.docx Ver fichero


+ 3
- 3
EWARM/Modbus.ewp Ver fichero

@@ -286,7 +286,7 @@
<option> <option>
<name>CCAllowList</name> <name>CCAllowList</name>
<version>1</version> <version>1</version>
<state>11111110</state>
<state>00000000</state>
</option> </option>
<option> <option>
<name>CCDebugInfo</name> <name>CCDebugInfo</name>
@@ -382,7 +382,7 @@
</option> </option>
<option> <option>
<name>CCOptLevel</name> <name>CCOptLevel</name>
<state>3</state>
<state>0</state>
</option> </option>
<option> <option>
<name>CCOptStrategy</name> <name>CCOptStrategy</name>
@@ -391,7 +391,7 @@
</option> </option>
<option> <option>
<name>CCOptLevelSlave</name> <name>CCOptLevelSlave</name>
<state>3</state>
<state>0</state>
</option> </option>
<option> <option>
<name>CompilerMisraRules98</name> <name>CompilerMisraRules98</name>


+ 17
- 3
Modbus/Src/modbus_rtu_slave.c Ver fichero

@@ -301,26 +301,40 @@ static uint16_t ModbusProcessReadHolding(const uint8_t *request,uint16_t request
ModbusSlaveStatistics.illegalValueCount++; ModbusSlaveStatistics.illegalValueCount++;
return ModbusBuildException(request[1], MODBUS_EX_ILLEGAL_VALUE); return ModbusBuildException(request[1], MODBUS_EX_ILLEGAL_VALUE);
} }
if (ModbusAddressRangeIsValid(start, quantity) == 0U)//地址检查 if (ModbusAddressRangeIsValid(start, quantity) == 0U)//地址检查
{ {
if ((start >= 20000U) &&
(start < 25000U) &&
(quantity > 0U) &&
(quantity <= (25000U - start)))goto tx;
ModbusSlaveStatistics.illegalAddressCount++; ModbusSlaveStatistics.illegalAddressCount++;
return ModbusBuildException(request[1], MODBUS_EX_ILLEGAL_ADDRESS); return ModbusBuildException(request[1], MODBUS_EX_ILLEGAL_ADDRESS);
} }

tx:
ModbusTxFrame[0] = ModbusSlaveAddress; ModbusTxFrame[0] = ModbusSlaveAddress;
ModbusTxFrame[1] = 0X03; ModbusTxFrame[1] = 0X03;
ModbusTxFrame[2] = (uint8_t)(quantity * 2U); ModbusTxFrame[2] = (uint8_t)(quantity * 2U);


for (index = 0U; index < quantity; index++) for (index = 0U; index < quantity; index++)
{ {
value = ModbusHoldingRegisters[start + index];
uint16_t address = start + index;
/* D20000~D24999映射到D1、D3、D5……D9999 */
if (address >= 20000U)
{
address = (address - 20000U) * 2U + 1U;
}
value = ModbusHoldingRegisters[address];
ModbusTxFrame[3U + index * 2U] = (uint8_t)(value >> 8U); ModbusTxFrame[3U + index * 2U] = (uint8_t)(value >> 8U);
ModbusTxFrame[4U + index * 2U] = (uint8_t)(value & 0x00FFU); ModbusTxFrame[4U + index * 2U] = (uint8_t)(value & 0x00FFU);
} }


ModbusAppendCrc(ModbusTxFrame, (uint16_t)(3U + quantity * 2U)); ModbusAppendCrc(ModbusTxFrame, (uint16_t)(3U + quantity * 2U));
return (uint16_t)(5U + quantity * 2U); return (uint16_t)(5U + quantity * 2U);




} }


/** /**


BIN
Touchwin/工程11.txp Ver fichero


Cargando…
Cancelar
Guardar