Modbuv.Tcp.Server (modbuv v0.1.0)

Copy Markdown View Source

Modbus TCP server: listens on a port, serves each connection from the shared DB, and optionally notifies the owner of parsed requests.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the raw DB map currently held by the server's shared model.

Starts the TCP server GenServer. params must include :model and may include :port, :timeout, :active, :fc_map, and :sup_opts.

Stops the TCP server GenServer process.

Reads or writes the server's local DB using a frame tuple. Validates the frame against the fc_map and returns the result or {:error, :efun} for unknown function codes.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_db(pid)

@spec get_db(pid()) :: map()

Returns the raw DB map currently held by the server's shared model.

start_link(params, gen_opts \\ [])

@spec start_link(keyword(), keyword()) :: {:ok, pid()} | {:error, term()}

Starts the TCP server GenServer. params must include :model and may include :port, :timeout, :active, :fc_map, and :sup_opts.

stop(pid)

@spec stop(pid()) :: :ok

Stops the TCP server GenServer process.

update(pid, frame)

@spec update(pid(), tuple()) :: term()

Reads or writes the server's local DB using a frame tuple. Validates the frame against the fc_map and returns the result or {:error, :efun} for unknown function codes.