Serial binding status

I have configured openhab 3 and using it to control my devices over mobus. There are two usb sticks connected to my devices:
/dev/ttyUSB0
/dev/ttyACM0

Sometime my usb sticks reconnects (it is another story…linked with ESD and Raspberry PI) and gets names like ttyUSB1, ttyUSB2 and so on.

To overcome above issue with names I made two symbolic links and updates them with udev.
/dev/ttyModbusEnergy → /dev/ttyUSB?
/dev/ttyModbusVav → /dev/ttyACM?

According to modbus add-on I have to create modbus:serial and modbus:pooler things. Lets look at my scenario in details:

  1. Enable modbus serial.
  2. Enable modbus pooler.
  3. Remove usb stick and attach to usb.
  4. Modbus pooler indicates error (exceptions occurred). But modbus serial in a status “ONLINE”.

I have read source codes and noticed that all exceptions occured during pooling tasks not influence to modbus:serial. Modbus serial does not know anything about actual state of device.

I know that disconnection is linked with an hardware issue, but I would like to:

  • know the real status of modbus:serial thing;
  • have some rules to reconnect it automatically.