mirror of
https://gitee.com/lircy/S7CommPlusV3Driver
synced 2026-06-06 09:58:18 +08:00
1. Added support for connecting to PLCs when "Only secure PG/PC and HMI communication" option is enabled
2. Fixed connection failure errors when PLC has "Only secure PG/PC and HMI communication" enabled 3. Fixed null reference errors when SessionKey is empty due to connection failures
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+22
-8
@@ -1,4 +1,6 @@
|
|||||||
|
//#define _TEST_BASIC_VAR
|
||||||
|
#define _TEST_PLCTAG
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -15,7 +17,7 @@ namespace DriverTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
string HostIp = "192.168.0.250";
|
string HostIp = "192.168.0.1";
|
||||||
string Password = "";
|
string Password = "";
|
||||||
int res;
|
int res;
|
||||||
List<ItemAddress> readlist = new List<ItemAddress>();
|
List<ItemAddress> readlist = new List<ItemAddress>();
|
||||||
@@ -31,9 +33,17 @@ namespace DriverTest
|
|||||||
Console.WriteLine("Main - Versuche Verbindungsaufbau zu: " + HostIp);
|
Console.WriteLine("Main - Versuche Verbindungsaufbau zu: " + HostIp);
|
||||||
|
|
||||||
S7CommPlusConnection conn = new S7CommPlusConnection();
|
S7CommPlusConnection conn = new S7CommPlusConnection();
|
||||||
|
conn.OnlySecurePGOrPCAndHMI = true;//Only secure PG/PC and HMI communication
|
||||||
|
System.Diagnostics.Stopwatch stopwatch1 = new System.Diagnostics.Stopwatch();
|
||||||
|
stopwatch1.Start();
|
||||||
res = conn.Connect(HostIp, Password);
|
res = conn.Connect(HostIp, Password);
|
||||||
|
stopwatch1.Stop();
|
||||||
|
Console.WriteLine($"PLCType: {conn.PLCInformation.PLCType} | MLFB: {conn.PLCInformation.MLFB} | Firmware: {conn.PLCInformation.Firmware}");
|
||||||
|
Console.WriteLine($"连接耗时{stopwatch1.ElapsedMilliseconds}ms.");
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("按任意键浏览变量");
|
||||||
|
Console.ReadKey();
|
||||||
Console.WriteLine("Main - Connect fertig");
|
Console.WriteLine("Main - Connect fertig");
|
||||||
|
|
||||||
#region Variablenhaushalt browsen
|
#region Variablenhaushalt browsen
|
||||||
@@ -43,7 +53,8 @@ namespace DriverTest
|
|||||||
res = conn.Browse(out vars);
|
res = conn.Browse(out vars);
|
||||||
Console.WriteLine("Main - Browse res=" + res);
|
Console.WriteLine("Main - Browse res=" + res);
|
||||||
#endregion
|
#endregion
|
||||||
List<VarInfo> vars_ = vars.GetRange(0,1000);
|
List<VarInfo> vars_ = vars.GetRange(0,50);
|
||||||
|
#if _TEST_PLCTAG
|
||||||
#region Werte aller Variablen einlesen
|
#region Werte aller Variablen einlesen
|
||||||
Console.WriteLine("Main - Lese Werte aller Variablen aus");
|
Console.WriteLine("Main - Lese Werte aller Variablen aus");
|
||||||
|
|
||||||
@@ -77,18 +88,20 @@ namespace DriverTest
|
|||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
while (res == 0)
|
while (res == 0)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
|
System.Diagnostics.Stopwatch stopwatch2 = new System.Diagnostics.Stopwatch();
|
||||||
stopwatch.Start();
|
stopwatch2.Start();
|
||||||
res = tags.ReadTags(conn);
|
res = tags.ReadTags(conn);
|
||||||
stopwatch.Stop();
|
stopwatch2.Stop();
|
||||||
long ms = stopwatch.ElapsedMilliseconds;
|
long ms = stopwatch2.ElapsedMilliseconds;
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
{
|
{
|
||||||
string header = $"读取{vars_.Count}个变量耗时{ms}毫秒";
|
string header = $"读取{vars_.Count}个变量耗时{ms}毫秒";
|
||||||
Console.WriteLine(header);
|
Console.WriteLine(header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _TEST_BASIC_VAR
|
||||||
#region Werte aller Variablen einlesen
|
#region Werte aller Variablen einlesen
|
||||||
Console.WriteLine("Main - Lese Werte aller Variablen aus");
|
Console.WriteLine("Main - Lese Werte aller Variablen aus");
|
||||||
|
|
||||||
@@ -123,6 +136,7 @@ namespace DriverTest
|
|||||||
Console.WriteLine("===============================================================");
|
Console.WriteLine("===============================================================");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#region Test: Wert schreiben
|
#region Test: Wert schreiben
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
SERVER_HANDSHAKE_TRAFFIC_SECRET 9d2884bb6d1ca343e259a23ffd195961228283a253916cb75661a90dbfa056f0 54afed328765987b013f17d3425b5ad139cd775ded5d8e9bd12fa96f93166508f793dca53267752de04c627218b51e4c
|
||||||
|
EXPORTER_SECRET 9d2884bb6d1ca343e259a23ffd195961228283a253916cb75661a90dbfa056f0 eaa6ef9882ce9d8c002ab41043f699f94d2a34fae101b9a2cd773dfdf7e6329acb65f2f6301c6894331bb62c35a63429
|
||||||
|
SERVER_TRAFFIC_SECRET_0 9d2884bb6d1ca343e259a23ffd195961228283a253916cb75661a90dbfa056f0 87149d68005b5512c6efbce24dcfb35146a4c49dcc2cc29d84294c566a45ee66b53df30eafea7c3f4070df9959d7f6be
|
||||||
|
CLIENT_HANDSHAKE_TRAFFIC_SECRET 9d2884bb6d1ca343e259a23ffd195961228283a253916cb75661a90dbfa056f0 d1d792a9d1a2f49dbda3f09b48a25de60192cef4434efd5cf51a61f73ce9e6d7c4f4dc466a6694a6d5612efd2773f784
|
||||||
|
CLIENT_TRAFFIC_SECRET_0 9d2884bb6d1ca343e259a23ffd195961228283a253916cb75661a90dbfa056f0 2238f875c69a7f5704c1792f3dec81b98af34d18643b467cccb730efc123c789632303c6e2c48dd2a397652ddfcf890a
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
SERVER_HANDSHAKE_TRAFFIC_SECRET ef29f3273eb4c3848fb8e869418198253bb70d55e234e55ed14bf4b4bab5c5b4 5c61d992793df1e85a7f6d9c3ffd27084373954871a262ccd827c65dc9a10b0fb8153392ced7cacdcb5c523d5eac9adb
|
||||||
|
EXPORTER_SECRET ef29f3273eb4c3848fb8e869418198253bb70d55e234e55ed14bf4b4bab5c5b4 97ed8911dac9e9e8543496c3ebf120a804da5fa88f70854e693a83db5b9f39d45a7c223f2782c6fc6943f18916c797f7
|
||||||
|
SERVER_TRAFFIC_SECRET_0 ef29f3273eb4c3848fb8e869418198253bb70d55e234e55ed14bf4b4bab5c5b4 3ca5d277257f1f536affba73730ec5561eb3654eddb53146e3935f79f3dde5d9b11220936506aa7c2806ba0fd3df065c
|
||||||
|
CLIENT_HANDSHAKE_TRAFFIC_SECRET ef29f3273eb4c3848fb8e869418198253bb70d55e234e55ed14bf4b4bab5c5b4 caf02ef79a590b2d9dd78149774174c4a305bc9255fb1df90c66f61e9445be5d74c43b2eff8be2aebfab27ca40751d3c
|
||||||
|
CLIENT_TRAFFIC_SECRET_0 ef29f3273eb4c3848fb8e869418198253bb70d55e234e55ed14bf4b4bab5c5b4 9d6d6cc9fc091479726907304d7c47d84e718db4b09319871d009dc7eb19c5795487528194c362708cd86faf4452f73b
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
dc7d04987a3dea6ec27cb7cd218eb8ff538ad9f0
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\obj\Debug\DriverTest.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\DriverTest.exe.config
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\DriverTest.exe
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\DriverTest.pdb
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\S7CommPlusDriver.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\S7PublicKeys.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\S7Utilities.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\zlib.net.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\S7CommPlusAuth.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\bin\Debug\S7Family0.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\obj\Debug\DriverTest.csproj.CopyComplete
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\obj\Debug\DriverTest.exe
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\obj\Debug\DriverTest.pdb
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\DriverTest\obj\Debug\DriverTest.csprojAssemblyReference.cache
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
ec14fa67cfbca0656c6c62f93ec1446787c52f00
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7CommPlusGUIBrowser.exe.config
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7CommPlusGUIBrowser.exe
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7CommPlusGUIBrowser.pdb
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7CommPlusDriver.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.csprojAssemblyReference.cache
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.Form1.resources
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.Properties.Resources.resources
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.csproj.GenerateResource.cache
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.csproj.CopyComplete
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.exe
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\obj\Debug\S7CommPlusGUIBrowser.pdb
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7PublicKeys.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7Utilities.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\zlib.net.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7CommPlusAuth.dll
|
||||||
|
C:\Users\ShenX\Desktop\DiscoverDevices\S7CommPlusV3Driver\S7CommPlusGUIBrowser\bin\Debug\S7Family0.dll
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user