Class KissEscapeOutputStream

java.lang.Object
java.io.OutputStream
org.ka2ddo.yaac.io.KissEscapeOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class KissEscapeOutputStream extends OutputStream
This filtering OutputStream adds the KISS protocol escape sequences for the body of a KISS frame. It also calculates G8BPQ's CRC for the frame if needed for MKISS operations.
Author:
Andrew Pavlin, KA2DDO
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    States of a KISS frame decoder.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Byte value for end-of-frame flag byte in KISS protocol.
    static final int
    Byte value of prefix for escaped byte value (use of protocol byte value in frame body).
    static final int
    Escaped value for literal FEND character.
    static final int
    Escaped value for literal FESC character.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a KissEscapeOutputStream wrapped around an implementation of the java.io.DataOutput interface.
    KissEscapeOutputStream(DataOutput out, boolean escCForKenwood)
    Create a KissEscapeOutputStream wrapped around an implementation of the java.io.DataOutput interface.
    Create a KissEscapeOutputStream wrapped around an OutputStream.
    KissEscapeOutputStream(OutputStream os, boolean escCForKenwood)
    Create a KissEscapeOutputStream wrapped around an OutputStream.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the number of bytes passed through this stream (counting escape codes injected by the stream).
    byte
    Get the G8BPQ CRC value for the last sent KISS frame.
    void
    Reset the statistics fields for this stream.
    void
    write(int b)
    Write one byte to the output stream.

    Methods inherited from class java.io.OutputStream

    close, flush, nullOutputStream, write, write

    Methods inherited from class java.lang.Object

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

    • FEND

      public static final int FEND
      Byte value for end-of-frame flag byte in KISS protocol.
      See Also:
    • FESC

      public static final int FESC
      Byte value of prefix for escaped byte value (use of protocol byte value in frame body).
      See Also:
    • TFEND

      public static final int TFEND
      Escaped value for literal FEND character.
      See Also:
    • TFESC

      public static final int TFESC
      Escaped value for literal FESC character.
      See Also:
  • Constructor Details

    • KissEscapeOutputStream

      public KissEscapeOutputStream(DataOutput out)
      Create a KissEscapeOutputStream wrapped around an implementation of the java.io.DataOutput interface.
      Parameters:
      out - DataOutput interface implementer to wrap with this stream
    • KissEscapeOutputStream

      public KissEscapeOutputStream(OutputStream os)
      Create a KissEscapeOutputStream wrapped around an OutputStream.
      Parameters:
      os - OutputStream to receive KISS-encoded frames
    • KissEscapeOutputStream

      public KissEscapeOutputStream(DataOutput out, boolean escCForKenwood)
      Create a KissEscapeOutputStream wrapped around an implementation of the java.io.DataOutput interface.
      Parameters:
      out - DataOutput interface implementer to wrap with this stream
      escCForKenwood - boolean, if true also escape 'C' with FESC to protect against Kenwood "features"
    • KissEscapeOutputStream

      public KissEscapeOutputStream(OutputStream os, boolean escCForKenwood)
      Create a KissEscapeOutputStream wrapped around an OutputStream.
      Parameters:
      os - OutputStream to receive KISS-encoded frames
      escCForKenwood - boolean, if true also escape 'C' with FESC to protect against Kenwood "features"
  • Method Details

    • getByteCount

      public int getByteCount()
      Get the number of bytes passed through this stream (counting escape codes injected by the stream).
      Returns:
      byte count
    • resetByteCount

      public void resetByteCount()
      Reset the statistics fields for this stream.
    • write

      public void write(int b) throws IOException
      Write one byte to the output stream.
      Specified by:
      write in class OutputStream
      Parameters:
      b - byte value to encode
      Throws:
      IOException - if wrapped stream throws an IOException
    • getG8bpqCrc

      public byte getG8bpqCrc()
      Get the G8BPQ CRC value for the last sent KISS frame.
      Returns:
      one-byte CRC as used by G8BPQ