@Test public void itCanReadMaximumSizedMavlink2Packet() throws IOException { MavlinkPacket expected = MavlinkPacket.createSignedMavlink2Packet( 0, 0, 0, 0, 0, new byte[255], 0, 0, new byte[32]); InputStream in = new ByteArrayInputStream(expected.getRawBytes()); MavlinkPacketReader reader = new MavlinkPacketReader(in); MavlinkPacket actual = reader.next(); assertEquals(expected, actual); }
public MavlinkPacket next() throws IOException { while (in.next()) { byte[] frame = in.frame(); switch (frame[0] & 0xff) { case MavlinkPacket.MAGIC_V1: return MavlinkPacket.fromV1Bytes(frame); case MavlinkPacket.MAGIC_V2: return MavlinkPacket.fromV2Bytes(frame); } in.drop(); } throw new EOFException("End of stream"); }
MavlinkPacketReader { public MavlinkPacket next() throws IOException { while (in.next()) { byte[] frame = in.frame(); switch (frame[0] & 0xff) { case MavlinkPacket.MAGIC_V1: return MavlinkPacket.fromV1Bytes(frame); case MavlinkPacket.MAGIC_V2: return MavlinkPacket.fromV2Bytes(frame); } in.drop(); } throw new EOFException("End of stream"); } }
MavlinkPacketReader { public MavlinkPacket next() throws IOException { while (in.next()) { byte[] frame = in.frame(); switch (frame[0] & 0xff) { case MavlinkPacket.MAGIC_V1: return MavlinkPacket.fromV1Bytes(frame); case MavlinkPacket.MAGIC_V2: return MavlinkPacket.fromV2Bytes(frame); } in.drop(); } throw new EOFException("End of stream"); } MavlinkPacketReader(InputStream in); }
MavlinkPacketReader { public MavlinkPacket next() throws IOException { while (in.next()) { byte[] frame = in.frame(); switch (frame[0] & 0xff) { case MavlinkPacket.MAGIC_V1: return MavlinkPacket.fromV1Bytes(frame); case MavlinkPacket.MAGIC_V2: return MavlinkPacket.fromV2Bytes(frame); } in.drop(); } throw new EOFException("End of stream"); } MavlinkPacketReader(InputStream in); MavlinkPacket next(); void drop(); }
MavlinkPacketReader { public MavlinkPacket next() throws IOException { while (in.next()) { byte[] frame = in.frame(); switch (frame[0] & 0xff) { case MavlinkPacket.MAGIC_V1: return MavlinkPacket.fromV1Bytes(frame); case MavlinkPacket.MAGIC_V2: return MavlinkPacket.fromV2Bytes(frame); } in.drop(); } throw new EOFException("End of stream"); } MavlinkPacketReader(InputStream in); MavlinkPacket next(); void drop();  }