From 4a5709a783bf39a1ac1a16f22d705aa9ea059b36 Mon Sep 17 00:00:00 2001 From: SikongJueluo Date: Thu, 10 Jul 2025 21:29:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E5=A6=82=E4=BF=AE=E5=A4=8D=E7=9A=84i2c=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Peripherals/I2cClient.cs | 2 +- server/src/UdpClientPool.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/Peripherals/I2cClient.cs b/server/src/Peripherals/I2cClient.cs index 14e65a1..893ae8b 100644 --- a/server/src/Peripherals/I2cClient.cs +++ b/server/src/Peripherals/I2cClient.cs @@ -123,7 +123,7 @@ public class I2c i2cData[i++] = item; } - var ret = await UDPClientPool.WriteAddr(this.ep, 2, I2cAddr.Write, data); + var ret = await UDPClientPool.WriteAddr(this.ep, 2, I2cAddr.Write, i2cData); if (!ret.IsSuccessful) { logger.Error($"Failed to write data to I2C FIFO: {ret.Error}"); diff --git a/server/src/UdpClientPool.cs b/server/src/UdpClientPool.cs index c8edc84..bbfeee4 100644 --- a/server/src/UdpClientPool.cs +++ b/server/src/UdpClientPool.cs @@ -458,7 +458,11 @@ public class UDPClientPool dataArray[(i * (256 * (32 / 8)))..] : dataArray[(i * (256 * (32 / 8)))..((i + 1) * (256 * (32 / 8)))]; - opts.BurstLength = ((byte)Math.Min(sendDataArray.Length / 4 - 1, 1)); + opts.BurstLength = ((byte)( + sendDataArray.Length % 4 == 0 ? + (sendDataArray.Length / 4) : + (sendDataArray.Length / 4) + 1 + )); ret = await UDPClientPool.SendAddrPackAsync(endPoint, new SendAddrPackage(opts)); if (!ret) return new(new Exception("Send 1st address package failed!"));