Procházet zdrojové kódy

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

deepseek
ywh před 1 měsícem
rodič
revize
d49b1f3663
5 změnil soubory, kde provedl 20 přidání a 6 odebrání
  1. binární
      Document/my_document/测试大纲.docx
  2. binární
      Document/my_document/测试报告.docx
  3. +3
    -3
      EWARM/Modbus.ewp
  4. +17
    -3
      Modbus/Src/modbus_rtu_slave.c
  5. binární
      Touchwin/工程11.txp

binární
Document/my_document/测试大纲.docx Zobrazit soubor


binární
Document/my_document/测试报告.docx Zobrazit soubor


+ 3
- 3
EWARM/Modbus.ewp Zobrazit soubor

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


+ 17
- 3
Modbus/Src/modbus_rtu_slave.c Zobrazit soubor

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

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

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[4U + index * 2U] = (uint8_t)(value & 0x00FFU);
}

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




}

/**


binární
Touchwin/工程11.txp Zobrazit soubor


Načítá se…
Zrušit
Uložit