mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-15 11:22:52 +00:00
Fix bug with writing too many bytes
This commit is contained in:
@@ -168,11 +168,11 @@ internal class Sharp7Connector: IDisposable
|
||||
EnsureSuccessOrThrow(result, $"Error writing {operand}{dbNo}:{startByteAddress} bit {bitAdress}");
|
||||
}
|
||||
|
||||
public async Task WriteBytes(Operand operand, ushort startByteAddress, byte[] data, ushort dbNo, CancellationToken token)
|
||||
public async Task WriteBytes(Operand operand, ushort startByteAddress, byte[] data, ushort dbNo, ushort bytesToWrite, CancellationToken token)
|
||||
{
|
||||
EnsureConnectionValid();
|
||||
|
||||
var result = await Task.Factory.StartNew(() => sharp7.WriteArea(operand.ToArea(), dbNo, startByteAddress, data.Length, S7WordLength.Byte, data), token, TaskCreationOptions.None, scheduler);
|
||||
var result = await Task.Factory.StartNew(() => sharp7.WriteArea(operand.ToArea(), dbNo, startByteAddress, bytesToWrite, S7WordLength.Byte, data), token, TaskCreationOptions.None, scheduler);
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
EnsureSuccessOrThrow(result, $"Error writing {operand}{dbNo}:{startByteAddress}.{data.Length}");
|
||||
|
||||
@@ -188,7 +188,7 @@ public class Sharp7Plc : IPlc
|
||||
{
|
||||
ValueConverter.WriteToBuffer(buffer, value, address);
|
||||
|
||||
await s7Connector.WriteBytes(address.Operand, address.Start, buffer, address.DbNo, token);
|
||||
await s7Connector.WriteBytes(address.Operand, address.Start, buffer, address.DbNo, address.BufferLength, token);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -295,7 +295,7 @@ public class Sharp7Plc : IPlc
|
||||
StartNotificationLoop();
|
||||
}
|
||||
|
||||
private async Task<Unit> GetAllValues(IS7Connector connector)
|
||||
private async Task<Unit> GetAllValues(Sharp7Connector connector)
|
||||
{
|
||||
if (multiVariableSubscriptions.ExistingKeys.IsEmpty())
|
||||
return Unit.Default;
|
||||
|
||||
Reference in New Issue
Block a user