From 87f53c8949f4067a508d1e171db075cd18f67afc Mon Sep 17 00:00:00 2001 From: anerx <512464164@qq.com> Date: Thu, 20 Mar 2025 21:54:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=99=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Seyounth.Core/Extensions/DateTimeExtensions.cs | 4 ++-- Seyounth.Hyosung.Core/Plc/McPlc.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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); }