2016-01-12 update 1
This commit is contained in:
@@ -60,7 +60,7 @@ namespace ModBus.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual byte[] SendReceive(params object[] content)
|
public virtual byte[] SendReceive(params object[] content)
|
||||||
{
|
{
|
||||||
return ProtocalLinker.SendReceive(ProtocalUnit.TranslateContent(content));
|
return AsyncHelper.RunSync(() => SendReceiveAsync(content));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -70,6 +70,10 @@ namespace ModBus.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual async Task<byte[]> SendReceiveAsync(params object[] content)
|
public virtual async Task<byte[]> SendReceiveAsync(params object[] content)
|
||||||
{
|
{
|
||||||
|
if (ProtocalLinker == null || !ProtocalLinker.IsConnected)
|
||||||
|
{
|
||||||
|
await ConnectAsync();
|
||||||
|
}
|
||||||
return await ProtocalLinker.SendReceiveAsync(ProtocalUnit.TranslateContent(content));
|
return await ProtocalLinker.SendReceiveAsync(ProtocalUnit.TranslateContent(content));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace ModBus.Net.Siemens
|
|||||||
|
|
||||||
public override async Task<byte[]> SendReceiveAsync(params object[] content)
|
public override async Task<byte[]> SendReceiveAsync(params object[] content)
|
||||||
{
|
{
|
||||||
while (!ProtocalLinker.IsConnected)
|
if (ProtocalLinker == null || !ProtocalLinker.IsConnected)
|
||||||
{
|
{
|
||||||
await ConnectAsync();
|
await ConnectAsync();
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ namespace ModBus.Net.Siemens
|
|||||||
|
|
||||||
public override async Task<OutputStruct> SendReceiveAsync(ProtocalUnit unit, InputStruct content)
|
public override async Task<OutputStruct> SendReceiveAsync(ProtocalUnit unit, InputStruct content)
|
||||||
{
|
{
|
||||||
if (!ProtocalLinker.IsConnected)
|
if (ProtocalLinker == null || !ProtocalLinker.IsConnected)
|
||||||
{
|
{
|
||||||
if (connectTryCount > 10) return null;
|
if (connectTryCount > 10) return null;
|
||||||
return await await ConnectAsync().ContinueWith(answer => answer.Result ? base.SendReceiveAsync(unit, content) : null);
|
return await await ConnectAsync().ContinueWith(answer => answer.Result ? base.SendReceiveAsync(unit, content) : null);
|
||||||
|
|||||||
Reference in New Issue
Block a user