24.04.2023, 14:10
(19.04.2023, 06:47)admin Wrote: Check system log in system config. Most likely your USB device reconnected and changed the port name from /dev/ttyUSB0 to /dev/ttyUSB1.
You can use this function to find the port name. It will return nil if no port is found.
Code:function findport()
local path = '/sys/bus/usb-serial/devices'
local ports = io.ls(path) or {}
if type(ports) == 'table' and #ports > 0 then
return '/dev/' .. ports[ 1 ]
end
end
You should check for read errors to detect USB disconnect:
Code:res, err = port:read(...)
if err == 'read error' then
-- USB disconnected
end
Hello admin,
Unfortunately the problem is still here.
USB does not change the port name. err displays: timeout
system log puts out:
Apr 24 13:57:01 LogicMachine kern.err kernel: [14656.417881] pl2303 1-1:1.0: pl2303_vendor_write - failed to write [0000]: -110
Apr 24 13:57:01 LogicMachine kern.err kernel: [14656.297931] pl2303 ttyUSB0: pl2303_get_line_request - failed: -110
Apr 24 13:57:01 LogicMachine kern.err kernel: [14656.177891] pl2303 ttyUSB0: pl2303_set_control_lines - failed: -110
Apr 24 13:57:01 LogicMachine kern.err kernel: [14656.057986] pl2303 1-1:1.0: pl2303_vendor_write - failed to write [0000]: -110
Apr 24 13:57:01 LogicMachine kern.err kernel: [14655.937909] pl2303 ttyUSB0: pl2303_set_line_request - failed: -110
Apr 24 13:57:01 LogicMachine kern.err kernel: [14655.818029] pl2303 ttyUSB0: pl2303_get_line_request - failed: -110
Apr 24 13:57:00 LogicMachine kern.err kernel: [14655.697920] pl2303 1-1:1.0: pl2303_vendor_write - failed to write [0009]: -110
Apr 24 13:57:00 LogicMachine kern.err kernel: [14655.578120] pl2303 1-1:1.0: pl2303_vendor_write - failed to write [0008]: -110
Apr 24 13:57:00 LogicMachine kern.err kernel: [14655.457913] pl2303 ttyUSB0: error sending break = -110
Any solutions? Or maybe I can restart USB port?