Scada-LTS icon indicating copy to clipboard operation
Scada-LTS copied to clipboard

Modbus Serial is not working

Open fabiodurao opened this issue 3 years ago • 12 comments

Describe the bug The Modbus Serial protocol/datasource is not working, it does not load the COM port or ttyS0.

To Reproduce Steps to reproduce the behavior:

  1. Go to the Datasource section and choose the Datasource Serial option and click create.
  2. You will see that it does not load the serial port, it shows an error from the rxtxserial library.

Expected behavior On windows it was expected to show all existing or compatible COM (on Windows) or ttySX (on Linux) ports.

Screenshots Captura de tela de 2021-05-10 20-02-27

Desktop:

  • OS: Pop OS 20.04
  • Browser: chrome
  • Version: 90

Additional context This is a bug inherited from ScadaBR 1.1 developed in Brazil, one of the things that prevent many users from migrating to ScadaLTS is the lack of this protocol, it is only available in ScadaBR 1.0 developed in Brazil, which is a very outdated version with java 6 and tomcat 6 yet.

The version of ScadaBR 1.1 was developed at the request of a Brazilian health company and this occurred at the same time that the Canadian project had its license closed, as we did not have the source code for the serial modbus, it was disabled or removed, I think it was the first option because some users were able to reactivate it manually in ScadaBR 1.1. This was discussed in the ScadaBR forum (http://forum.scadabr.com.br/t/erro-no-driver-modbus-serial-na-versao-do-scadabr-1-1-0-rc-do-branches/1307/4).

Although personally I do not use the serial modbus protocol [and when I need to use it, I prefer to use a serial modbus to modbus tcp converter (gateway) as I find the serial gate management more efficient in this way], the vast majority of users starts by getting to know ScadaBR/ScadaLTS at the university level with an arduino uno in hand trying to connect to the supervisory with a usb cable even using the serial modbus protocol.

The defense of the correctness of this protocol is based on facilitating the adoption of this wonderful system by new users and giving more connection options for some equipment, such as multimeters and input PLC's without the need for additional hardware.

fabiodurao avatar May 10 '21 23:05 fabiodurao

@fabiodurao Thanks for the detailed description of the problem. We have limited resources so I cannot promise that we will deal with this in the near future. We develop the project, including the team, we try to meet the expectations of users as far as we are able. We encourage you to support project. Greetings.

Limraj avatar May 11 '21 17:05 Limraj

Hi fabio and Limraj I already had the same need to use the serial in an application and ended up having to migrate to a gateway (Terminal Server Serial). The problem that many times the customer finds it bad to have an additional cost with equipment and is also another point of failure in communication. As Fabio said, the operation of the serial modbus would be very important to present this tool to students of technical and higher courses and to further disseminate the tool that we know to be excellent. Sorry for my english. thanks alot

ourique98 avatar May 11 '21 20:05 ourique98

Hello, Wagner de Queiroz, here. For the moment, I'm creating a bash script to install the ScadaLTS on ARM boards like Raspberry PI and TVsetbox based Linux. I found this problem with the Modbus Library. Really this are a problem to use ScadaLTS/BR for Study or small projects where the user need's low cost to use the ScadaLTS/BR, I heard some peoples have interest to use MODBUS into serial channels because this are very cheap to begin and maintain small projects. It's important we have serial access into ScadaLTS project.

WagnerDeQueiroz avatar May 11 '21 22:05 WagnerDeQueiroz

Goodnight everyone. I agree with what was explained by Fabio, Wagner and Ourique. It is very important to have the serial Modbus connection function available, mainly to study and practice. In my case I have several devices (Powermeters, Temperature Controller, Power Factor Controller, and others) with serial connection in my Laboratory of the School (currently I teach Scada), and it is very important to have this feature. In ScadaBR1.1 we already know that Modbus Serial does not work, but we hoped that in the LTS version this would be corrected. I hope this detail can be solved and have the serial connection. Thank you.

fernandoborbabritos avatar May 11 '21 22:05 fernandoborbabritos

I also have this problem. I need to implement it on a client. It would be of great help if the feature were implemented.

celsoiha avatar May 11 '21 23:05 celsoiha

We covered the topic in the team because there is so much interest in this feature, we decided to tackle it in the coming iterations, the latest it should be in 2.9.0. Greetings to everyone, thank you for your votes.

Limraj avatar May 12 '21 09:05 Limraj

I've also encountered this problem on Debian 10 after installing librxtx-java packet. In my case, it was solved by setting an appropriate LD_LIBRARY_PATH before starting the tomcat:

export LD_LIBRARY_PATH=/usr/lib/jni/
./bin/startup.sh

dev-pts avatar Jul 01 '21 15:07 dev-pts

Hello @fabiodurao @ourique98 @WagnerDeQueiroz @celsoiha @fernandoborbabritos @dev-pts, I made initial fixes, unfortunately we noticed a serious RXTX flaw, we decided to change the library to jSerialComm , which does not require additional steps in the system, everything is included in the jar file with the library. If anyone would be willing to help with the Modbus Serial communication tests, I invite you, it will significantly speed up the work.

Feel free to download and test, this is war with the fix Scada-LTS.zip

After deploying to tomcat, the application is available at: (default config) http://localhost:8080/Scada-LTS

Best wishes.

Limraj avatar Jun 21 '22 17:06 Limraj

Actual version: Scada-LTS.zip

If there were any problems, please contact me: [email protected]

More information about jSerialComm: https://fazecast.github.io/jSerialComm/ However, on linux system configuration is necessary as long as we are not running on root:

sudo usermod -a -G uucp username
sudo usermod -a -G dialout username
sudo usermod -a -G lock username
sudo usermod -a -G tty username

Limraj avatar Jun 22 '22 08:06 Limraj

Thanks @Limraj for investing time in this community demand, the serial modbus fix will be very helpful for mass adoption of Scada-LTS by the community. I would like to test it, it would be easier if there was already a docker tag, I have been testing the docker versions of the system, I have even started testing the wonderful features of 2.7.1. Is there something along these lines? I ask this because installing mysql 5.7 on linux manually has been an almost impossible mission.

fabiodurao avatar Jun 22 '22 20:06 fabiodurao

docker tag: pr-2266 In the docker-compose.yml file, I added device sharing for docker, only run on unix system (macos x, linux) :

devices:
   - "/dev/:/dev/"

As a result, I have access to ports from the docker.

For windows try: (assuming there is a COM1 port, change if you have other ports)

devices:
   - "COM1:/dev/ttyS1"

For all:

  1. You must have a docker-compose installed.
  2. Download file and uzip: docker-compose.zip
  3. Create dir example scadalts and move file *.yml
  4. Open terminal in scadalts dir and execute command:
 docker-compose up database
 docker-compose up scadalts

Thanks @fabiodurao


As for tests and docker, for each pull request a docker image is generated under the name: "pr- [pull_request_number]" For example: https://github.com/SCADA-LTS/Scada-LTS/pull/2266

is docker tag: pr-2266

All tags: https://hub.docker.com/r/scadalts/scadalts/tags


Modbus Serial fix will be released in version 2.7.2


Test version 2.7.1: https://github.com/SCADA-LTS/Scada-LTS/issues/2267

Limraj avatar Jun 23 '22 06:06 Limraj

Hello @fabiodurao, Did you manage to launch the docker with ports and test something?

Best wishes.

Limraj avatar Jun 24 '22 07:06 Limraj

Sorry for the delay in responding, I was without any hardware, now I have a plc delta dvp-14ss2, the communication already tested in another version of ScadaBR and it is ok, but it seems that the port is not opening. My installation is in docker on linux pop-os.

Here's the error: There was a problem starting the scan. There may be an enabled data source already using the selected port. (org.scada_lts.serial.SerialPortException: org.scada_lts.serial.SerialPortException: com.fazecast.jSerialComm.SerialPortIOException: Failed open port: SerialPortParametersImpl{commPortId='ttyUSB0', portOwnerName='Mango Modbus Serial Data Source Scan', baudRate= 57600, flowControlIn=0, flowControlOut=0, dataBits=8, stopBits=1, parity=0, timeout=500}) Captura de tela de 2022-10-06 13-24-35

fabiodurao avatar Oct 06 '22 16:10 fabiodurao

@fabiodurao You just have this port written down in Data Source and cannot be used in the test. This was originally the case, replacing this behavior would require major code changes. You can choose a different port and click scan. Best to just create a Data Source, attach a point and test it on the point.

"the communication already tested in another version of ScadaBR" What version?

Limraj avatar Oct 07 '22 02:10 Limraj

I tested serial modbus communication on ScadaBR 1.0, an old version before the bug was accidentally added to version 1.1 (which was the branch for Scada-LTS that inherited the bug) and I tested it on ScadaBR 1.2 (version created with some updates from java, tomcat and with this bug fixed). I tested in those versions that I know to see if there was no problem in the communication on the PLC side.

My test on Scada-LTS was not successful because I forgot to do the procedure mentioned above to release the ports, I will redo it and post the result.

fabiodurao avatar Oct 07 '22 14:10 fabiodurao

I would like to give my feedback about the modbus serial in Scada-lts, version 2.7.2. I got to test the Modbus Serial via a docker container, using as host an Ubuntu 22.04. I had success only reading registers and coils, but i can't do writing operations. I am not sure if I'm doing something wrong, then I prefered to relate this situation here!

Thanks for the good work guys!

JoseVinicius1998 avatar Mar 24 '23 19:03 JoseVinicius1998

Hi @JoseVinicius1998,

  1. When you report a problem, it is worth presenting the scenario that leads to it. How are we supposed to know what you did?
  2. It is also important on what hardware did you test, or rather on an emulator?
  3. In addition, it is worth writing what exactly is happening, what error do you have, send logs, screenshots?

Unfortunately, we have limited access to physical hardware, so we can only rely on the emulator or your relationship with the description.

It's best to open an issue with this information in mind. Example: https://github.com/SCADA-LTS/Scada-LTS/issues/2472

Regards, Kamil Jarmusik

Limraj avatar Mar 24 '23 19:03 Limraj

Sorry. I noticed that a made a mistake. The silly mistake of not considering subtracting the register address value by one... Actually, the Modbus serial is working perfectly and I also can do commands!

JoseVinicius1998 avatar Mar 27 '23 11:03 JoseVinicius1998

Hi @JoseVinicius1998, Okey. Sorry if that sounded rude. If something happens, be sure to let us know.

Regards, Kamil Jarmusik

Limraj avatar Mar 27 '23 12:03 Limraj