You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by "Alvaro del Castillo (Jira)" <ji...@apache.org> on 2019/11/27 11:05:01 UTC

[jira] [Updated] (PLC4X-156) The unitId is hardcoded to 0 which is the broadcast id in modbus

     [ https://issues.apache.org/jira/browse/PLC4X-156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alvaro del Castillo updated PLC4X-156:
--------------------------------------
    Description: 
Trying to use the modbus driver, it is always trying to read and write from the slave 0 in the modbus slave/server. This identifier is the one used for broadcasting reads and writes to all the slaves in the modbus network. I have tested it with:

[https://pypi.org/project/pyModSlave|https://pypi.org/project/pyModSlave/]

[diagslave|https://www.modbusdriver.com/diagslave.html]

and in the second case, if you try to read a register:
{noformat}
2019-11-27 08:29:29,837 ERROR modbus.handle_request Thread-1 invalid request: Function 3 can not be broadcasted{noformat}
This unitId should be a param but if it must be hardcoded, changing it to *1* is a fix.

The unitId is defined in:

[https://github.com/apache/plc4x/blob/develop/plc4j/protocols/modbus/src/main/java/org/apache/plc4x/java/modbus/netty/Plc4XModbusProtocol.java#L92]

I have tested in 0.4.0 release that changing the unitId to *1* fixes the problem. I have attached the file with this minor modification.

I can send a PR if you find the fix useful.

Thanks!

 

 

  was:
Trying to use the modbus driver, it is always trying to read and write from the slave 0 in the modbus slave/server. This identifier is the one used for broadcasting reads and writes to all the slaves in the modbus network. I have tested it with:

[pyModSlave|[https://pypi.org/project/pyModSlave|https://pypi.org/project/pyModSlave/]]

[diagslave|https://www.modbusdriver.com/diagslave.html]

and in the second case, if you try to read a register:
{noformat}
2019-11-27 08:29:29,837 ERROR modbus.handle_request Thread-1 invalid request: Function 3 can not be broadcasted{noformat}
This unitId should be a param but if it must be hardcoded, changing it to *1* is a fix.

The unitId is defined in:

[https://github.com/apache/plc4x/blob/develop/plc4j/protocols/modbus/src/main/java/org/apache/plc4x/java/modbus/netty/Plc4XModbusProtocol.java#L92]

I have tested in 0.4.0 release that changing the unitId to *1* fixes the problem. I have attached the file with this minor modification.


I can send a PR if you find the fix useful.

Thanks!

 

 


> The unitId is hardcoded to 0 which is the broadcast id in modbus
> ----------------------------------------------------------------
>
>                 Key: PLC4X-156
>                 URL: https://issues.apache.org/jira/browse/PLC4X-156
>             Project: Apache PLC4X
>          Issue Type: Bug
>          Components: Driver-Modbus
>            Reporter: Alvaro del Castillo
>            Priority: Major
>         Attachments: Plc4XModbusProtocol.java
>
>
> Trying to use the modbus driver, it is always trying to read and write from the slave 0 in the modbus slave/server. This identifier is the one used for broadcasting reads and writes to all the slaves in the modbus network. I have tested it with:
> [https://pypi.org/project/pyModSlave|https://pypi.org/project/pyModSlave/]
> [diagslave|https://www.modbusdriver.com/diagslave.html]
> and in the second case, if you try to read a register:
> {noformat}
> 2019-11-27 08:29:29,837 ERROR modbus.handle_request Thread-1 invalid request: Function 3 can not be broadcasted{noformat}
> This unitId should be a param but if it must be hardcoded, changing it to *1* is a fix.
> The unitId is defined in:
> [https://github.com/apache/plc4x/blob/develop/plc4j/protocols/modbus/src/main/java/org/apache/plc4x/java/modbus/netty/Plc4XModbusProtocol.java#L92]
> I have tested in 0.4.0 release that changing the unitId to *1* fixes the problem. I have attached the file with this minor modification.
> I can send a PR if you find the fix useful.
> Thanks!
>  
>  



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