修复写字符串BUG
This commit is contained in:
parent
4251b781f9
commit
87f53c8949
@ -2,8 +2,8 @@ namespace Seyounth.Core.Extensions;
|
|||||||
|
|
||||||
public static class DateTimeExtensions
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -79,8 +79,8 @@ public class McPlc(string host, int port, Mitsubishi.McFrame type)
|
|||||||
// 将字符串使用 ASCII 编码转换为字节数组
|
// 将字符串使用 ASCII 编码转换为字节数组
|
||||||
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(value);
|
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(value);
|
||||||
// 确保字节数组长度为 10
|
// 确保字节数组长度为 10
|
||||||
byte[] fixedLengthBytes = new byte[fixedLength];
|
byte[] fixedLengthBytes = new byte[fixedLength*2];
|
||||||
Array.Copy(bytes, fixedLengthBytes, Math.Min(bytes.Length, fixedLength));
|
Array.Copy(bytes, fixedLengthBytes, Math.Min(bytes.Length, fixedLength*2));
|
||||||
// 调用 WriteBytesAsync 方法写入字节数组
|
// 调用 WriteBytesAsync 方法写入字节数组
|
||||||
await WriteBytesAsync(address, fixedLengthBytes);
|
await WriteBytesAsync(address, fixedLengthBytes);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user