mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2026-02-04 07:42:53 +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}");
|
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();
|
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();
|
token.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
EnsureSuccessOrThrow(result, $"Error writing {operand}{dbNo}:{startByteAddress}.{data.Length}");
|
EnsureSuccessOrThrow(result, $"Error writing {operand}{dbNo}:{startByteAddress}.{data.Length}");
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class Sharp7Plc : IPlc
|
|||||||
{
|
{
|
||||||
ValueConverter.WriteToBuffer(buffer, value, address);
|
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
|
finally
|
||||||
{
|
{
|
||||||
@@ -295,7 +295,7 @@ public class Sharp7Plc : IPlc
|
|||||||
StartNotificationLoop();
|
StartNotificationLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Unit> GetAllValues(IS7Connector connector)
|
private async Task<Unit> GetAllValues(Sharp7Connector connector)
|
||||||
{
|
{
|
||||||
if (multiVariableSubscriptions.ExistingKeys.IsEmpty())
|
if (multiVariableSubscriptions.ExistingKeys.IsEmpty())
|
||||||
return Unit.Default;
|
return Unit.Default;
|
||||||
|
|||||||
Reference in New Issue
Block a user