更新2026

This commit is contained in:
GukSang.Jin
2026-05-16 16:58:57 +08:00
parent c4966677b9
commit 9de217d2ff
15 changed files with 785 additions and 309 deletions

View File

@@ -80,6 +80,18 @@ namespace TabletTester2025.Services
await _master.WriteSingleRegisterAsync(_config.SlaveId, registerAddress, value);
}
public async Task WriteFloatAsync(ushort startAddress, float value)
{
await EnsureConnectedAsync();
byte[] bytes = BitConverter.GetBytes(value);
ushort[] registers =
{
(ushort)((bytes[2] << 8) | bytes[3]),
(ushort)((bytes[0] << 8) | bytes[1])
};
await _master.WriteMultipleRegistersAsync(_config.SlaveId, startAddress, registers);
}
public async Task<ushort[]> ReadHoldingRegistersAsync(ushort startAddress, ushort count)
{
await EnsureConnectedAsync();
@@ -120,4 +132,4 @@ namespace TabletTester2025.Services
await task;
}
}
}
}