This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Reseting USB from script
#3
(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?
Reply


Messages In This Thread
Reseting USB from script - by Aivaras - 19.04.2023, 06:19
RE: Reseting USB from script - by admin - 19.04.2023, 06:47
RE: Reseting USB from script - by Aivaras - 24.04.2023, 14:10
RE: Reseting USB from script - by admin - 24.04.2023, 15:22
RE: Reseting USB from script - by Aivaras - 06.06.2023, 05:41
RE: Reseting USB from script - by admin - 06.06.2023, 07:37

Forum Jump: