mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
Fix V0.1.6 bit write to DB don't work #91
This commit is contained in:
@@ -6,7 +6,7 @@ namespace S7.Net.UnitTest.Helpers
|
||||
class S7TestServer
|
||||
{
|
||||
static S7Server Server;
|
||||
static private byte[] DB1 = new byte[512]; // Our DB1
|
||||
static private byte[] DB1 = new byte[1024]; // Our DB1
|
||||
static private byte[] DB2 = new byte[64000]; // Our DB2
|
||||
static private byte[] DB3 = new byte[1024]; // Our DB3
|
||||
|
||||
|
||||
@@ -455,6 +455,14 @@ namespace S7.Net.UnitTest
|
||||
plc.Write("DB1.DBX0.7", 0);
|
||||
boolVariable = (bool)plc.Read("DB1.DBX0.7");
|
||||
Assert.IsFalse(boolVariable);
|
||||
|
||||
plc.Write("DB1.DBX658.0", 1);
|
||||
boolVariable = (bool)plc.Read("DB1.DBX658.0");
|
||||
Assert.IsTrue(boolVariable);
|
||||
|
||||
plc.Write("DB2.DBX9658.0", 1);
|
||||
boolVariable = (bool)plc.Read("DB2.DBX9658.0");
|
||||
Assert.IsTrue(boolVariable);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -664,8 +672,8 @@ namespace S7.Net.UnitTest
|
||||
|
||||
Assert.AreEqual(expectedReadBytes, actualReadBytes);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
[TestMethod]
|
||||
public void T22_ReadClassWithArray()
|
||||
{
|
||||
Assert.IsTrue(plc.IsConnected, "Before executing this test, the plc must be connected. Check constructor.");
|
||||
|
||||
@@ -1136,7 +1136,7 @@ namespace S7.Net
|
||||
package.Add(Types.Word.ToByteArray((ushort)varCount));
|
||||
package.Add(Types.Word.ToByteArray((ushort)(db)));
|
||||
package.Add((byte)dataType);
|
||||
var overflow = (int)(startByteAdr * 8 + bitAdr / 0xffffU); // handles words with address bigger than 8191
|
||||
var overflow = (int)(startByteAdr * 8 / 0xffffU); // handles words with address bigger than 8191
|
||||
package.Add((byte)overflow);
|
||||
package.Add(Types.Word.ToByteArray((ushort)(startByteAdr * 8 + bitAdr)));
|
||||
package.Add(new byte[] { 0, 0x03 }); //ending 0x03 is used for writing a sinlge bit
|
||||
|
||||
Reference in New Issue
Block a user