ExSunSpec lets you quickly define profiles for SunSpec compliant devices.
If available in Hex, the package can be installed
by adding ex_sunspec
to your list of dependencies in mix.exs
:
def deps do
[{:ex_sunspec, "~> 0.1.0"}]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ex_sunspec.
ExSunSpec uses macros to let you define unit profiles with minimal data declaration. Example:
defmodule Fronius.SpecificModel do
use ExModbus.SunSpec, 40_000, [100, 101, 121, 133]
end
ex_sunspec relies on ex_modbus, which can communicate via TCP or RTU connections. The connection required is inferred based on the start_link parameters. If a host or ip is provided, we assume TCP. If tty & speed are provided, then RTU is configured.
{:ok, pid} = Fronius.SpecificModel.start_link {10, 0, 0, 1}
Fronius.mn(pid, 1)
{:ok, "Fronius"}
{:ok, pid} = Fronius.SpecificModel.start_link {10, 0, 0, 1}
Fronius.SpecificModel.set_out_pfset(pid, 1, 12)
{:ok, 12}