SciFiDryer / ModbusMechanic

Cross platform GUI MODBUS TCP/RTU simulator & gateway. Interprets data types including ascii float and int.
Apache License 2.0
175 stars 15 forks source link

Display error message when serial port fails to open on RTU scanner function #10

Closed zhurlik closed 2 years ago

zhurlik commented 2 years ago

Describe the bug It would be great to add some information or try to handle the case when a user is not in dialout group.

To Reproduce Steps to reproduce the behavior:

  1. check that you are not in dialout group: $ groups
  2. $ java -jar ModbusMechanic.jar -debug
  3. Tools-> RTU Scanner, click 'Scan'
  4. See error in console: purejavacomm.PortInUseException: errno() == 13 at purejavacomm.PureJavaSerialPort.(PureJavaSerialPort.java:1090) at purejavacomm.CommPortIdentifier.open(CommPortIdentifier.java:159) at modbusmechanic.RTUScannerThread.run(RTUScannerThread.java:49)

Expected behavior To fix that you need to do: sudo usermod -a -G dialout $USER

Screenshots There are no any errors on UI.

Desktop (please complete the following information):

Java Runtime Version java -version openjdk version "17.0.4" 2022-07-19 OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-118.04) OpenJDK Server VM (build 17.0.4+8-Ubuntu-118.04, mixed mode, sharing)

Additional context Advanced Modbus Module User Manual Serial Device Access Privileges Next, the ignition user account (or whatever user runs the Ignition gateway service) must be added to the group controlling access to these devices. On most Linux distributions, this is the dialout group. This will work in most cases (executed as root): adduser ignition dialout Be sure to restart Ignition after changing group membership—it doesn’t take immediate effect.

Thanks, Vlad

SciFiDryer commented 2 years ago

As I understand the problem - attempting to run the RTU scanner will crash the program without an error dialog when all of the following are true:

This should be a similar fix to https://github.com/SciFiDryer/ModbusMechanic/issues/4 where an error message was displayed but it was not informative enough.

zhurlik commented 2 years ago

The application will not crash, but the scanning process will not display any results. As far as I remember, running under sudo did not solve the problem too. The main thing is that a user should be in dialout group.

SciFiDryer commented 2 years ago

c23fe5eb37233924cf60cf7cc46be0f1415b2a65 now stops the scanner and displays an error message without needing to be in debug. Thanks for reporting the issue.