You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: S7.Net/PlcAsynchronous.cs
+100Lines changed: 100 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,34 @@ public async Task<byte[]> ReadBytesAsync(DataType dataType, int db, int startByt
122
122
returnresultBytes;
123
123
}
124
124
125
+
#if NET5_0_OR_GREATER
126
+
127
+
/// <summary>
128
+
/// Reads a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests.
129
+
/// If the read was not successful, check LastErrorCode or LastErrorString.
130
+
/// </summary>
131
+
/// <param name="buffer">Buffer to receive the read bytes. The <see cref="Memory{T}.Length"/> determines the number of bytes to read.</param>
132
+
/// <param name="dataType">Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output.</param>
133
+
/// <param name="db">Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc.</param>
134
+
/// <param name="startByteAdr">Start byte address. If you want to read DB1.DBW200, this is 200.</param>
135
+
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is None.
136
+
/// Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases.</param>
137
+
/// <returns>Returns the bytes in an array</returns>
/// Read and decode a certain number of bytes of the "VarType" provided.
127
155
/// This can be used to read multiple consecutive variables of the same type (Word, DWord, Int, etc).
@@ -320,6 +348,33 @@ public async Task WriteBytesAsync(DataType dataType, int db, int startByteAdr, b
320
348
}
321
349
}
322
350
351
+
#if NET5_0_OR_GREATER
352
+
353
+
/// <summary>
354
+
/// Write a number of bytes from a DB starting from a specified index. This handles more than 200 bytes with multiple requests.
355
+
/// If the write was not successful, check LastErrorCode or LastErrorString.
356
+
/// </summary>
357
+
/// <param name="dataType">Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output.</param>
358
+
/// <param name="db">Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc.</param>
359
+
/// <param name="startByteAdr">Start byte address. If you want to write DB1.DBW200, this is 200.</param>
360
+
/// <param name="value">Bytes to write. If more than 200, multiple requests will be made.</param>
361
+
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is None.
362
+
/// Please note that cancellation is advisory/cooperative and will not lead to immediate cancellation in all cases.</param>
363
+
/// <returns>A task that represents the asynchronous write operation.</returns>
/// Writes up to 200 bytes to the PLC. You must specify the memory area type, memory are address, byte start address and bytes count.
572
+
/// </summary>
573
+
/// <param name="dataType">Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output.</param>
574
+
/// <param name="db">Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc.</param>
575
+
/// <param name="startByteAdr">Start byte address. If you want to read DB1.DBW200, this is 200.</param>
576
+
/// <param name="value">Bytes to write. The lenght of this parameter can't be higher than 200. If you need more, use recursion.</param>
577
+
/// <returns>A task that represents the asynchronous write operation.</returns>
0 commit comments