diff --git a/Seyounth.Core/Extensions/DateTimeExtensions.cs b/Seyounth.Core/Extensions/DateTimeExtensions.cs index 326190b..3b6736f 100644 --- a/Seyounth.Core/Extensions/DateTimeExtensions.cs +++ b/Seyounth.Core/Extensions/DateTimeExtensions.cs @@ -2,8 +2,8 @@ namespace Seyounth.Core.Extensions; public static class DateTimeExtensions { - public static int ToTimestamp(this DateTime dateTime) + public static long ToTimestamp(this DateTime dateTime) { - return (int)new DateTimeOffset(dateTime).ToUnixTimeSeconds(); + return new DateTimeOffset(dateTime).ToUnixTimeMilliseconds(); } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Core/Plc/McPlc.cs b/Seyounth.Hyosung.Core/Plc/McPlc.cs index b86f602..a7eb887 100644 --- a/Seyounth.Hyosung.Core/Plc/McPlc.cs +++ b/Seyounth.Hyosung.Core/Plc/McPlc.cs @@ -79,8 +79,8 @@ public class McPlc(string host, int port, Mitsubishi.McFrame type) // 将字符串使用 ASCII 编码转换为字节数组 byte[] bytes = System.Text.Encoding.ASCII.GetBytes(value); // 确保字节数组长度为 10 - byte[] fixedLengthBytes = new byte[fixedLength]; - Array.Copy(bytes, fixedLengthBytes, Math.Min(bytes.Length, fixedLength)); + byte[] fixedLengthBytes = new byte[fixedLength*2]; + Array.Copy(bytes, fixedLengthBytes, Math.Min(bytes.Length, fixedLength*2)); // 调用 WriteBytesAsync 方法写入字节数组 await WriteBytesAsync(address, fixedLengthBytes); }