Pummpcomm v2.5.1 Pummpcomm.Session.Packet View Source

A general packet for sending Pummpcomm.Session.Command.t and receive Pummp.Session.Response.t

Link to this section Summary

Types

t()
  • pump_serial - serial number of the pump

Functions

Parses Pummpcomm.Session.Packet.t out of bytes

Converts command to t

Converts command to t, using given payload instead of getting payload from command params

Converts packet to binary format used to transmit to pump

Link to this section Types

Link to this type t() View Source
t() :: %Pummpcomm.Session.Packet{date: term, opcode: non_neg_integer, payload: binary, pump_serial: String.t, type: non_neg_integer}
  • pump_serial - serial number of the pump

Link to this section Functions

Link to this function from_binary(bytes) View Source
from_binary(<<_::0>>) ::
  {:ok, t} |
  {:error, {:invalid_packet, :crc_mismatch | :packet_too_short}}

Parses Pummpcomm.Session.Packet.t out of bytes

Returns

  • {:ok, Pummpcomm.Session.Response.t} - packet could be parsed and CRC8 check passed
  • {:error, {:invalid_packet, :crc_mismatch}} - packet could be parsed, but CRC8 check failed
  • {:error, {:invalid_packet, :packet_too_short}} - fewer than 6 bytes are given, packet was not parsed
Link to this function from_command(command) View Source
from_command(Pummpcomm.Session.Command.t) :: {:ok, t}

Converts command to t

Link to this function from_command(command, payload) View Source
from_command(Pummpcomm.Session.Command.t, binary) :: {:ok, t}

Converts command to t, using given payload instead of getting payload from command params.

Link to this function to_binary(packet) View Source
to_binary(t) :: binary

Converts packet to binary format used to transmit to pump