Liking cljdoc? Tell your friends :D

mavlink.core


BUFFER-SIZEclj

source

get-descriptionclj

(get-description {:keys [descriptions] :as mavlink} msg-key)

Return the description, only useful if descriptions were saved. Otherwise nil is returned.

Return the description, only useful if descriptions were saved.
Otherwise nil is returned.
sourceraw docstring

get-enumclj

(get-enum mavlink group-id v)

Look up value in an enum group and return the enum-key for that value. nil in case of error.

Look up value in an enum group and return the enum-key for that value.
nil in case of error.
sourceraw docstring

get-enum-groupclj

(get-enum-group mavlink group-id)

Given a group id, return the map of key/values for that group.

Given a group id, return the map of key/values for that group.
sourceraw docstring

INCOMPAT-FLAG-SIGNEDclj

source

MAVLINK1-HDR-CRC-SIZEclj

source

MAVLINK1-HDR-SIZEclj

source

MAVLINK1-START-BYTEclj

source

MAVLINK1-START-VALUEclj

source

MAVLINK2-HDR-CRC-SIGN-SIZEclj

source

MAVLINK2-HDR-CRC-SIZEclj

source

MAVLINK2-HDR-SIZEclj

source

MAVLINK2-SIGN-SIZEclj

source

MAVLINK2-START-BYTEclj

source

MAVLINK2-START-VALUEclj

source

ONE-MINUTEclj

source

open-channelclj

(open-channel mavlink
              {:keys [component-id decode-input-stream decode-output-channel
                      encode-input-channel encode-output-link exception-handler
                      link-id protocol report-error signing-options system-id
                      tlog-stream]
               :as options})

Given a mavlink (the result of parse), and the open channel options an encode and a decode thread are started. A map is returned with the following bindings: :statistics - the atom the encode/decode threads will update with encoding/decoding statistics :close-channel-fn - a function with no arguments to call to close the channel, in other words to stop the encoding/decoding threads.

A note about MAVlink message protocol. Messages are (en/de)coded based on the current protocol and the value of the secret-key.

If the protocol is :mavlink1 then messages are encoded MAVlink 1 and all received messages are expected to be MAVlink 1, until a MAVlink 2 message is received. If the message is successfully decoded, this will change the protocol to :mavlink2.

If the protocol is :mavlink2, then all messages will be encoded MAVlink 2. Whether the message is signed or not is controlled by the secret key in the signing options. If the key is not nil, the message is signed.

Once the secret key is set it is never cleared, and only updated when a signed MAVlink 2 message's signature is successfully decrypted using a different key, then the secret key is updated to the key used to decrypt the signature.

Thus, the MAVlink protocol is either :mavlink1, :mavlink2 without signing (because the secret key is nil) or :mavlink2 with signing (because the secret key is set). And the protocol can only move forward through those 'states'. Thus the application can start using MAVlink 1 MAVlink 2 signed or unsigned by setting the procotol and secret-key. Once running, the decoding process itself will update the protocol based on the decoding process.

The accept-message-handler provides a method for the application to indicate whether or not to accept a message that is MAVlink 1 when the current protocol is MAVlink 2. Or the message is unsigned when it should be signed. Of it is signed and no key was found to decode it. The handler is called with one argument, a message map with the following fields: :message'id - from the message :sequence'id - from the message :system'id - from the message :component'id - from the message :current'protocol - :mavlink1 or :mavlink2 :signed'message - true or false The handler should return true if the message should be accepted, false otherwise.

mavlink - is the mavlink map returned by a call to parse. options - is a hashmap of channel options accept-message-handler- a function to all to ask the application whether to accept a message that it would otherwise drop. component-id - the encode component id decode-input-stream - the stream to read bytes to decode from decode-output-channel - the channel to write decoded messages to encode-input-channel - the channel to receive messages to decode on encode-output-link - either an output stream to write the encoded bytes to or a channel to write the encoded byte array to (anything else will cause an exception) exception-handler - exception handler function, if nil the exception is thrown otherwise this function is called with the exception as the sole argument. Exception's generally will be an IException, the ex-data map will have :cause, :message (if the message is known), and :exception. link-id - the encode link id, if not given and protocol is :mavlink2, then 0 is used protocol - the encode protocol to use :mavlink1 - decode mavlink1 ignore mavlink2 messages :mavlink2 - decode mavlink2 using signing options report-error - function to report non-fatal errors and exceptions, particularly encoding errors, it is passed an IException (see exception -handler for a description of the error data message map bindings. signing-options { secret-key - The current secret-key to use to encode, the first key to try when decoding signed messages. The secret-key can be set on open-channel. When signed messages are decoded, the secret-key is set to the key that was used to validate the signature. If signed message cannot be validated with any keys, then the secret-key is not updated. secret-keyset - a sequable collection of valid keys while decoding, if the currnet secret-key fails to validate the message, all the keys will be tried in order. If no valid key is found the secret-key is not updated, if a valid key is found the secret-key is updated. accept-message-handler - a function to all if the message header indicates the message is not of the expected protocol. } system-id - the encode system id tlog-stream - OutputStream to write telemetry log to. Should be nil if no telemetry log is desired.

For encodingMAVLink 2.0: The system-id and component-id are taken from the channel, but maybe provided in the encode message-map. Note that if signing is active (i.e. the secret-key has a value) then the link-id must be given in the message-map, otherwise the default value will be used for the link id (see the encode function.) Timestamps just indicate forward progression (once a timestamp is seen, ignore anything earlier). So, the initial values of the encoding timestamp is 0. See the sign-packet function for timestamping for encoding.

Given a mavlink (the result of parse), and the open channel options
 an encode and a decode thread are started. A map is returned with
 the following bindings:
   :statistics - the atom the encode/decode threads will update with 
                 encoding/decoding statistics
   :close-channel-fn - a function with no arguments to call to close
                 the channel, in other words to stop the encoding/decoding
                 threads.

A note about MAVlink message protocol.
   Messages are (en/de)coded based on the current protocol and the value
   of the secret-key.

   If the protocol is :mavlink1 then messages are encoded MAVlink 1 and
   all received messages are expected to be MAVlink 1, until a MAVlink 2
   message is received. If the message is successfully decoded,
   this will change the protocol to :mavlink2.

   If the protocol is :mavlink2, then all messages will be encoded MAVlink 2.
   Whether the message is signed or not is controlled by the secret key in the
   signing options. If the key is not nil, the message is signed.

   Once the secret key is set it is never cleared, and only updated when a
   signed MAVlink 2 message's signature is successfully decrypted using a
   different key, then the secret key is updated to the key used to decrypt
   the signature.

   Thus, the MAVlink protocol is either :mavlink1, :mavlink2 without
   signing (because the secret key is nil) or :mavlink2 with signing
   (because the secret key is set). And the protocol can only move forward
   through those 'states'. Thus the application can start using MAVlink 1
   MAVlink 2 signed or unsigned by setting the procotol and secret-key.
   Once running, the decoding process itself will update the protocol
   based on the decoding process. 

   The accept-message-handler provides a method for the application to
   indicate whether or not to accept a message that is MAVlink 1 when the
   current protocol is MAVlink 2. Or the message is unsigned when it should
   be signed. Of it is signed and no key was found to decode it. The handler
   is called with one argument, a message map with the following fields:
                                    :message'id       - from the message
                                    :sequence'id      - from the message
                                    :system'id        - from the message
                                    :component'id     - from the message
                                    :current'protocol - :mavlink1 or :mavlink2
                                    :signed'message   - true or false
   The handler should return true if the message should be accepted,
   false otherwise.

   
 mavlink - is the mavlink map returned by a call to parse.
 options - is a hashmap of channel options
   accept-message-handler- a function to all to ask the application whether
                           to accept a message that it would otherwise drop.
   component-id          - the encode component id
   decode-input-stream   - the stream to read bytes to decode from
   decode-output-channel - the channel to write decoded messages to
   encode-input-channel  - the channel to receive messages to decode on
   encode-output-link    - either an output stream to write the encoded bytes to
                           or a channel to write the encoded byte array to
                           (anything else will cause an exception)
   exception-handler     - exception handler function,
                           if nil the exception is thrown
                           otherwise this function is called with the exception
                           as the sole argument. Exception's generally will
                           be an IException, the ex-data map will have :cause,
                           :message (if the message is known), and :exception.
   link-id               - the encode link id, if not given and protocol 
                           is :mavlink2, then 0 is used
   protocol              - the encode protocol to use
                           :mavlink1 - decode mavlink1 ignore mavlink2 messages
                           :mavlink2 - decode mavlink2 using signing options
   report-error          - function to report non-fatal errors and exceptions,
                           particularly encoding errors, it is passed an IException
                           (see exception -handler for a description of the error
                           data message map bindings.
   signing-options {
       secret-key        - The current secret-key to use to encode, the
                           first key to try when decoding signed messages.
                           The secret-key can be set on open-channel.
                           When signed messages are decoded, the secret-key
                           is set to the key that was used to validate the
                           signature. If signed message cannot be validated
                           with any keys, then the secret-key is not updated.
       secret-keyset     - a sequable collection of valid keys
                           while decoding, if the currnet secret-key fails to
                           validate the message, all the keys will be tried in
                           order. If no valid key is found the secret-key is
                           not updated, if a valid key is found the secret-key is updated.
       accept-message-handler - a function to all if the message header
                                indicates the message is not of the expected
                                protocol.
       }
   system-id             - the encode system id
   tlog-stream           - OutputStream to write telemetry log to. Should be nil if
                           no telemetry log is desired.

 For encodingMAVLink 2.0:
   The system-id and component-id are taken from the channel, but maybe
   provided in the encode message-map. Note that if signing is active
   (i.e. the secret-key has a value) then the link-id must be given in the
   message-map, otherwise the default value will be used for the link id
   (see the encode function.)
   Timestamps just indicate forward progression (once a timestamp is seen,
   ignore anything earlier). So, the initial values of the encoding timestamp
   is 0. See the sign-packet function for timestamping for encoding.
 
sourceraw docstring

parseclj

(parse {:keys [descriptions xml-sources] :as options})

Given a map with the specifications for a mavlink instance, return a map of the mavlink instance.

The map should contain the following bindings:

:descriptions - true or false indicating whether to save descriptions :xml-sources - either a vector of 1 or more maps holding the XML sources: [{:xml-file - holds the filename of the XML file :xml-source - An XML source suitable for clojure.data.xml/parse }] or a vector of 1 or more XML sources

For example: {:xml-sources [{:xml-file test-parse.xml :xml-source (-> test/resources/test-parse.xml io/input-stream)}] :descriptions true}

Possible :cause failures from ExceptionInfo exceptions: :bad-checksum - obviously a bad checksum :enum-conflicts - there is a name conflict in the enumerated types :message-id-conflicts - there is a conflict with the message id values in an XML file :message-name-conflicts - there is a conflict witht he message names in an XML file :missing-xml-include - an XML file is included, but no source was identified for this file :missing-xml-file-id - an XML source is missing an XML file indicator :no-read-fn - the type is missing a read function :no-write-fn - the type is missing a write function :null-pointer - obviously a null pointer :string-not-number - string conversion to a number failed usually due to non numeric characters :undefined-enum - A message value uses an unidentified enumerated value :unknown-type - unknown type specifier in an XML file

Given a map with the specifications for a mavlink instance, return a
 map of the mavlink instance.

 The map should contain the following bindings:

 :descriptions - true or false indicating whether to save descriptions
 :xml-sources    - either a vector of 1 or more maps holding the XML sources:
    [{:xml-file     - holds the filename of the XML file
      :xml-source - An XML source suitable for clojure.data.xml/parse
      }]
                   or a vector of 1 or more XML sources

For example: {:xml-sources [{:xml-file test-parse.xml
                             :xml-source (-> test/resources/test-parse.xml
                                             io/input-stream)}]
              :descriptions true}

Possible :cause failures from ExceptionInfo exceptions:
  :bad-checksum           - obviously a bad checksum
  :enum-conflicts         - there is a name conflict in the enumerated types
  :message-id-conflicts   - there is a conflict with the message id values
                            in an XML file
  :message-name-conflicts - there is a conflict witht he message names in
                            an XML file
  :missing-xml-include    - an XML file is included, but no source was
                            identified for this file
  :missing-xml-file-id    - an XML source is missing an XML file indicator
  :no-read-fn             - the type is missing a read function
  :no-write-fn            - the type is missing a write function
  :null-pointer           - obviously a null pointer
  :string-not-number      - string conversion to a number failed usually
                            due to non numeric characters
  :undefined-enum         - A message value uses an unidentified
                            enumerated value
  :unknown-type           - unknown type specifier in an XML file
sourceraw docstring

SIGN-PACKETS-FLAGclj

source

update-decode-statisticsclj

(update-decode-statistics system-id sequence-id statistics)
source

write-tlogcljmacro

(write-tlog tlog packet length)

Write timestamp and packet to DataOutputStream.

Write timestamp and packet to DataOutputStream.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close