Selaa lähdekoodia

移除exe测试项目,删除无用项目文件夹

master
zcn1123 4 vuotta sitten
vanhempi
commit
1dd92be828
13 muutettua tiedostoa jossa 0 lisäystä ja 960 poistoa
  1. +0
    -195
      Modbus_communication/RTU_Salve_test/3.ini
  2. +0
    -81
      Modbus_communication/RTU_Salve_test/RTU_Salve_test.vcxproj
  3. +0
    -42
      Modbus_communication/RTU_Salve_test/RTU_Salve_test.vcxproj.filters
  4. +0
    -106
      Modbus_communication/RTU_Salve_test/RTU_Test_Code.cpp
  5. +0
    -14
      Modbus_communication/RTU_Salve_test/RTU_Test_Code.h
  6. +0
    -9
      Modbus_communication/RTU_Salve_test/RTU_test.cpp
  7. +0
    -140
      Modbus_communication/TCP_Master_test/1.ini
  8. +0
    -127
      Modbus_communication/TCP_Master_test/2.ini
  9. +0
    -81
      Modbus_communication/TCP_Master_test/TCP_Master_test.vcxproj
  10. +0
    -42
      Modbus_communication/TCP_Master_test/TCP_Master_test.vcxproj.filters
  11. +0
    -9
      Modbus_communication/TCP_Master_test/TCP_Test.cpp
  12. +0
    -98
      Modbus_communication/TCP_Master_test/TCP_Test_Code.cpp
  13. +0
    -16
      Modbus_communication/TCP_Master_test/TCP_Test_Code.h

+ 0
- 195
Modbus_communication/RTU_Salve_test/3.ini Näytä tiedosto

@@ -1,195 +0,0 @@
[Example]
Number = 41

;0x01功能码正常读取响应
[Example1]
Input1 = "09 01 00 00 00 01 FC 82"
Output = "09 01 01 01 92 28"

[Example2]
Input1 = "09 01 00 00 00 0A BD 45"
Output = "09 01 02 FF 03 59 CC"

[Example3]
Input1 = "09 01 00 00 00 C8 3C D4"
Output = "09 01 19 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF D6 40"

[Example4]
Input1 = "09 01 00 00 07 D0 3E EE"
Output = "09 01 FA FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 8D BF"

;0x01功能码下03异常码响应
[Example5]
Input1 = "09 01 00 00 07 D1 FF 2E"
Output = "09 81 03 81 93"

[Example6]
Input1 = "09 01 00 00 00 00 3D 42"
Output = "09 81 03 81 93"

[Example7]
Input1 = "09 01 00 00 00 01 00 82 41"
Output = "09 81 03 81 93"

;0x01功能码下无响应
[Example8]
Input1 = "09 01 00 00 00 01 11 11"
Output = ""

[Example9]
Input1 = "08 01 00 00 00 01 FD 53"
Output = ""

;0x01功能码下02异常码
[Example10]
Input1 = "09 01 27 06 00 14 D7 F8"
Output = "09 81 02 40 53"


;0x03功能码正常读取响应样例
[Example11]
Input1 = "09 03 00 00 00 01 85 42"
Output = "09 03 02 FF FF 58 35"

[Example12]
Input1 = "09 03 00 00 00 64 45 69"
Output = "09 03 C8 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ED 8C"

[Example13]
Input1 = "09 03 00 00 00 7B 04 A1"
Output = "09 03 F6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 34 54"

[Example14]
Input1 = "09 03 00 00 00 7D 84 A3"
Output = "09 03 FA FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 70 F8"

;0x03功能码下03异常码响应
[Example15]
Input1 = "09 03 00 00 00 00 44 82"
Output = "09 83 03 80 F3"

[Example16]
Input1 = "09 03 00 00 00 7E C4 A2"
Output = "09 83 03 80 F3"

[Example17]
Input1 = "09 03 00 00 00 01 00 83 A3"
Output = "09 83 03 80 F3"

;0x03功能码下无响应
[Example18]
Input1 = "09 03 00 00 00 01 11 11"
Output = ""

[Example19]
Input1 = "08 03 00 00 00 01 84 93"
Output = ""

;0x03功能码下02异常码
[Example20]
Input1 = "09 03 27 06 00 14 AE 38"
Output = "09 83 02 41 33"






;0x0F正常写入样例
[Example21]
Input1 = "09 0F 00 00 00 01 01 01 EE F1"
Output = "09 0F 00 00 00 01 95 43"

[Example22]
Input1 = "09 0F 00 00 07 B0 F6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B8 78"
Output = "09 0F 00 00 07 B0 57 07"

;0x0F下03异常码样例
[Example23]
Input1 = "09 0F 00 00 00 00 54 83"
Output = "09 8F 03 85 F3"

[Example24]
Input1 = "09 0F 00 00 00 01 01 01 00 71 4C"
Output = "09 8F 03 85 F3"

[Example25]
Input1 = "09 0F 00 00 07 B1 F6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 DB"
Output = "09 8F 03 85 F3"

;0x0F下无响应
[Example26]
Input1 = "09 0F 00 00 00 01 01 01 11 F1"
Output = ""

[Example27]
Input1 = "08 0F 00 00 00 01 01 01 2F 3D"
Output = ""

;0x0F下02异常码
[Example28]
Input1 = "09 0F 27 06 00 14 03 02 FF FF 54 11"
Output = "09 8F 02 44 33"



;0x10下正常写入响应样例
[Example29]
Input1 = "09 10 00 00 00 01 02 00 00 C1 90"
Output = "09 10 00 00 00 01 00 81"

[Example30]
Input1 = "09 10 00 00 00 02 04 00 00 00 00 D9 CF"
Output = "09 10 00 00 00 02 40 80"

[Example31]
Input1 = "09 10 00 00 00 7B F6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CE 42"
Output = "09 10 00 00 00 7B 81 62"

;0x10下03异常码
[Example32]
Input1 = "09 10 00 00 00 00 C1 41"
Output = "09 90 03 8D C3"

[Example33]
Input1 = "09 10 00 00 00 01 02 00 00 00 51 90"
Output = "09 90 03 8D C3"

;0x10下无响应
[Example34]
Input1 = "09 10 00 00 00 01 02 01 01 11 11"
Output = ""

[Example35]
Input1 = "08 10 00 00 00 01 02 01 01 0C 50"
Output = ""

;0x10下02异常码
[Example36]
Input1 = "09 10 27 0F 00 02 04 00 00 00 00 26 7E"
Output = "09 90 02 4C 03"

[Example37]
Input1 = "09 10 27 06 00 14 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D9 BB"
Output = "09 90 02 4C 03"

;其他特殊样例
;设备ID+功能码+CRC
[Example38]
Input1 = "09 01 C6 20"
Output = ""
;只有设备ID+CRC
[Example39]
Input1 = "09 7F 46"
Output = ""
;只有设备ID
[Example40]
Input1 = "09"
Output = ""
;01异常码
[Example41]
Input1 = "09 02 00 00 00 01 B8 82"
Output = "09 82 01 00 A2"




+ 0
- 81
Modbus_communication/RTU_Salve_test/RTU_Salve_test.vcxproj Näytä tiedosto

@@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4443732F-F883-4E71-ACDD-E5E777C63728}</ProjectGuid>
<RootNamespace>RTU_Salve_test</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Modbus_RTU_Salve\common.cpp" />
<ClCompile Include="..\Modbus_RTU_Salve\RTU_Salve.cpp" />
<ClCompile Include="RTU_test.cpp" />
<ClCompile Include="RTU_Test_Code.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Modbus_RTU_Salve\common.h" />
<ClInclude Include="..\Modbus_RTU_Salve\RTU_Salve.h" />
<ClInclude Include="RTU_Test_Code.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

+ 0
- 42
Modbus_communication/RTU_Salve_test/RTU_Salve_test.vcxproj.filters Näytä tiedosto

@@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RTU_test.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="RTU_Test_Code.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\Modbus_RTU_Salve\common.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\Modbus_RTU_Salve\RTU_Salve.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RTU_Test_Code.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\Modbus_RTU_Salve\common.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\Modbus_RTU_Salve\RTU_Salve.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>

+ 0
- 106
Modbus_communication/RTU_Salve_test/RTU_Test_Code.cpp Näytä tiedosto

@@ -1,106 +0,0 @@
#include "RTU_Test_Code.h"

/*********************************************************************************************
* Function Test 1: Parsing Request Message
*********************************************************************************************/
void Parsing_Request_Message_Test(void)
{
char buf[LEN];
CString name = "Example";
char s[10] = "";
int Input1;
int j = 0;
int number = GetPrivateProfileInt(name, "Number", 0, TESTPATH3);
for (int i = 1; i < number + 1; i++)
{
memset(buf, 0, sizeof(buf));
memset(s, 0, sizeof(s));
_itoa_s(i, s, 10);
CString name1 = name + s;
Input1 = GetPrivateProfileString(name1, "Input1", "", buf, LEN, TESTPATH3);

UINT8 Requst_Message[300];
UINT8 Response_Message[300];
string Act_Message = buf;
const char *b = Act_Message.c_str();
unsigned int Act_len = 0;
for (unsigned int i = 0; i + 3 < Act_Message.length(); i = i + 3)
{
sscanf_s(b + i, "%02X", (int *)(Requst_Message + Act_len));
Act_len++;
}
sscanf_s(b + Act_Message.length() - 2, "%02X", (int *)(Requst_Message + Act_len));
//bool Create_Response_Message(UINT8 *Requst_Message, UINT8 *Response_Message, DWORD Read_len)
bool a = Create_Response_Message(Requst_Message, Response_Message, Act_len+1);
j++;
printf("%d---%d\n", j, a);
}
}

/*********************************************************************************************
* Function Test 2: Create Response Message
*********************************************************************************************/
void Create_Response_Message_Test(void)
{
char buf[LEN];
char buf1[LEN];
CString name = "Example";
char s[10] = "";
int Input1, Input2;
int number = GetPrivateProfileInt(name, "Number", 0, TESTPATH3);
Init_Coil_Register();
for (int i = 1; i < number + 1; i++)
{
memset(buf, 0, sizeof(buf));
memset(buf1, 0, sizeof(buf1));
memset(s, 0, sizeof(s));
_itoa_s(i, s, 10);
CString name1 = name + s;
Input1 = GetPrivateProfileString(name1, "Input1", "", buf, LEN, TESTPATH3);
Input2 = GetPrivateProfileString(name1, "Output", "", buf1, LEN, TESTPATH3);

UINT8 Request_Message[300];
memset(Request_Message, 0, 300);
string Act_Message = buf;
const char *b = Act_Message.c_str();
unsigned int Act_len = 0;
for (unsigned int i = 0; i + 3 < Act_Message.length(); i = i + 3)
{
sscanf_s(b + i, "%02X", (int *)(Request_Message + Act_len));
Act_len++;
}
sscanf_s(b + Act_Message.length() - 2, "%02X", (int *)(Request_Message + Act_len));


UINT8 Act_Response_Message[300];
memset(Act_Response_Message, 0, 300);
unsigned int Act_len1 = 0;
if (Input2 != 0)
{
string Act_Message1 = buf1;
const char *a = Act_Message1.c_str();
for (unsigned int i = 0; i + 3 < Act_Message1.length(); i = i + 3)
{
sscanf_s(a + i, "%02X", (int *)(Act_Response_Message + Act_len1));
Act_len1++;
}
sscanf_s(a + Act_Message1.length() - 2, "%02X", (int *)(Act_Response_Message + Act_len1));
}

UINT8 Response_Message[300];
memset(Response_Message, 0, 300);
Create_Response_Message(Request_Message, Response_Message, Act_len + 1);
printf("µÚ%d×éÑùÀý£º\n",i);
for (unsigned int j = 0; j < Act_len1 + 1; j++)
{
printf("%02X ", Act_Response_Message[j]);
}
printf("\n");
for (unsigned int m = 0; m < Act_len1 + 1; m++)
{
printf("%02X ", Response_Message[m]);
}
printf("\n");
printf("\n");
}
}

+ 0
- 14
Modbus_communication/RTU_Salve_test/RTU_Test_Code.h Näytä tiedosto

@@ -1,14 +0,0 @@
#ifndef __RTU_TEST_CODE_H
#define __RTU_TEST_CODE_H

#include "../Modbus_RTU_Salve/RTU_Salve.h"
#include <windows.h>
#include <atlstr.h>

#define TESTPATH3 "./3.ini"
#define LEN 65535

void Parsing_Request_Message_Test(void);
void Create_Response_Message_Test(void);

#endif

+ 0
- 9
Modbus_communication/RTU_Salve_test/RTU_test.cpp Näytä tiedosto

@@ -1,9 +0,0 @@
#include "RTU_Test_Code.h"

int main()
{
Parsing_Request_Message_Test();
Create_Response_Message_Test();
getchar();
return 0;
}

+ 0
- 140
Modbus_communication/TCP_Master_test/1.ini Näytä tiedosto

@@ -1,140 +0,0 @@
[Example]
Number = 19

;0x01
[Example1]
Input1 = 1
Input2 = 1
Input3 = 0
Input4 = ""
Output = "00 00 00 00 00 06 01 01 00 00 00 01"

[Example2]
Input1 = 1
Input2 = 155
Input3 = 1
Input4 = ""
Output = "00 01 00 00 00 06 01 01 00 01 00 9B"

[Example3]
Input1 = 1
Input2 = 1568
Input3 = 100
Input4 = ""
Output = "00 02 00 00 00 06 01 01 00 64 06 20"

[Example4]
Input1 = 1
Input2 = 2000
Input3 = 65535
Input4 = ""
Output = "00 03 00 00 00 06 01 01 FF FF 07 D0"

[Example5]
Input1 = 1
Input2 = 65535
Input3 = 300
Input4 = ""
Output = "00 04 00 00 00 06 01 01 01 2C FF FF"

[Example6]
Input1 = 1
Input2 = 65535
Input3 = 65535
Input4 = ""
Output = "00 05 00 00 00 06 01 01 FF FF FF FF"

;0x03
[Example7]
Input1 = 3
Input2 = 1
Input3 = 0
Input4 = ""
Output = "00 06 00 00 00 06 01 03 00 00 00 01"

[Example8]
Input1 = 3
Input2 = 100
Input3 = 1
Input4 = ""
Output = "00 07 00 00 00 06 01 03 00 01 00 64"

[Example9]
Input1 = 3
Input2 = 1122
Input3 = 100
Input4 = ""
Output = "00 08 00 00 00 06 01 03 00 64 04 62"

[Example10]
Input1 = 3
Input2 = 125
Input3 = 65535
Input4 = ""
Output = "00 09 00 00 00 06 01 03 FF FF 00 7D"

[Example11]
Input1 = 3
Input2 = 65535
Input3 = 300
Input4 = ""
Output = "00 0A 00 00 00 06 01 03 01 2C FF FF"

[Example12]
Input1 = 3
Input2 = 65535
Input3 = 65535
Input4 = ""
Output = "00 0B 00 00 00 06 01 03 FF FF FF FF"

;0x0F
[Example13]
Input1 = 15
Input2 = 1
Input3 = 0
Input4 = "01"
Output = "00 0C 00 00 00 08 01 0F 00 00 00 01 01 01"

[Example14]
Input1 = 15
Input2 = 100
Input3 = 1
Input4 = "01 01 01 01 01 01 01 01 01 01 01 01 01"
Output = "00 0D 00 00 00 14 01 0F 00 01 00 64 0D 01 01 01 01 01 01 01 01 01 01 01 01 01"

[Example15]
Input1 = 15
Input2 = 1968
Input3 = 100
Input4 = "FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
Output = "00 0E 00 00 00 FD 01 0F 00 64 07 B0 F6 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"

[Example16]
Input1 = 15
Input2 = 10
Input3 = 65535
Input4 = "55 03"
Output = "00 0F 00 00 00 09 01 0F FF FF 00 0A 02 55 03"

;0x0F
[Example17]
Input1 = 16
Input2 = 1
Input3 = 0
Input4 = "01 01"
Output = "00 10 00 00 00 09 01 10 00 00 00 01 02 01 01"

[Example18]
Input1 = 16
Input2 = 4
Input3 = 1
Input4 = "01 01 01 01 01 01 01 01"
Output = "00 11 00 00 00 0F 01 10 00 01 00 04 08 01 01 01 01 01 01 01 01"

[Example19]
Input1 = 16
Input2 = 123
Input3 = 65535
Input4 = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
Output = "00 12 00 00 00 FD 01 10 FF FF 00 7B F6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"


+ 0
- 127
Modbus_communication/TCP_Master_test/2.ini Näytä tiedosto

@@ -1,127 +0,0 @@
[Example]
Number = 27

;0x01正常读取响应解析样例
[Example1]
Input1 = "00 00 00 00 00 06 01 01 00 00 00 01"
Input2 = "00 00 00 00 00 04 01 01 01 00"

[Example2]
Input1 = "00 01 00 00 00 06 01 01 00 00 00 64"
Input2 = "00 01 00 00 00 10 01 01 0D 00 00 00 00 00 00 00 00 00 00 00 00 00"

[Example3]
Input1 = "00 03 00 00 00 06 01 01 00 00 07 D0"
Input2 = "00 03 00 00 00 FD 01 01 FA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"

;0x03正常读取响应解析样例
[Example4]
Input1 = "00 06 00 00 00 06 01 03 00 00 00 01"
Input2 = "00 06 00 00 00 05 01 03 02 00 00"

[Example5]
Input1 = "00 00 00 00 00 06 01 03 00 00 00 02"
Input2 = "00 00 00 00 00 07 01 03 04 00 00 00 00"

[Example6]
Input1 = "00 07 00 00 00 06 01 03 00 0A 00 0A"
Input2 = "00 07 00 00 00 17 01 03 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"

[Example7]
Input1 = "00 08 00 00 00 06 01 03 00 00 00 7D"
Input2 = "00 08 00 00 00 FD 01 03 FA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"

;0x0F正常写入响应解析样例
[Example8]
Input1 = "00 0A 00 00 00 08 01 0F 00 00 00 01 01 01"
Input2 = "00 0A 00 00 00 06 01 0F 00 00 00 01"

[Example9]
Input1 = "00 0B 00 00 00 14 01 0F 00 00 00 64 0D 00 00 00 00 00 00 00 00 00 00 00 00 00"
Input2 = "00 0B 00 00 00 06 01 0F 00 00 00 64"

[Example10]
Input1 = "00 0C 00 00 00 FD 01 0F 00 05 07 B0 F6 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
Input2 = "00 0C 00 00 00 06 01 0F 00 05 07 B0"

;0x10正常写入响应解析样例
[Example11]
Input1 = "00 0E 00 00 00 09 01 10 00 00 00 01 02 11 11"
Input2 = "00 0E 00 00 00 06 01 10 00 00 00 01"

[Example12]
Input1 = "00 0F 00 00 00 11 01 10 00 0A 00 05 0A 00 11 22 33 44 55 66 77 88 99"
Input2 = "00 0F 00 00 00 06 01 10 00 0A 00 05"

[Example13]
Input1 = "00 10 00 00 00 FD 01 10 00 64 00 7B F6 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
Input2 = "00 10 00 00 00 06 01 10 00 64 00 7B"

;异常响应样例
[Example14]
Input1 = "00 0E 00 00 00 08 01 0F 00 00 00 01 01 01"
Input2 = "00 0F 00 00 00 06 01 0F 00 00 00 01"

[Example15]
Input1 = "00 0E 00 00 00 08 01 0F 00 00 00 01 01 01"
Input2 = "00 0E 01 00 00 06 01 0F 00 00 00 01"

[Example16]
Input1 = "00 0E 00 00 00 08 01 0F 00 00 00 01 01 01"
Input2 = "00 0E 00 1E 00 06 01 0F 00 00 00 01"

[Example17]
Input1 = "00 0E 00 00 00 08 01 0F 00 00 00 01 01 01"
Input2 = "00 0E 00 00 11 06 01 0F 00 00 00 01"

[Example18]
Input1 = "00 0E 00 00 00 06 01 01 00 00 00 01"
Input2 = "00 0E 00 00 00 03 01 01 01 00"

[Example19]
Input1 = "00 0E 00 00 00 06 01 01 00 00 00 01"
Input2 = "00 0E 00 00 00 04 02 01 01 00"

[Example20]
Input1 = "00 0E 00 00 00 06 01 01 00 00 00 01"
Input2 = "00 0E 00 00 00 04 01 03 01 00"

[Example21]
Input1 = "00 0E 00 00 00 06 01 10 00 00 00 02 04 11 11 11 11"
Input2 = "00 0E 00 00 00 06 01 10 50 10 00 02"

[Example22]
Input1 = "00 0E 00 00 00 0B 01 10 00 00 00 02 04 11 11 11 11"
Input2 = "00 0E 00 00 00 06 01 10 00 00 01 02"

[Example23]
Input1 = "00 0E 00 00 00 06 01 03 00 00 00 02"
Input2 = "00 0E 00 00 00 07 01 03 02 11 11 11 11"

;异常码响应样例
[Example24]
Input1 = "00 0E 00 00 00 06 01 03 00 00 00 02"
Input2 = "00 0E 00 00 00 03 01 83 01"

[Example25]
Input1 = "00 0E 00 00 00 06 01 01 00 00 00 02"
Input2 = "00 0E 00 00 00 03 01 81 02"

[Example26]
Input1 = "00 0E 00 00 00 08 01 0F 00 00 00 02 01 00"
Input2 = "00 0E 00 00 00 03 01 8F 03"

[Example27]
Input1 = "00 0E 00 00 00 09 01 10 00 00 00 01 02 00 00"
Input2 = "00 0E 00 00 00 03 01 90 04"












+ 0
- 81
Modbus_communication/TCP_Master_test/TCP_Master_test.vcxproj Näytä tiedosto

@@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{677F6F19-D890-4DE8-9EFD-08FE0E154AD0}</ProjectGuid>
<RootNamespace>TCP_Master_test</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Modbus_TCP\common.cpp" />
<ClCompile Include="..\Modbus_TCP\TCP_client.cpp" />
<ClCompile Include="TCP_Test.cpp" />
<ClCompile Include="TCP_Test_Code.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Modbus_TCP\common.h" />
<ClInclude Include="..\Modbus_TCP\TCP_client.h" />
<ClInclude Include="TCP_Test_Code.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

+ 0
- 42
Modbus_communication/TCP_Master_test/TCP_Master_test.vcxproj.filters Näytä tiedosto

@@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TCP_Test.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="TCP_Test_Code.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\Modbus_TCP\common.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\Modbus_TCP\TCP_client.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TCP_Test_Code.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\Modbus_TCP\common.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\Modbus_TCP\TCP_client.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>

+ 0
- 9
Modbus_communication/TCP_Master_test/TCP_Test.cpp Näytä tiedosto

@@ -1,9 +0,0 @@
#include "TCP_Test_Code.h"

int main()
{
Generate_request_message_test();
Analysis_response_message_test();
getchar();
return 0;
}

+ 0
- 98
Modbus_communication/TCP_Master_test/TCP_Test_Code.cpp Näytä tiedosto

@@ -1,98 +0,0 @@
#include "TCP_Test_Code.h"

/*********************************************************************************************
* Function Test 1: Generate request message
*********************************************************************************************/
void Generate_request_message_test(void)
{
char buf[LEN];
char buf1[LEN];
CString name = "Example";
char s[10] = "";
int Output, Input1, Input2, Input3, Input4;

int number = GetPrivateProfileInt(name, "Number", 0, TESTPATH1);
for (int i = 1; i < number + 1; i++)
{
memset(buf, 0, sizeof(buf));
memset(buf1, 0, sizeof(buf1));
memset(s, 0, sizeof(s));
_itoa_s(i, s, 10);
CString name1 = name + s;
Input1 = GetPrivateProfileInt(name1, "Input1", 0, TESTPATH1);
Input2 = GetPrivateProfileInt(name1, "Input2", 0, TESTPATH1);
Input3 = GetPrivateProfileInt(name1, "Input3", 0, TESTPATH1);
Input4 = GetPrivateProfileString(name1, "Input4", "", buf, LEN, TESTPATH1);
Output = GetPrivateProfileString(name1, "Output", "", buf1, LEN, TESTPATH1);

UINT8 test_Message[300];
UINT8 Output_Message[300];
string Write_date = buf;
string Act_Message = buf1;
const char *b = Act_Message.c_str();
unsigned int Act_len = 0;
for (unsigned int i = 0; i + 3 < Act_Message.length(); i = i + 3)
{
sscanf_s(b + i, "%02X", (int *)(Output_Message + Act_len));
Act_len++;
}
sscanf_s(b + Act_Message.length() - 2, "%02X", (int *)(Output_Message + Act_len));
//int Create_TCP_Message(UINT8 *Message, int function_code, unsigned int operations_Number, unsigned int starting_address, string write_date);
int len = Create_TCP_Message(test_Message, Input1, Input2, Input3, Write_date);
for (int j = 0; j < len; j++)
{
if (test_Message[j] != Output_Message[j])
printf("--%d--loss--%d \n",i,j);
}

}
}

/*********************************************************************************************
* Function Test 2: Analysis response message
*********************************************************************************************/
void Analysis_response_message_test(void)
{
char buf[LEN];
char buf1[LEN];
CString name = "Example";
char s[10] = "";
int Input1, Input2;
int number = GetPrivateProfileInt(name, "Number", 0, TESTPATH2);
for (int i = 1; i < number + 1; i++)
{
memset(buf, 0, sizeof(buf));
memset(buf1, 0, sizeof(buf1));
memset(s, 0, sizeof(s));
_itoa_s(i, s, 10);
CString name1 = name + s;
Input1 = GetPrivateProfileString(name1, "Input1", "", buf, LEN, TESTPATH2);
Input2 = GetPrivateProfileString(name1, "Input2", "", buf1, LEN, TESTPATH2);

UINT8 Response_Message[300];
string Act_Message = buf1;
const char *b = Act_Message.c_str();
unsigned int Act_len = 0;
for (unsigned int i = 0; i + 3 < Act_Message.length(); i = i + 3)
{
sscanf_s(b + i, "%02X", (int *)(Response_Message + Act_len));
Act_len++;
}
sscanf_s(b + Act_Message.length() - 2, "%02X", (int *)(Response_Message + Act_len));


UINT8 Request_Message[300];
string Act_Message1 = buf;
const char *a = Act_Message1.c_str();
unsigned int Act_len1 = 0;
for (unsigned int i = 0; i + 3 < Act_Message1.length(); i = i + 3)
{
sscanf_s(a + i, "%02X", (int *)(Request_Message + Act_len1));
Act_len1++;
}
sscanf_s(a + Act_Message1.length() - 2, "%02X", (int *)(Request_Message + Act_len1));
Analysis_Response_Message(Response_Message, Request_Message, Act_len+1);
}
}



+ 0
- 16
Modbus_communication/TCP_Master_test/TCP_Test_Code.h Näytä tiedosto

@@ -1,16 +0,0 @@
#ifndef __TCP_TEST_CODE_H
#define __TCP_TEST_CODE_H

#include <stdio.h>
#include "../Modbus_TCP/common.h"
#include "../Modbus_TCP/TCP_client.h"
#include <windows.h>
#include <atlstr.h>

#define TESTPATH1 "./1.ini"
#define TESTPATH2 "./2.ini"
#define LEN 65535

void Generate_request_message_test(void);
void Analysis_response_message_test(void);
#endif

Ladataan…
Peruuta
Tallenna