Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: modbus rtu maybe error by serial port. #1604

Open
2 of 16 tasks
liudianwei opened this issue May 19, 2024 · 3 comments
Open
2 of 16 tasks

[Bug]: modbus rtu maybe error by serial port. #1604

liudianwei opened this issue May 19, 2024 · 3 comments
Assignees
Labels
bug driver-modbus java Pull requests that update Java code Modbus plc4j

Comments

@liudianwei
Copy link

What happened?

modbus rtu over serial port will not work correct because the serial may be not write all data to the pc(or memory?), due to this, if read serial port immediately after send command, the data just read may be incomplete, so modbus driver will throw some errors like crc or read error.

temporary solution:
image
file location plc4x\plc4j\transports\serial\src\main\java\org\apache\plc4x\java\transport\serial\SerialChannelHandler.java
thx.

Version

latest

Programming Languages

  • plc4j
  • plc4go
  • plc4c
  • plc4net

Protocols

  • AB-Ethernet
  • ADS /AMS
  • BACnet/IP
  • CANopen
  • DeltaV
  • DF1
  • EtherNet/IP
  • Firmata
  • KNXnet/IP
  • Modbus
  • OPC-UA
  • S7
@liudianwei liudianwei added the bug label May 19, 2024
@liudianwei
Copy link
Author

link #831

@ottlukas ottlukas added java Pull requests that update Java code Modbus driver-modbus plc4j labels May 21, 2024
@chrisdutz
Copy link
Contributor

The main problem here is that modbus doesn't have any form of "length indicator" in the protocol.

One option would be to call the parse method in the ByteLengthEstimator in ModbusAsciiDriver and ModbusRtuDriver ... this would increase the cpu and memory-load of the drivers, but serial ports not really being high-speed, I think this doesn't matter much.

chrisdutz added a commit that referenced this issue May 24, 2024
…try parsing the message in order to correctly operate.

Addresses:
#831
#1604
@chrisdutz
Copy link
Contributor

I've just pushed an update that should make Modbus ASCII and RTU a bit more stable in situations as you describe. Please give the SNAPSHOT a try as soon as Jenkins is finished building it.

https://ci-builds.apache.org/job/PLC4X/job/PLC4X/job/develop/2050/

@chrisdutz chrisdutz self-assigned this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug driver-modbus java Pull requests that update Java code Modbus plc4j
Projects
None yet
Development

No branches or pull requests

3 participants