Nanodrop.Device (nanodrop v0.3.1)

Copy Markdown

USB device management for NanoDrop spectrophotometers.

Handles device enumeration, connection, and low-level USB communication using the Ocean Optics USB2000 endpoints.

Summary

Functions

Closes a device connection.

Lists all connected NanoDrop/USB2000 devices.

Opens a connection to a NanoDrop device.

Reads query response from the device (bulk transfer in on EP 0x87).

Reads spectrum data from the device (bulk transfer in on EP 0x82).

Sends a command to the device (bulk transfer out).

Types

device_info()

@type device_info() :: %{
  vendor_id: non_neg_integer(),
  product_id: non_neg_integer(),
  bus: non_neg_integer(),
  address: non_neg_integer(),
  device_ref: reference()
}

t()

@type t() :: %Nanodrop.Device{device_info: device_info(), handle: reference()}

Functions

close(device)

@spec close(t()) :: :ok

Closes a device connection.

list_devices()

@spec list_devices() :: [device_info()]

Lists all connected NanoDrop/USB2000 devices.

open(device_info \\ nil)

@spec open(device_info() | nil) :: {:ok, t()} | {:error, term()}

Opens a connection to a NanoDrop device.

read_query(device, length \\ 64)

@spec read_query(t(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}

Reads query response from the device (bulk transfer in on EP 0x87).

read_spectrum(device, length \\ 4096)

@spec read_spectrum(t(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}

Reads spectrum data from the device (bulk transfer in on EP 0x82).

send_command(device, data)

@spec send_command(t(), binary()) :: :ok | {:error, term()}

Sends a command to the device (bulk transfer out).