org.ka2ddo.yaac.io
Class KissEscapeOutputStream

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

public class KissEscapeOutputStream
extends java.io.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.


Nested Class Summary
static class KissEscapeOutputStream.RcvState
          States of a KISS frame decoder.
 
Field Summary
static int FEND
           
static int FESC
           
static int TFEND
           
static int TFESC
           
 
Constructor Summary
KissEscapeOutputStream(java.io.DataOutput out)
          Create a KissEscapeOutputStream wrapped around an implementation of the java.io.DataOutput interface.
KissEscapeOutputStream(java.io.OutputStream os)
          Create a KissEscapeOutputStream wrapped around an OutputStream.
 
Method Summary
 int getByteCount()
          Get the number of bytes passed through this stream (counting escape codes injected by the stream).
 byte getG8bpqCrc()
          Get the G8BPQ CRC value for the last sent KISS frame.
 void resetByteCount()
          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, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FEND

public static final int FEND
See Also:
Constant Field Values

FESC

public static final int FESC
See Also:
Constant Field Values

TFEND

public static final int TFEND
See Also:
Constant Field Values

TFESC

public static final int TFESC
See Also:
Constant Field Values
Constructor Detail

KissEscapeOutputStream

public KissEscapeOutputStream(java.io.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(java.io.OutputStream os)
Create a KissEscapeOutputStream wrapped around an OutputStream.

Parameters:
os - OutputStream to receive KISS-encoded frames
Method Detail

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 java.io.IOException
Write one byte to the output stream.

Specified by:
write in class java.io.OutputStream
Parameters:
b - byte value to encode
Throws:
java.io.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