# Conflicts:
#	NDSD-Screwdriver/FrmSetting.Designer.cs
#	NDSD-Screwdriver/FrmSetting.cs
master
SoulStar 3 months ago
commit e819063b5b

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D090275D-5272-4408-A97F-96DA24D568A4}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication</RootNamespace>
<AssemblyName>ConsoleApplication</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>C:\Program Files\IIS\Microsoft Web Deploy V3\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs"/>
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,84 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
namespace ConsoleApplication
{
internal class Program
{
static string GetTimestamp()
{
long milliseconds = DateTimeOffset.Now.ToUnixTimeMilliseconds();
return milliseconds.ToString();
}
static string GenerateMD5(string input)
{
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
return sb.ToString();
}
}
public static void Main(string[] args)
{
//创建 HttpClient 实例
using (HttpClient client = new HttpClient())
{
// 设置请求的基础地址
client.BaseAddress = new Uri("http://IP/jd/services/sendReceiveCollectionBag");
string timeStamp = GetTimestamp();
// 设置请求头
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("JD-MachineCode", "channel-machine-test-rk-001");
client.DefaultRequestHeaders.Add("JD-Timestamp", timeStamp);
client.DefaultRequestHeaders.Add("JD-Signature", GenerateMD5("channel-machine-test-rk-001" + timeStamp + "08F68F890E91838CE6C5D08347F17F58"));
object parameters = new object();
var jsonContent = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(parameters), Encoding.UTF8, "application/json");
// 选择请求方式
HttpResponseMessage response;
try
{
// 发送 POST 请求
response = client.PostAsync("/api/endpoint", jsonContent).GetAwaiter().GetResult();
// 处理响应
if (response.IsSuccessStatusCode)
{
string responseData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();;
Console.WriteLine("Response: " + responseData);
}
else
{
Console.WriteLine("Error: " + response.ReasonPhrase);
}
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
Thread.Sleep(-1);
}
}
}

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApplication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApplication")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("D090275D-5272-4408-A97F-96DA24D568A4")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -36,14 +36,14 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Chloe, Version=5.25.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.25.0\lib\net46\Chloe.dll</HintPath>
<Reference Include="Chloe, Version=5.26.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.26.0\lib\net46\Chloe.dll</HintPath>
</Reference>
<Reference Include="Chloe.Extension, Version=5.25.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.Extension.5.25.0\lib\net46\Chloe.Extension.dll</HintPath>
</Reference>
<Reference Include="Chloe.SQLite, Version=5.25.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.25.0\lib\net46\Chloe.SQLite.dll</HintPath>
<Reference Include="Chloe.SQLite, Version=5.26.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.26.0\lib\net46\Chloe.SQLite.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -64,5 +64,8 @@
<Compile Include="SqlLiteTool.cs" />
<Compile Include="Student.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Chloe" version="5.26.0" targetFramework="net48" />
<package id="Chloe.SQLite" version="5.26.0" targetFramework="net48" />
</packages>

Binary file not shown.

@ -21,6 +21,10 @@
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Chloe" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.26.0.0" newVersion="5.26.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -14,6 +14,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NDSD_TouchSocket;
using NewLife;
using TouchSocket.Core;
namespace NDSD_Screwdriver
{
@ -24,8 +27,15 @@ namespace NDSD_Screwdriver
public FrmSetting()
{
InitializeComponent();
var body = "00 03 08 E0 04 01 50 B8 C1 39 3A".ToHex();
var ssss = CRC16.ToModbus(body).ToHex(" ");
SqlLiteTool.CreateTable(AppTool.GetDb());
Init();
}

@ -33,26 +33,50 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Chloe, Version=5.25.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.25.0\lib\net46\Chloe.dll</HintPath>
<Reference Include="Chloe, Version=5.26.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.26.0\lib\net46\Chloe.dll</HintPath>
</Reference>
<Reference Include="Chloe.SQLite, Version=5.25.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.25.0\lib\net46\Chloe.SQLite.dll</HintPath>
<Reference Include="Chloe.SQLite, Version=5.26.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.26.0\lib\net46\Chloe.SQLite.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="mscorlib" />
<Reference Include="NewLife.Core, Version=10.10.2024.803, Culture=neutral, PublicKeyToken=8343210f0b524456, processorArchitecture=MSIL">
<HintPath>..\packages\NewLife.Core.10.10.2024.803\lib\net461\NewLife.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nModbusPC">
<HintPath>..\Dll\nmodbuspc.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>..\Dll\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Ports, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Ports.8.0.0\lib\net462\System.IO.Ports.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
@ -66,6 +90,12 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.2.1.0-rc.10\lib\net472\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.2.1.0-rc.10\lib\net472\TouchSocket.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AppTool.cs" />
@ -92,6 +122,10 @@
<DependentUpon>ScrewdriverTest.cs</DependentUpon>
</Compile>
<Compile Include="FormUtils.cs" />
<Compile Include="TestDataFactory.cs" />
<Compile Include="Tool\hfIIReader.cs" />
<Compile Include="Tool\HFIIREADER_PARAMS.cs" />
<Compile Include="Tool\SerialPortFactory.cs" />
<EmbeddedResource Include="FrmSetting.resx">
<DependentUpon>FrmSetting.cs</DependentUpon>
</EmbeddedResource>
@ -140,6 +174,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="ndsd.db" />
<Content Include="read.json" />
<Content Include="x64\SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
@ -147,5 +182,8 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.2.1.0-rc.10\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace NDSD_Screwdriver
{
public class TestDataFactory
{
/// <summary>
/// 获取Rfid的数据
/// </summary>
/// <returns></returns>
public static List<string> GetRfidList()
{
List<string> ls = new List<string>
{
"E0040150B8C12108",
"E0040150B8C1393A",
"E0040150B8C0512F",
"E0040150B8C170F6",
"E0040150B8C12100"
};
return ls;
}
}
}

@ -0,0 +1,49 @@
using System.Runtime.InteropServices;
namespace NDSD_Screwdriver.Tool
{
// Token: 0x02000002 RID: 2
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct HFIIREADER_PARAMS
{
// Token: 0x04000001 RID: 1
public ushort addr;
// Token: 0x04000002 RID: 2
public ushort br;
// Token: 0x04000003 RID: 3
public ushort afiMode;
// Token: 0x04000004 RID: 4
public ushort invtTo;
// Token: 0x04000005 RID: 5
public ushort trgMode;
// Token: 0x04000006 RID: 6
public ushort opTagMode;
// Token: 0x04000007 RID: 7
public ushort opBlockRegAddr;
// Token: 0x04000008 RID: 8
public ushort opBlockRegNum;
// Token: 0x04000009 RID: 9
public ushort trgTimerTick;
// Token: 0x0400000A RID: 10
public ushort opFormat;
// Token: 0x0400000B RID: 11
public ushort frameHead;
// Token: 0x0400000C RID: 12
public ushort keppTimer;
// Token: 0x0400000D RID: 13
public ushort tagType;
}
}

@ -0,0 +1,58 @@
using System.IO.Ports;
namespace NDSD_Screwdriver.Tool
{
public class SerialPortFactory
{
private SerialPort serialPortModbus;
private hfIIReader reader;
public SerialPortFactory(string portName="COM13")
{
reader = new hfIIReader();
serialPortModbus = new SerialPort();
serialPortModbus.BaudRate = 9600;
serialPortModbus.PortName = portName;
serialPortModbus.ReadTimeout = 0;
}
public string Read()
{
if (!serialPortModbus.IsOpen)
{
serialPortModbus.Open();
var b= reader.Connect(serialPortModbus, 2000, 0);
}
string str2 = "";
ushort[] array6 = reader.ReadTagMemory(ref str2, 28, 4);
string text6 = "";
for (int j = 0; j < 4; j += 1)
{
text6 += array6[j].ToString("X").PadLeft(4, '0');
if (text6.Length > 0)
{
text6 += "";
}
}
return text6;
}
public void Disconnect()
{
if (!serialPortModbus.IsOpen)
{
serialPortModbus.Close();
}
reader.Disconnect();
}
}
}

File diff suppressed because it is too large Load Diff

@ -1,7 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Chloe" version="5.25.0" targetFramework="net48" />
<package id="Chloe.SQLite" version="5.25.0" targetFramework="net48" />
<package id="Chloe" version="5.26.0" targetFramework="net48" />
<package id="Chloe.SQLite" version="5.26.0" targetFramework="net48" />
<package id="NewLife.Core" version="10.10.2024.803" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.IO.Ports" version="8.0.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="TouchSocket" version="2.1.0-rc.10" targetFramework="net48" />
<package id="TouchSocket.Core" version="2.1.0-rc.10" targetFramework="net48" />
</packages>

@ -0,0 +1,2 @@
00 03 08 E0 04 01 50 B8 C0 51 2F 43 AE
00 03 00 1C 00 04 84 1E

@ -31,6 +31,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="NewLife.Core, Version=10.10.2024.803, Culture=neutral, PublicKeyToken=8343210f0b524456, processorArchitecture=MSIL">
<HintPath>..\packages\NewLife.Core.10.10.2024.803\lib\net461\NewLife.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\NDSD-Screwdriver\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
@ -39,6 +43,11 @@
<HintPath>..\NDSD-Screwdriver\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Ports, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Ports.8.0.0\lib\net462\System.IO.Ports.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\NDSD-Screwdriver\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
@ -47,11 +56,16 @@
<HintPath>..\NDSD-Screwdriver\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\NDSD-Screwdriver\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\NDSD-Screwdriver\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -59,10 +73,10 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.2.1.0-rc.9\lib\net472\TouchSocket.dll</HintPath>
<HintPath>..\packages\TouchSocket.2.1.0-rc.10\lib\net472\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.2.1.0-rc.9\lib\net472\TouchSocket.Core.dll</HintPath>
<HintPath>..\packages\TouchSocket.Core.2.1.0-rc.10\lib\net472\TouchSocket.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -77,7 +91,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.2.1.0-rc.9\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Core.2.1.0-rc.10\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -52,6 +52,8 @@ namespace NDSD_TouchSocket
}
return builder.ToString().Trim();
}
}
public static class CRC16
@ -129,5 +131,40 @@ namespace NDSD_TouchSocket
return (uchCRCHi << 8) | uchCRCLo; // 返回校验值
}
/// <summary>
/// CRC16_Modbus效验
/// </summary>
/// <param name="byteData">要进行计算的字节数组</param>
/// <returns>计算后的数组</returns>
public static byte[] ToModbus(byte[] byteData)
{
byte[] CRC = new byte[2];
UInt16 wCrc = 0xFFFF;
for (int i = 0; i < byteData.Length; i++)
{
wCrc ^= Convert.ToUInt16(byteData[i]);
for (int j = 0; j < 8; j++)
{
if ((wCrc & 0x0001) == 1)
{
wCrc >>= 1;
wCrc ^= 0xA001;//异或多项式
}
else
{
wCrc >>= 1;
}
}
}
CRC[1] = (byte)((wCrc & 0xFF00) >> 8);//高位在后
CRC[0] = (byte)(wCrc & 0x00FF); //低位在前
return CRC;
}
}
}

@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NewLife.Core" version="10.10.2024.803" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.IO.Ports" version="8.0.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="TouchSocket" version="2.1.0-rc.9" targetFramework="net48" />
<package id="TouchSocket.Core" version="2.1.0-rc.9" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="TouchSocket" version="2.1.0-rc.10" targetFramework="net48" />
<package id="TouchSocket.Core" version="2.1.0-rc.10" targetFramework="net48" />
</packages>
Loading…
Cancel
Save