s/methods/functions ![]()
You can set the @doc attribute simply inline before your function def:
defmodule ExModbus.SunSpec.Fronius do
@external_resource Path.join([__DIR__, "sunspec.csv"])
for line <- File.stream!(Path.join([__DIR__, "sunspec.csv"]), [], :line) |> Stream.drop(1) do
[start, _end, size, _access, _func_codes, name, desc, type, _units, _scale_factor, _range] = String.split(line, ",")
start = String.to_integer(start)
size = String.to_integer(size)
name = String.to_atom(String.downcase(name))
@doc "Function that does #{desc}"
def unquote(name)(pid, slave_id \\ 1) do
case ExModbus.Client.read_data(pid, slave_id, unquote(start - 1 + 40000), unquote(size)) do
%{data: {:read_holding_registers, data}, transaction_id: transaction_id, unit_id: unit_id} ->
data = data |> ExModbus.Types.convert_type(unquote(type))
{:ok, %{data: data, transaction_id: transaction_id, slave_id: unit_id}}
other ->
IO.puts inspect other
end
end
end
end






















