Modbux.Tcp (Modbux v0.3.14)

View Source

Tcp message helper, functions that handles TCP responses/requests messages.

Summary

Functions

pack_req(cmd, transid)

@spec pack_req(
  {:fc | :phr | :rc | :rhr | :ri | :rir, integer(), integer(),
   maybe_improper_list() | integer()},
  integer()
) :: <<_::48, _::_*8>>

pack_res(cmd, values, transid)

@spec pack_res(
  {:fc | :phr | :rc | :rhr | :ri | :rir, integer(), any(),
   maybe_improper_list() | integer()},
  any(),
  integer()
) :: <<_::48, _::_*8>>

parse_req(wraped)

@spec parse_req(<<_::48, _::_*8>>) ::
  {{:einval | :error | :fc | :phr | :rc | :rhr | :ri | :rir, byte(), char(),
    [any()] | char()}, char()}

parse_res(cmd, wraped, transid)

@spec parse_res(any(), <<_::48, _::_*8>>, char()) ::
  nil | [any()] | {:error, any()} | {:error, byte(), <<_::104>>}

req_len(cmd)

@spec req_len({:fc | :phr | :rc | :rhr | :ri | :rir, any(), any(), any()}) ::
  integer()

res_len(cmd)

@spec res_len({:fc | :phr | :rc | :rhr | :ri | :rir, any(), any(), any()}) :: number()

unwrap(inv_data)

@spec unwrap(<<_::48, _::_*8>>) :: {binary(), char()}

unwrap(msg, transid)

@spec unwrap(<<_::48, _::_*8>>, char()) :: nil | binary()

wrap(payload, transid)

@spec wrap(binary(), integer()) :: <<_::48, _::_*8>>