Modbus serial no reconnect after USB error

Hello

I use the modbus binding on OH 3.4.4(debian) to connect a device using a serial connection (a cp210X connected to an arduino mega).

Sometimes there is an error on the usb

#dmesg
[1389433.010167] cp210x ttyUSB1: usb_serial_generic_read_bulk_callback - urb stopped: -32
[1389433.010372] cp210x ttyUSB1: usb_serial_generic_read_bulk_callback - urb stopped: -32
[1389433.036868] cp210x ttyUSB1: usb_serial_generic_write_bulk_callback - urb stopped: -32
[1389433.068483] usb 1-5.3-port1: disabled by hub (EMI?), re-enabling...
[1389433.068704] usb 1-5.3.1: USB disconnect, device number 29
[1389433.068808] cp210x ttyUSB1: failed set request 0x12 status: -19
[1389433.068814] cp210x ttyUSB1: failed set request 0x0 status: -19
[1389433.069061] cp210x ttyUSB1: cp210x converter now disconnected from ttyUSB1
[1389433.069079] cp210x 1-5.3.1:1.0: device disconnected
[1389433.314526] usb 1-5.3.1: new full-speed USB device number 30 using xhci_hcd
[1389433.440270] usb 1-5.3.1: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
[1389433.440280] usb 1-5.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1389433.440283] usb 1-5.3.1: Product: Lumiere1er
[1389433.440284] usb 1-5.3.1: Manufacturer: Silicon Labs
[1389433.440286] usb 1-5.3.1: SerialNumber: Lumiere1er
[1389433.446270] cp210x 1-5.3.1:1.0: cp210x converter detected
[1389433.449308] usb 1-5.3.1: cp210x converter now attached to ttyUSB5

After that openhab refuses to reconnect.

2023-08-01 12:24:32.525 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 3c7600f6-2dae-4e5c-a437-d562ffcd96ff]
2023-08-01 12:24:32.561 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 3c7600f6-2dae-4e5c-a437-d562ffcd96ff]
2023-08-01 12:24:32.596 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Aborting. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 3c7600f6-2dae-4e5c-a437-d562ffcd96ff]
2023-08-01 12:24:32.632 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 74234191-52f4-4802-abbe-ed21c7ae6a53]
2023-08-01 12:24:32.667 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 74234191-52f4-4802-abbe-ed21c7ae6a53]
2023-08-01 12:24:32.702 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Aborting. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 74234191-52f4-4802-abbe-ed21c7ae6a53]
2023-08-01 12:24:32.748 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 0afe5a18-492d-413b-9cb0-17542cf9b378]
2023-08-01 12:24:32.784 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=51, functionCode=READ_COILS, start=11, length=11, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O failed to write [operation ID 0afe5a18-492d-413b-9cb0-17542cf9b378]

I use an udev rule OH pointing to a symbolic link

SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="Lumiere1er", SYMLINK+="ttyLumiere1er"

yaml modbus serial thing (note : “timeBetweenReconnectMillis” doesn’t seem to be taken into consideration)

UID: modbus:serial:Lumiere1er
label: Arduino lumières 1er
thingTypeUID: modbus:serial
configuration:
  baud: 9600
  timeBetweenTransactionsMillis: 35
  connectMaxTries: 1
  stopBits: "1.0"
  parity: none
  receiveTimeoutMillis: 1500
  dataBits: 8
  echo: false
  encoding: rtu
  flowControlIn: none
  port: /dev/ttyLumiere1er
  flowControlOut: none
  timeBetweenReconnectMillis: 5000
  connectTimeoutMillis: 10000
  afterConnectionDelayMillis: 0
  id: 51
  enableDiscovery: false

The only solution I have found is to restart openhab.
Do you have anything better to suggest?
Does OH4 correct the problem?

restarting only the modbus bundle works

ssh -i /var/lib/openhab/.ssh/openhab.id_rsa openhab@localhost -p 8101 bundle:restart 283

The automation is being tested