           count: 0,
           direction: -1
         }
+
         {:ok, settings}
 
       {:error, error} ->

    {:noreply, state}
  end

  def handle_info({:nerves_uart, port, message}, state)
    when !Map.has_key?(state, port) do

    {:noreply, state}
  end

  def handle_info({:nerves_uart, port, message}, state)
    when Map.has_key?(state, port) do

    {point_type, new_settings} = next_settings(Map.get(state, port))

    case point_type do
      :crest, :trough ->
        Logger.info(message)

      _ ->
    end

    new_state = Map.put(state, port, new_settings)
    {:noreply, new_state}
  end

  def handle_info(msg, state) do

  end

  defp set_up(port, log_path, sample_rate) do
    with {:ok, settings} <- generate_settings(log_path, sample_rate),
         :ok <- UART.open(uart_pid(), port, @open_options),
         :ok <- UART.flush(uart_pid()),
         :ok <- UART.write(uart_pid(), @on),
