[ 
https://issues.apache.org/jira/browse/PLC4X-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16990393#comment-16990393
 ] 

Alvaro del Castillo edited comment on PLC4X-159 at 12/7/19 8:30 AM:
--------------------------------------------------------------------

I have detected the error with 0.4.0 but I am testing it now against develop.

Firsts step is to start a modbus server to write to:
{code:java}
docker run --network=host panterdsd/diagslave:latest "-p 1502:502" -e 
"PROTOCOL=tcp"{code}
The code I am using to test it:
{code:java}
// Test write a coil: off because future does not return (on now for working in 
the fix)
PlcWriteRequest writeRequestCoil = client.getConnection().writeRequestBuilder()
  .addItem("randomCoilField", "coil:1", true).build();
if (true) {
  PlcWriteResponse writeResponseCoil = writeRequestCoil.execute().get(5, 
TimeUnit.SECONDS);
  System.out.println("Response " + writeResponseCoil);
}
{code}
I can reproduce the error:

 
{code:java}
 java.util.concurrent.TimeoutException
 at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1784)
 at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928)
 at 
com.thingso2.agent.plugins.modbus.services.ModbusTest.writeTest(ModbusTest.java:246)
 {code}
 but the data has been written:
{code:java}
Slave   0: writeCoils from 2, 1 references
{code}
 


was (Author: acs):
I have detected the error with 0.4.0 but I am testing it now against develop.

Firsts step is to start a modbus server to write to:
{code:java}
docker run --network=host panterdsd/diagslave:latest "-p 1502:502" -e 
"PROTOCOL=tcp"{code}
The code I am using to test it:
{code:java}
// Test write a coil: off because future does not return (on now for working in 
the fix)
PlcWriteRequest writeRequestCoil = client.getConnection().writeRequestBuilder()
  .addItem("randomCoilField", "coil:1", true).build();
if (true) {
  PlcWriteResponse writeResponseCoil = writeRequestCoil.execute().get(5, 
TimeUnit.SECONDS);
  System.out.println("Response " + writeResponseCoil);
}
{code}
I can reproduce the error:

 
{code:java}
 java.util.concurrent.TimeoutException
 at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1784)
 at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928)
 at 
com.thingso2.agent.plugins.modbus.services.ModbusTest.writeTest(ModbusTest.java:246)
 {code}
 

> modbus: Future which writes data correctly in modbus does not return
> --------------------------------------------------------------------
>
>                 Key: PLC4X-159
>                 URL: https://issues.apache.org/jira/browse/PLC4X-159
>             Project: Apache PLC4X
>          Issue Type: Bug
>          Components: Driver-Modbus
>            Reporter: Alvaro del Castillo
>            Assignee: Christofer Dutz
>            Priority: Major
>             Fix For: 0.6.0
>
>
> When writing data registers in modbus, the data is written correctly but the 
> Future which does it does not return. The hack is just to not wait for the 
> Future because you don't need the results. Just that the data is written. But 
> if there are some error during the writing you don't know it. And probably 
> the resources are not freed correctly.
> Some sample code:
> {code:java}
> PlcWriteRequest writeRequest =  connection.writeRequestBuilder()
>   .addItem(registerName, "register:" + offset + "[" + size + "]", 
> writeRegister)
>   .build();
> writeRequest.execute().whenComplete((writeResponse, error) -> {
>   assertNotNull(writeResponse);
> });
> {code}
> The whenComplete is never called. I have follow the code and the "decode" 
> method is called, so it is when processing the response from the modbus slave 
> where the problem is.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to