Package org.ka2ddo.yaac.io
Class KissEscapeOutputStream
java.lang.Object
java.io.OutputStream
org.ka2ddo.yaac.io.KissEscapeOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
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
Modifier and TypeClassDescriptionstatic enum
States of a KISS frame decoder. -
Field Summary
Modifier and TypeFieldDescriptionstatic 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
ConstructorDescriptionCreate 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 TypeMethodDescriptionint
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
-
Field Details
-
FEND
public static final int FENDByte value for end-of-frame flag byte in KISS protocol.- See Also:
-
FESC
public static final int FESCByte value of prefix for escaped byte value (use of protocol byte value in frame body).- See Also:
-
TFEND
public static final int TFENDEscaped value for literal FEND character.- See Also:
-
TFESC
public static final int TFESCEscaped value for literal FESC character.- See Also:
-
-
Constructor Details
-
KissEscapeOutputStream
Create a KissEscapeOutputStream wrapped around an implementation of the java.io.DataOutput interface.- Parameters:
out
- DataOutput interface implementer to wrap with this stream
-
KissEscapeOutputStream
Create a KissEscapeOutputStream wrapped around an OutputStream.- Parameters:
os
- OutputStream to receive KISS-encoded frames
-
KissEscapeOutputStream
Create a KissEscapeOutputStream wrapped around an implementation of the java.io.DataOutput interface.- Parameters:
out
- DataOutput interface implementer to wrap with this streamescCForKenwood
- boolean, if true also escape 'C' with FESC to protect against Kenwood "features"
-
KissEscapeOutputStream
Create a KissEscapeOutputStream wrapped around an OutputStream.- Parameters:
os
- OutputStream to receive KISS-encoded framesescCForKenwood
- 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
Write one byte to the output stream.- Specified by:
write
in classOutputStream
- 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
-