Class PacketOutputStream

java.lang.Object
java.io.OutputStream
org.refcodes.serial.PacketOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, BlockSizeAccessor, PacketSizeAccessor, EndianessAccessor, PacketLengthWidthAccessor, PacketMagicBytesAccessor, PacketSegmentPackagerAccessor, SequenceNumberAccessor, SequenceNumberConcatenateModeAccessor, SequenceNumberInitValueAccessor, SequenceNumberWidthAccessor
Direct Known Subclasses:
StopAndWaitPacketOutputStream

The PacketOutputStream wraps an OutputStream and chunks any data to be written into packets with a sequence number, a block of data and a CRC checksum. An according StopAndWaitPacketInputStream then reverts the packetised data stream while performing CRC checksum validation as well as sequence number validation. ATTENTION: In order to send the last packet (block of data), call flush() so that it is transmitted even if the block is not completely filled with bytes.