NAME

UAV::Pilot::ArdupilotProtocol::Packet

DESCRIPTION

Role for ArdupilotProtocol packets. These are based on the ArduPilot protocol packets, as described here:

http://code.google.com/p/ardupilot-mega/wiki/Protocol

No attempts have yet been made to test this against an existing ArduPilot implmentation, but it should be close.

Do not create Packets directly. Instead, use UAV::Pilot::ArdupilotProtocol::PacketFactory.

Does the UAV::Pilot::Logger role.

METHODS

write

write( $fh )

Writes the packet to the given filehandle.

make_checksum_clean

Recalculates the checksum based on current field values.

make_byte_vector

Returns the packet fields in a single scalar full of bytes.

get_ordered_payload_vales

Returns the packet field values in the order they appear in payload_fields().

get_ordered_payload_value_bytes

Returns a byte array of all the packet fields in the order they appear in payload_fields().

make_packet_queue_map_key

Creates a unique key for this packet.

ATTRIBUTES

preamble

Fixed bytes that start every packet

version

Protocol version

checksum1

First checksum byte

checksum2

Second checksum byte

REQUIRED METHODS/ATTRIBUTES

message_id

ID for this type of message

payload_fields

Arrayref. A list of field names in the order they appear in the packet.

payload_length

Hashref. Keys match to an entry in payload_fields. Values are the length in bytes of that field.