java.lang.Object
org.photonvision.common.dataflow.structures.Packet

public class Packet extends Object
A packet that holds byte-packed data to be sent over NetworkTables.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Packet(byte[] data)
    Constructs a packet with the given data.
    Packet(int size)
    Constructs an empty packet.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the packet and resets the read and write positions.
    boolean
    Returns a decoded boolean from the packet.
    byte
    Returns a decoded byte from the packet.
    double
    Returns a decoded double from the packet.
    double[]
     
    float
    Returns a decoded float from the packet.
    int
    Returns a decoded int from the packet.
    long
     
    short
     
    void
    encode(boolean src)
    Encodes the boolean into the packet.
    void
    encode(byte src)
    Encodes the byte into the packet.
    void
    encode(double src)
    Encodes the double into the packet.
    void
    encode(double[] data)
     
    void
    encode(float src)
    Encodes the float into the packet.
    void
    encode(int src)
    Encodes the integer into the packet.
    void
    encode(long data)
    Encodes the double into the packet.
    void
    encode(short src)
    Encodes the short into the packet.
    byte[]
    Returns the packet data.
    int
     
    void
    setData(byte[] data)
    Sets the packet data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Packet

      public Packet(int size)
      Constructs an empty packet.
      Parameters:
      size - The size of the packet buffer.
    • Packet

      public Packet(byte[] data)
      Constructs a packet with the given data.
      Parameters:
      data - The packet data.
  • Method Details

    • clear

      public void clear()
      Clears the packet and resets the read and write positions.
    • getSize

      public int getSize()
    • getData

      public byte[] getData()
      Returns the packet data.
      Returns:
      The packet data.
    • setData

      public void setData(byte[] data)
      Sets the packet data.
      Parameters:
      data - The packet data.
    • encode

      public void encode(byte src)
      Encodes the byte into the packet.
      Parameters:
      src - The byte to encode.
    • encode

      public void encode(short src)
      Encodes the short into the packet.
      Parameters:
      src - The short to encode.
    • encode

      public void encode(int src)
      Encodes the integer into the packet.
      Parameters:
      src - The integer to encode.
    • encode

      public void encode(float src)
      Encodes the float into the packet.
      Parameters:
      src - The float to encode.
    • encode

      public void encode(long data)
      Encodes the double into the packet.
      Parameters:
      data - The double to encode.
    • encode

      public void encode(double src)
      Encodes the double into the packet.
      Parameters:
      src - The double to encode.
    • encode

      public void encode(boolean src)
      Encodes the boolean into the packet.
      Parameters:
      src - The boolean to encode.
    • decodeByte

      public byte decodeByte()
      Returns a decoded byte from the packet.
      Returns:
      A decoded byte from the packet.
    • decodeInt

      public int decodeInt()
      Returns a decoded int from the packet.
      Returns:
      A decoded int from the packet.
    • decodeLong

      public long decodeLong()
    • decodeDouble

      public double decodeDouble()
      Returns a decoded double from the packet.
      Returns:
      A decoded double from the packet.
    • decodeFloat

      public float decodeFloat()
      Returns a decoded float from the packet.
      Returns:
      A decoded float from the packet.
    • decodeBoolean

      public boolean decodeBoolean()
      Returns a decoded boolean from the packet.
      Returns:
      A decoded boolean from the packet.
    • encode

      public void encode(double[] data)
    • decodeDoubleArray

      public double[] decodeDoubleArray(int len)
    • decodeShort

      public short decodeShort()