[Bug]: [Modbus TCP] Connection-level unit-identifier is not applied to read requests
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start by tracing how the Modbus TCP connection URL parses unit-identifier and how that value reaches plc4j read requests and generated holding-register tags. Compare the connection-level setting with the explicit {unit-id: 19} tag address shown in the report. Done means a tag without an explicit unit ID uses the configured default, or the documented behavior explains why it does not.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happened?
When using the Apache PLC4X Modbus TCP driver, configuring unit-identifier=19 in the connection URL does not appear to apply the configured Unit Identifier (Slave ID) to a read request.
The request works as expected when the Unit ID is explicitly specified in the tag address using {unit-id: 19}.
This behavior suggests that the connection-level Unit Identifier is not propagated to the generated Modbus tag or request, or that the configured default is not being applied as expected.
Environment
Driver: Apache PLC4X Modbus TCP Version 1.0.0
Protocol: Modbus TCP
Host: 10.10.121.55
Port: 502
Configured Unit Identifier: 19
Request timeout: 5000 ms
Default payload byte order: BIG_ENDIAN
Steps to Reproduce
- Configure the connection URL
String connectionUrl =
"modbus-tcp:tcp://10.10.121.55:502"
+ "?unit-identifier=19"
+ "&request-timeout=5000"
+ "&default-payload-byte-order=BIG_ENDIAN";
- Create a read request without an explicit Unit ID
PlcReadRequest request = connection.readRequestBuilder()
.addTagAddress("energy", "holding-register:29[0..1]:UINT")
.build();
- Observe the response and generated tag
The response contains:
response = [56741, 65535]
Tag: energy
Response code for energy: OK
response = ModbusTagHoldingRegister {
address=28,
quantity=2,
dataType=UINT,
unitId=null
}
The generated tag has unitId=null, despite the connection URL specifying unit-identifier=19.
The decoded energy value is:
Assembled Energy Value: 4294958501
- Specify the Unit ID explicitly in the tag address
Modify the request as follows:
PlcReadRequest request = connection.readRequestBuilder()
.addTagAddress(
"energy",
"holding-register:29[0..1]:UINT{unit-id: 19}"
)
.build();
Keep the same connection URL.
The response now contains:
response = [55121, 21]
Tag: energy
Response code for energy: OK
response = ModbusTagHoldingRegister {
address=28,
quantity=2,
dataType=UINT,
unitId=19
}
The assembled energy value is:
Assembled Energy Value: 1431377
The tag now correctly contains unitId=19, and the returned register values differ from those obtained when the tag's Unit ID is null.
Expected Behavior
When the connection URL contains:
unit-identifier=19
a read request created without an explicit unit-id in its tag address should use Unit Identifier 19, unless the documented API intentionally requires the Unit ID to be supplied per tag.
Actual Behavior
The connection URL contains unit-identifier=19, but the generated holding-register tag has:
unitId=null
The configured Unit Identifier appears to be ignored when creating the tag or preparing the request.
Adding the following explicitly to the tag address makes the tag use the expected Unit ID:
{unit-id: 19}
Impact
Applications communicating with Modbus TCP devices that require a specific Unit Identifier may read data from the wrong logical device or receive unexpected register values when relying on the connection-level configuration.
This also forces applications to specify the Unit ID repeatedly in tag addresses, even when it has already been configured in the connection URL.
Questions for the Maintainers
Is unit-identifier intended to act as the default Unit Identifier for all Modbus TCP requests created through a connection?
If so, why is the Unit ID not propagated to a tag when the tag address omits {unit-id: ...}?
Is this an implementation defect, or is the documented behavior that Unit ID must be specified per tag?
If this is a defect, could the connection-level Unit Identifier be applied as the default whenever a tag does not explicitly override it?
Version
v1.0.0
Programming Languages
- plc4c
- plc4go
- plc4j
- plc4net
- plc4py
Protocols
- AB-Ethernet
- ADS /AMS
- BACnet/IP
- C-Bus
- CANopen
- EtherNet/IP
- Firmata
- IEC-69870
- KNXnet/IP
- Modbus
- OPC-UA
- PLC4X
- Profinet
- S7
- Simulated
- SLMP
- UMAS
- Lenguaje dominante
- Java
- Estrellas
- 1.8k
- Forks
- 512
- Merge medio
- 2 d 2 h
- PR fusionados (30 d)
- 34
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/plc4x
-
[Bug]: eip.mspec formationAbiertoEthernet/IP java
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
apache/plc4x#2733 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Bug]: [Modbus] Support UDINT with least significant register first (little-endian word order)Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
Los mantenedores suelen responder en 1 día
-
[Bug]: TagBatch reuses a cached PlcReadRequest bound to a closed connection, so fetches fail after the first and never recover after a PLC restartPosiblemente ocupada @chrisdutz la tomó hace 3 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
apache/plc4x#2832 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Bug]: OPC-UA driver 1.0.0 fails against a certificate-less server even with security-policy=NONE (regression vs 0.13.1)Posiblemente ocupada @splatch la tomó hace 7 días. Abierto
apache/plc4x#2830 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Bug]: OPC UA UserNameIdentityToken sends length+password+nonce instead of the plain password when token security policy is NonePosiblemente ocupada @splatch la tomó hace 27 días. AbiertoOPC-UA
apache/plc4x#2791 · 2 comentarios · 2 asignados ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/plc4x
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
oracle/graalvm-reachability-metadata#11472 ·
Los mantenedores suelen responder en 1 día
-
status: waiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
spring-projects/spring-ai#7269 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 89/100
objectionary/hone-maven-plugin#1353 ·
Los mantenedores suelen responder en 9 días
-
ClassNotFoundException: io.netty.channel.kqueue.KQueueEventLoop stack trace printed during native build on main (Netty 4.2 removed the class)Posiblemente ocupada @gastaldi la tomó hoy. Abiertoarea/netty kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
quarkusio/quarkus#57939 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
conductor-oss/conductor#1777 ·
Los mantenedores suelen responder en 4 días