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!"));