Skip to content

Commit 134040a

Browse files
author
Claudio Bosticco
committed
Added .NET Core 6.0 project
1 parent 3f1f609 commit 134040a

File tree

7 files changed

+5548
-3
lines changed

7 files changed

+5548
-3
lines changed

EasyModbus.sln

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29503.13
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32811.315
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyModbus_Net40", "EasyModbus\EasyModbus_Net40.csproj", "{7657FC4A-AEDF-4F17-B3E9-0D0DFB1CE23B}"
77
EndProject
@@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleAppStd", "ConsoleApp
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyModbus_V5.0", "EasyModbus_NET5\EasyModbus_V5.0.csproj", "{83AFFC60-BC95-46B1-861F-B1F80270FBFA}"
1717
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyModbus_Net60", "EasyModbus_Net60\EasyModbus_Net60.csproj", "{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}"
19+
EndProject
1820
Global
1921
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2022
Debug|Any CPU = Debug|Any CPU
@@ -331,12 +333,60 @@ Global
331333
{83AFFC60-BC95-46B1-861F-B1F80270FBFA}.Release|x64.Build.0 = Release|Any CPU
332334
{83AFFC60-BC95-46B1-861F-B1F80270FBFA}.Release|x86.ActiveCfg = Release|Any CPU
333335
{83AFFC60-BC95-46B1-861F-B1F80270FBFA}.Release|x86.Build.0 = Release|Any CPU
336+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
337+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
338+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|ARM.ActiveCfg = Debug|Any CPU
339+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|ARM.Build.0 = Debug|Any CPU
340+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|x64.ActiveCfg = Debug|Any CPU
341+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|x64.Build.0 = Debug|Any CPU
342+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|x86.ActiveCfg = Debug|Any CPU
343+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Debug|x86.Build.0 = Debug|Any CPU
344+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|Any CPU.ActiveCfg = Debug|Any CPU
345+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|Any CPU.Build.0 = Debug|Any CPU
346+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|ARM.ActiveCfg = Debug|Any CPU
347+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|ARM.Build.0 = Debug|Any CPU
348+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|x64.ActiveCfg = Debug|Any CPU
349+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|x64.Build.0 = Debug|Any CPU
350+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|x86.ActiveCfg = Debug|Any CPU
351+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial|x86.Build.0 = Debug|Any CPU
352+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|Any CPU.ActiveCfg = Debug|Any CPU
353+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|Any CPU.Build.0 = Debug|Any CPU
354+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|ARM.ActiveCfg = Debug|Any CPU
355+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|ARM.Build.0 = Debug|Any CPU
356+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|x64.ActiveCfg = Debug|Any CPU
357+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|x64.Build.0 = Debug|Any CPU
358+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|x86.ActiveCfg = Debug|Any CPU
359+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial1|x86.Build.0 = Debug|Any CPU
360+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|Any CPU.ActiveCfg = Debug|Any CPU
361+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|Any CPU.Build.0 = Debug|Any CPU
362+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|ARM.ActiveCfg = Debug|Any CPU
363+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|ARM.Build.0 = Debug|Any CPU
364+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|x64.ActiveCfg = Debug|Any CPU
365+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|x64.Build.0 = Debug|Any CPU
366+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|x86.ActiveCfg = Debug|Any CPU
367+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial2|x86.Build.0 = Debug|Any CPU
368+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|Any CPU.ActiveCfg = Debug|Any CPU
369+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|Any CPU.Build.0 = Debug|Any CPU
370+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|ARM.ActiveCfg = Debug|Any CPU
371+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|ARM.Build.0 = Debug|Any CPU
372+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|x64.ActiveCfg = Debug|Any CPU
373+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|x64.Build.0 = Debug|Any CPU
374+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|x86.ActiveCfg = Debug|Any CPU
375+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.DebugCommercial3|x86.Build.0 = Debug|Any CPU
376+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
377+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|Any CPU.Build.0 = Release|Any CPU
378+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|ARM.ActiveCfg = Release|Any CPU
379+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|ARM.Build.0 = Release|Any CPU
380+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|x64.ActiveCfg = Release|Any CPU
381+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|x64.Build.0 = Release|Any CPU
382+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|x86.ActiveCfg = Release|Any CPU
383+
{6BD5A885-D0A3-44C0-BF73-E2118519EAFE}.Release|x86.Build.0 = Release|Any CPU
334384
EndGlobalSection
335385
GlobalSection(SolutionProperties) = preSolution
336386
HideSolutionNode = FALSE
337387
EndGlobalSection
338388
GlobalSection(ExtensibilityGlobals) = postSolution
339-
SolutionGuid = {7628B1C9-8DDB-4DBD-A71D-D369A4A166DE}
340389
VisualSVNWorkingCopyRoot = .
390+
SolutionGuid = {7628B1C9-8DDB-4DBD-A71D-D369A4A166DE}
341391
EndGlobalSection
342392
EndGlobal
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace EasyModbus
6+
{
7+
public partial class ModbusClient
8+
{
9+
/*
10+
public enum DataType { Short = 0, UShort = 1, Long = 2, ULong = 3, Float = 4, Double = 5 };
11+
public object[] ReadHoldingRegisters(int startingAddress, int quantity, DataType dataType, RegisterOrder registerOrder)
12+
{
13+
int quantityToRead = quantity;
14+
if (dataType == DataType.Long | dataType == DataType.ULong | dataType == DataType.Float)
15+
quantityToRead = quantity * 2;
16+
if (dataType == DataType.Float)
17+
quantityToRead = quantity * 4;
18+
int[] response = this.ReadHoldingRegisters(startingAddress, quantityToRead);
19+
switch (dataType)
20+
{
21+
case DataType.Short: return response.Cast<object>().ToArray();
22+
break;
23+
default: return response.Cast<object>().ToArray();
24+
break;
25+
26+
}
27+
28+
29+
}
30+
*/
31+
}
32+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<AssemblyName>EasyModbus</AssemblyName>
8+
<RootNamespace>EasyModbus</RootNamespace>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
/*
2+
Copyright (c) 2018-2020 Rossmann-Engineering
3+
Permission is hereby granted, free of charge,
4+
to any person obtaining a copy of this software
5+
and associated documentation files (the "Software"),
6+
to deal in the Software without restriction,
7+
including without limitation the rights to use,
8+
copy, modify, merge, publish, distribute, sublicense,
9+
and/or sell copies of the Software, and to permit
10+
persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission
14+
notice shall be included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*/
24+
using System;
25+
using System.Runtime.Serialization;
26+
27+
namespace EasyModbus.Exceptions
28+
{
29+
/// <summary>
30+
/// Exception to be thrown if serial port is not opened
31+
/// </summary>
32+
public class SerialPortNotOpenedException : ModbusException
33+
{
34+
public SerialPortNotOpenedException()
35+
: base()
36+
{
37+
}
38+
39+
public SerialPortNotOpenedException(string message)
40+
: base(message)
41+
{
42+
}
43+
44+
public SerialPortNotOpenedException(string message, Exception innerException)
45+
: base(message, innerException)
46+
{
47+
}
48+
49+
protected SerialPortNotOpenedException(SerializationInfo info, StreamingContext context)
50+
: base(info, context)
51+
{
52+
}
53+
}
54+
55+
/// <summary>
56+
/// Exception to be thrown if Connection to Modbus device failed
57+
/// </summary>
58+
public class ConnectionException : ModbusException
59+
{
60+
public ConnectionException()
61+
: base()
62+
{
63+
}
64+
65+
public ConnectionException(string message)
66+
: base(message)
67+
{
68+
}
69+
70+
public ConnectionException(string message, Exception innerException)
71+
: base(message, innerException)
72+
{
73+
}
74+
75+
protected ConnectionException(SerializationInfo info, StreamingContext context)
76+
: base(info, context)
77+
{
78+
}
79+
}
80+
81+
/// <summary>
82+
/// Exception to be thrown if Modbus Server returns error code "Function code not supported"
83+
/// </summary>
84+
public class FunctionCodeNotSupportedException : ModbusException
85+
{
86+
public FunctionCodeNotSupportedException()
87+
: base()
88+
{
89+
}
90+
91+
public FunctionCodeNotSupportedException(string message)
92+
: base(message)
93+
{
94+
}
95+
96+
public FunctionCodeNotSupportedException(string message, Exception innerException)
97+
: base(message, innerException)
98+
{
99+
}
100+
101+
protected FunctionCodeNotSupportedException(SerializationInfo info, StreamingContext context)
102+
: base(info, context)
103+
{
104+
}
105+
}
106+
107+
/// <summary>
108+
/// Exception to be thrown if Modbus Server returns error code "quantity invalid"
109+
/// </summary>
110+
public class QuantityInvalidException : ModbusException
111+
{
112+
public QuantityInvalidException()
113+
: base()
114+
{
115+
}
116+
117+
public QuantityInvalidException(string message)
118+
: base(message)
119+
{
120+
}
121+
122+
public QuantityInvalidException(string message, Exception innerException)
123+
: base(message, innerException)
124+
{
125+
}
126+
127+
protected QuantityInvalidException(SerializationInfo info, StreamingContext context)
128+
: base(info, context)
129+
{
130+
}
131+
}
132+
133+
/// <summary>
134+
/// Exception to be thrown if Modbus Server returns error code "starting adddress and quantity invalid"
135+
/// </summary>
136+
public class StartingAddressInvalidException : ModbusException
137+
{
138+
public StartingAddressInvalidException()
139+
: base()
140+
{
141+
}
142+
143+
public StartingAddressInvalidException(string message)
144+
: base(message)
145+
{
146+
}
147+
148+
public StartingAddressInvalidException(string message, Exception innerException)
149+
: base(message, innerException)
150+
{
151+
}
152+
153+
protected StartingAddressInvalidException(SerializationInfo info, StreamingContext context)
154+
: base(info, context)
155+
{
156+
}
157+
}
158+
159+
/// <summary>
160+
/// Exception to be thrown if Modbus Server returns error code "Function Code not executed (0x04)"
161+
/// </summary>
162+
public class ModbusException : Exception
163+
{
164+
public ModbusException()
165+
: base()
166+
{
167+
}
168+
169+
public ModbusException(string message)
170+
: base(message)
171+
{
172+
}
173+
174+
public ModbusException(string message, Exception innerException)
175+
: base(message, innerException)
176+
{
177+
}
178+
179+
protected ModbusException(SerializationInfo info, StreamingContext context)
180+
: base(info, context)
181+
{
182+
}
183+
}
184+
185+
/// <summary>
186+
/// Exception to be thrown if CRC Check failed
187+
/// </summary>
188+
public class CRCCheckFailedException : ModbusException
189+
{
190+
public CRCCheckFailedException()
191+
: base()
192+
{
193+
}
194+
195+
public CRCCheckFailedException(string message)
196+
: base(message)
197+
{
198+
}
199+
200+
public CRCCheckFailedException(string message, Exception innerException)
201+
: base(message, innerException)
202+
{
203+
}
204+
205+
protected CRCCheckFailedException(SerializationInfo info, StreamingContext context)
206+
: base(info, context)
207+
{
208+
}
209+
}
210+
211+
}

0 commit comments

Comments
 (0)