esptest.devices.serial_tools module

esptest.devices.serial_tools.get_all_serial_ports(user='default', include_links=False)[source]

list_ports could spend a very long time if there are many ports

Parameters:
Return type:

List[ListPortInfo]

esptest.devices.serial_tools.compute_serial_port(port, strict=False)[source]

Get the real serial port device from device, port name or usb location

Parameters:
  • port (str) – device, port name or usb location

  • strict (bool, optional) – raise Exception if not found locally.

Returns:

port device. return the given input port

Return type:

str

esptest.devices.serial_tools.is_serial_port_in_use(port)[source]

Return whether the serial device is likely open in another process.

Resolves port with compute_serial_port(), then prefers fuser(1) (fuser -s on the device path: exit 0 means some process is using the file). If fuser is unavailable, fails, or returns an unexpected exit code, falls back to lsof(8) (exit 0 means holders were found).

If neither tool is available or both fail, raise OSError (occupancy unknown; callers may still open the port).

Parameters:

port (str)

Return type:

bool