Exemplo n.º 1
0
 /** Encode message with raw data and other informations */
 public byte[] encode() throws IOException {
   byte[] buffer = new byte[8 + 16];
   LittleEndianDataOutputStream dos =
       new LittleEndianDataOutputStream(new ByteArrayOutputStream());
   dos.writeByte((byte) 0xFE);
   dos.writeByte(length & 0x00FF);
   dos.writeByte(sequence & 0x00FF);
   dos.writeByte(sysId & 0x00FF);
   dos.writeByte(componentId & 0x00FF);
   dos.writeByte(messageType & 0x00FF);
   dos.writeLong(tc1);
   dos.writeLong(ts1);
   dos.flush();
   byte[] tmp = dos.toByteArray();
   for (int b = 0; b < tmp.length; b++) buffer[b] = tmp[b];
   int crc = MAVLinkCRC.crc_calculate_encode(buffer, 16);
   crc = MAVLinkCRC.crc_accumulate((byte) IMAVLinkCRC.MAVLINK_MESSAGE_CRCS[messageType], crc);
   byte crcl = (byte) (crc & 0x00FF);
   byte crch = (byte) ((crc >> 8) & 0x00FF);
   buffer[22] = crcl;
   buffer[23] = crch;
   dos.close();
   return buffer;
 }
Exemplo n.º 2
0
 /** Encode message with raw data and other informations */
 public byte[] encode() throws IOException {
   byte[] buffer = new byte[8 + 21];
   LittleEndianDataOutputStream dos =
       new LittleEndianDataOutputStream(new ByteArrayOutputStream());
   dos.writeByte((byte) 0xFE);
   dos.writeByte(length & 0x00FF);
   dos.writeByte(sequence & 0x00FF);
   dos.writeByte(sysId & 0x00FF);
   dos.writeByte(componentId & 0x00FF);
   dos.writeByte(messageType & 0x00FF);
   dos.writeFloat(roll);
   dos.writeFloat(pitch);
   dos.writeFloat(yaw);
   dos.writeFloat(thrust);
   dos.writeByte(target & 0x00FF);
   dos.writeByte(roll_manual & 0x00FF);
   dos.writeByte(pitch_manual & 0x00FF);
   dos.writeByte(yaw_manual & 0x00FF);
   dos.writeByte(thrust_manual & 0x00FF);
   dos.flush();
   byte[] tmp = dos.toByteArray();
   for (int b = 0; b < tmp.length; b++) buffer[b] = tmp[b];
   int crc = MAVLinkCRC.crc_calculate_encode(buffer, 21);
   crc = MAVLinkCRC.crc_accumulate((byte) IMAVLinkCRC.MAVLINK_MESSAGE_CRCS[messageType], crc);
   byte crcl = (byte) (crc & 0x00FF);
   byte crch = (byte) ((crc >> 8) & 0x00FF);
   buffer[27] = crcl;
   buffer[28] = crch;
   dos.close();
   return buffer;
 }
 /** Encode message with raw data and other informations */
 public byte[] encode() throws IOException {
   byte[] buffer = new byte[8 + 43];
   LittleEndianDataOutputStream dos =
       new LittleEndianDataOutputStream(new ByteArrayOutputStream());
   dos.writeByte((byte) 0xFE);
   dos.writeByte(length & 0x00FF);
   dos.writeByte(sequence & 0x00FF);
   dos.writeByte(sysId & 0x00FF);
   dos.writeByte(componentId & 0x00FF);
   dos.writeByte(messageType & 0x00FF);
   dos.writeFloat(x);
   dos.writeFloat(y);
   dos.writeFloat(z);
   dos.writeShort(timeout & 0x00FFFF);
   dos.writeByte(type & 0x00FF);
   dos.writeByte(color & 0x00FF);
   dos.writeByte(coordinate_system & 0x00FF);
   for (int i = 0; i < 26; i++) {
     dos.writeByte(name[i]);
   }
   dos.flush();
   byte[] tmp = dos.toByteArray();
   for (int b = 0; b < tmp.length; b++) buffer[b] = tmp[b];
   int crc = MAVLinkCRC.crc_calculate_encode(buffer, 43);
   crc = MAVLinkCRC.crc_accumulate((byte) IMAVLinkCRC.MAVLINK_MESSAGE_CRCS[messageType], crc);
   byte crcl = (byte) (crc & 0x00FF);
   byte crch = (byte) ((crc >> 8) & 0x00FF);
   buffer[49] = crcl;
   buffer[50] = crch;
   dos.close();
   return buffer;
 }
Exemplo n.º 4
0
 /** Encode message with raw data and other informations */
 public byte[] encode() throws IOException {
   byte[] buffer = new byte[12 + 2];
   LittleEndianDataOutputStream dos =
       new LittleEndianDataOutputStream(new ByteArrayOutputStream());
   dos.writeByte((byte) 0xFD);
   dos.writeByte(length & 0x00FF);
   dos.writeByte(incompat & 0x00FF);
   dos.writeByte(compat & 0x00FF);
   dos.writeByte(packet & 0x00FF);
   dos.writeByte(sysId & 0x00FF);
   dos.writeByte(componentId & 0x00FF);
   dos.writeByte(messageType & 0x00FF);
   dos.writeByte((messageType >> 8) & 0x00FF);
   dos.writeByte((messageType >> 16) & 0x00FF);
   dos.writeByte(target_system & 0x00FF);
   dos.writeByte(target_component & 0x00FF);
   dos.flush();
   byte[] tmp = dos.toByteArray();
   for (int b = 0; b < tmp.length; b++) buffer[b] = tmp[b];
   int crc = MAVLinkCRC.crc_calculate_encode(buffer, 2);
   crc = MAVLinkCRC.crc_accumulate((byte) IMAVLinkCRC.MAVLINK_MESSAGE_CRCS[messageType], crc);
   byte crcl = (byte) (crc & 0x00FF);
   byte crch = (byte) ((crc >> 8) & 0x00FF);
   buffer[12] = crcl;
   buffer[13] = crch;
   dos.close();
   return buffer;
 }
 /** Encode message with raw data and other informations */
 public byte[] encode() throws IOException {
   byte[] buffer = new byte[12 + 28];
   LittleEndianDataOutputStream dos =
       new LittleEndianDataOutputStream(new ByteArrayOutputStream());
   dos.writeByte((byte) 0xFD);
   dos.writeByte(length & 0x00FF);
   dos.writeByte(incompat & 0x00FF);
   dos.writeByte(compat & 0x00FF);
   dos.writeByte(packet & 0x00FF);
   dos.writeByte(sysId & 0x00FF);
   dos.writeByte(componentId & 0x00FF);
   dos.writeByte(messageType & 0x00FF);
   dos.writeByte((messageType >> 8) & 0x00FF);
   dos.writeByte((messageType >> 16) & 0x00FF);
   dos.writeInt((int) (time_boot_ms & 0x00FFFFFFFF));
   dos.writeFloat(x);
   dos.writeFloat(y);
   dos.writeFloat(z);
   dos.writeFloat(roll);
   dos.writeFloat(pitch);
   dos.writeFloat(yaw);
   dos.flush();
   byte[] tmp = dos.toByteArray();
   for (int b = 0; b < tmp.length; b++) buffer[b] = tmp[b];
   int crc = MAVLinkCRC.crc_calculate_encode(buffer, 28);
   crc = MAVLinkCRC.crc_accumulate((byte) IMAVLinkCRC.MAVLINK_MESSAGE_CRCS[messageType], crc);
   byte crcl = (byte) (crc & 0x00FF);
   byte crch = (byte) ((crc >> 8) & 0x00FF);
   buffer[38] = crcl;
   buffer[39] = crch;
   dos.close();
   return buffer;
 }
Exemplo n.º 6
0
 /** Encode message with raw data and other informations */
 public byte[] encode() throws IOException {
   byte[] buffer = new byte[12 + 23];
   LittleEndianDataOutputStream dos =
       new LittleEndianDataOutputStream(new ByteArrayOutputStream());
   dos.writeByte((byte) 0xFD);
   dos.writeByte(length & 0x00FF);
   dos.writeByte(incompat & 0x00FF);
   dos.writeByte(compat & 0x00FF);
   dos.writeByte(packet & 0x00FF);
   dos.writeByte(sysId & 0x00FF);
   dos.writeByte(componentId & 0x00FF);
   dos.writeByte(messageType & 0x00FF);
   dos.writeByte((messageType >> 8) & 0x00FF);
   dos.writeByte((messageType >> 16) & 0x00FF);
   dos.writeInt((int) (time_boot_ms & 0x00FFFFFFFF));
   dos.writeFloat(image_interval);
   dos.writeFloat(video_framerate);
   dos.writeShort(image_resolution_h & 0x00FFFF);
   dos.writeShort(image_resolution_v & 0x00FFFF);
   dos.writeShort(video_resolution_h & 0x00FFFF);
   dos.writeShort(video_resolution_v & 0x00FFFF);
   dos.writeByte(camera_id & 0x00FF);
   dos.writeByte(image_status & 0x00FF);
   dos.writeByte(video_status & 0x00FF);
   dos.flush();
   byte[] tmp = dos.toByteArray();
   for (int b = 0; b < tmp.length; b++) buffer[b] = tmp[b];
   int crc = MAVLinkCRC.crc_calculate_encode(buffer, 23);
   crc = MAVLinkCRC.crc_accumulate((byte) IMAVLinkCRC.MAVLINK_MESSAGE_CRCS[messageType], crc);
   byte crcl = (byte) (crc & 0x00FF);
   byte crch = (byte) ((crc >> 8) & 0x00FF);
   buffer[33] = crcl;
   buffer[34] = crch;
   dos.close();
   return buffer;
 }
Exemplo n.º 7
0
 /** Encode message with raw data and other informations */
 public byte[] encode() throws IOException {
   byte[] buffer = new byte[8 + 35];
   LittleEndianDataOutputStream dos =
       new LittleEndianDataOutputStream(new ByteArrayOutputStream());
   dos.writeByte((byte) 0xFE);
   dos.writeByte(length & 0x00FF);
   dos.writeByte(sequence & 0x00FF);
   dos.writeByte(sysId & 0x00FF);
   dos.writeByte(componentId & 0x00FF);
   dos.writeByte(messageType & 0x00FF);
   dos.writeFloat(param1);
   dos.writeFloat(param2);
   dos.writeFloat(param3);
   dos.writeFloat(param4);
   dos.writeInt((int) (x & 0x00FFFFFFFF));
   dos.writeInt((int) (y & 0x00FFFFFFFF));
   dos.writeFloat(z);
   dos.writeShort(command & 0x00FFFF);
   dos.writeByte(target_system & 0x00FF);
   dos.writeByte(target_component & 0x00FF);
   dos.writeByte(frame & 0x00FF);
   dos.writeByte(current & 0x00FF);
   dos.writeByte(autocontinue & 0x00FF);
   dos.flush();
   byte[] tmp = dos.toByteArray();
   for (int b = 0; b < tmp.length; b++) buffer[b] = tmp[b];
   int crc = MAVLinkCRC.crc_calculate_encode(buffer, 35);
   crc = MAVLinkCRC.crc_accumulate((byte) IMAVLinkCRC.MAVLINK_MESSAGE_CRCS[messageType], crc);
   byte crcl = (byte) (crc & 0x00FF);
   byte crch = (byte) ((crc >> 8) & 0x00FF);
   buffer[41] = crcl;
   buffer[42] = crch;
   dos.close();
   return buffer;
 }