/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* java mavlink generator tool. It should not be modified by hand.
*/
// MESSAGE GIMBAL_SET_FACTORY_PARAMETERS PACKING
package com.MAVLink.ardupilotmega;
import com.MAVLink.MAVLinkPacket;
import com.MAVLink.Parser;
import com.MAVLink.ardupilotmega.CRC;
import java.nio.ByteBuffer;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
/**
*
Set factory configuration parameters (such as assembly date and time, and serial number). This is only intended to be used
during manufacture, not by end users, so it is protected by a simple checksum of sorts (this won't stop anybody determined,
it's mostly just to keep the average user from trying to modify these values. This will need to be revisited if that isn't
adequate.
*/
public class msg_gimbal_set_factory_parameters_test{
public static final int MAVLINK_MSG_ID_GIMBAL_SET_FACTORY_PARAMETERS = 206;
public static final int MAVLINK_MSG_LENGTH = 33;
private static final long serialVersionUID = MAVLINK_MSG_ID_GIMBAL_SET_FACTORY_PARAMETERS;
private Parser parser = new Parser();
public CRC generateCRC(byte[] packet){
CRC crc = new CRC();
for (int i = 1; i < packet.length - 2; i++) {
crc.update_checksum(packet[i] & 0xFF);
}
crc.finish_checksum(MAVLINK_MSG_ID_GIMBAL_SET_FACTORY_PARAMETERS);
return crc;
}
public byte[] generateTestPacket(){
ByteBuffer payload = ByteBuffer.allocate(6 + MAVLINK_MSG_LENGTH + 2);
payload.put((byte)MAVLinkPacket.MAVLINK_STX); //stx
payload.put((byte)MAVLINK_MSG_LENGTH); //len
payload.put((byte)0); //seq
payload.put((byte)255); //sysid
payload.put((byte)190); //comp id
payload.put((byte)MAVLINK_MSG_ID_GIMBAL_SET_FACTORY_PARAMETERS); //msg id
payload.putInt((int)963497464); //magic_1
payload.putInt((int)963497672); //magic_2
payload.putInt((int)963497880); //magic_3
payload.putInt((int)963498088); //serial_number_pt_1
payload.putInt((int)963498296); //serial_number_pt_2
payload.putInt((int)963498504); //serial_number_pt_3
payload.putShort((short)18483); //assembly_year
payload.put((byte)211); //target_system
payload.put((byte)22); //target_component
payload.put((byte)89); //assembly_month
payload.put((byte)156); //assembly_day
payload.put((byte)223); //assembly_hour
payload.put((byte)34); //assembly_minute
payload.put((byte)101); //assembly_second
CRC crc = generateCRC(payload.array());
payload.put((byte)crc.getLSB());
payload.put((byte)crc.getMSB());
return payload.array();
}
@Test
public void test(){
byte[] packet = generateTestPacket();
for(int i = 0; i < packet.length - 1; i++){
parser.mavlink_parse_char(packet[i] & 0xFF);
}
MAVLinkPacket m = parser.mavlink_parse_char(packet[packet.length - 1] & 0xFF);
byte[] processedPacket = m.encodePacket();
assertArrayEquals("msg_gimbal_set_factory_parameters", processedPacket, packet);
}
}