github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/common/enum_mav_protocol_capability.go (about)

     1  //autogenerated:yes
     2  //nolint:revive,misspell,govet,lll,dupl,gocritic
     3  package common
     4  
     5  import (
     6  	"fmt"
     7  	"strconv"
     8  	"strings"
     9  )
    10  
    11  // Bitmask of (optional) autopilot capabilities (64 bit). If a bit is set, the autopilot supports this capability.
    12  type MAV_PROTOCOL_CAPABILITY uint64
    13  
    14  const (
    15  	// Autopilot supports the MISSION_ITEM float message type.
    16  	// Note that MISSION_ITEM is deprecated, and autopilots should use MISSION_INT instead.
    17  	MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT MAV_PROTOCOL_CAPABILITY = 1
    18  	// Autopilot supports the new param float message type.
    19  	MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT MAV_PROTOCOL_CAPABILITY = 2
    20  	// Autopilot supports MISSION_ITEM_INT scaled integer message type.
    21  	// Note that this flag must always be set if missions are supported, because missions must always use MISSION_ITEM_INT (rather than MISSION_ITEM, which is deprecated).
    22  	MAV_PROTOCOL_CAPABILITY_MISSION_INT MAV_PROTOCOL_CAPABILITY = 4
    23  	// Autopilot supports COMMAND_INT scaled integer message type.
    24  	MAV_PROTOCOL_CAPABILITY_COMMAND_INT MAV_PROTOCOL_CAPABILITY = 8
    25  	// Parameter protocol uses byte-wise encoding of parameter values into param_value (float) fields: https://mavlink.io/en/services/parameter.html#parameter-encoding.
    26  	// Note that either this flag or MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST should be set if the parameter protocol is supported.
    27  	MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_BYTEWISE MAV_PROTOCOL_CAPABILITY = 16
    28  	// Autopilot supports the File Transfer Protocol v1: https://mavlink.io/en/services/ftp.html.
    29  	MAV_PROTOCOL_CAPABILITY_FTP MAV_PROTOCOL_CAPABILITY = 32
    30  	// Autopilot supports commanding attitude offboard.
    31  	MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET MAV_PROTOCOL_CAPABILITY = 64
    32  	// Autopilot supports commanding position and velocity targets in local NED frame.
    33  	MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED MAV_PROTOCOL_CAPABILITY = 128
    34  	// Autopilot supports commanding position and velocity targets in global scaled integers.
    35  	MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT MAV_PROTOCOL_CAPABILITY = 256
    36  	// Autopilot supports terrain protocol / data handling.
    37  	MAV_PROTOCOL_CAPABILITY_TERRAIN MAV_PROTOCOL_CAPABILITY = 512
    38  	// Reserved for future use.
    39  	MAV_PROTOCOL_CAPABILITY_RESERVED3 MAV_PROTOCOL_CAPABILITY = 1024
    40  	// Autopilot supports the MAV_CMD_DO_FLIGHTTERMINATION command (flight termination).
    41  	MAV_PROTOCOL_CAPABILITY_FLIGHT_TERMINATION MAV_PROTOCOL_CAPABILITY = 2048
    42  	// Autopilot supports onboard compass calibration.
    43  	MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION MAV_PROTOCOL_CAPABILITY = 4096
    44  	// Autopilot supports MAVLink version 2.
    45  	MAV_PROTOCOL_CAPABILITY_MAVLINK2 MAV_PROTOCOL_CAPABILITY = 8192
    46  	// Autopilot supports mission fence protocol.
    47  	MAV_PROTOCOL_CAPABILITY_MISSION_FENCE MAV_PROTOCOL_CAPABILITY = 16384
    48  	// Autopilot supports mission rally point protocol.
    49  	MAV_PROTOCOL_CAPABILITY_MISSION_RALLY MAV_PROTOCOL_CAPABILITY = 32768
    50  	// Reserved for future use.
    51  	MAV_PROTOCOL_CAPABILITY_RESERVED2 MAV_PROTOCOL_CAPABILITY = 65536
    52  	// Parameter protocol uses C-cast of parameter values to set the param_value (float) fields: https://mavlink.io/en/services/parameter.html#parameter-encoding.
    53  	// Note that either this flag or MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_BYTEWISE should be set if the parameter protocol is supported.
    54  	MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST MAV_PROTOCOL_CAPABILITY = 131072
    55  )
    56  
    57  var labels_MAV_PROTOCOL_CAPABILITY = map[MAV_PROTOCOL_CAPABILITY]string{
    58  	MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT:                  "MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT",
    59  	MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT:                    "MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT",
    60  	MAV_PROTOCOL_CAPABILITY_MISSION_INT:                    "MAV_PROTOCOL_CAPABILITY_MISSION_INT",
    61  	MAV_PROTOCOL_CAPABILITY_COMMAND_INT:                    "MAV_PROTOCOL_CAPABILITY_COMMAND_INT",
    62  	MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_BYTEWISE:          "MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_BYTEWISE",
    63  	MAV_PROTOCOL_CAPABILITY_FTP:                            "MAV_PROTOCOL_CAPABILITY_FTP",
    64  	MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET:            "MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET",
    65  	MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED:  "MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED",
    66  	MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT: "MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT",
    67  	MAV_PROTOCOL_CAPABILITY_TERRAIN:                        "MAV_PROTOCOL_CAPABILITY_TERRAIN",
    68  	MAV_PROTOCOL_CAPABILITY_RESERVED3:                      "MAV_PROTOCOL_CAPABILITY_RESERVED3",
    69  	MAV_PROTOCOL_CAPABILITY_FLIGHT_TERMINATION:             "MAV_PROTOCOL_CAPABILITY_FLIGHT_TERMINATION",
    70  	MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION:            "MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION",
    71  	MAV_PROTOCOL_CAPABILITY_MAVLINK2:                       "MAV_PROTOCOL_CAPABILITY_MAVLINK2",
    72  	MAV_PROTOCOL_CAPABILITY_MISSION_FENCE:                  "MAV_PROTOCOL_CAPABILITY_MISSION_FENCE",
    73  	MAV_PROTOCOL_CAPABILITY_MISSION_RALLY:                  "MAV_PROTOCOL_CAPABILITY_MISSION_RALLY",
    74  	MAV_PROTOCOL_CAPABILITY_RESERVED2:                      "MAV_PROTOCOL_CAPABILITY_RESERVED2",
    75  	MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST:            "MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST",
    76  }
    77  
    78  var values_MAV_PROTOCOL_CAPABILITY = map[string]MAV_PROTOCOL_CAPABILITY{
    79  	"MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT":                  MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT,
    80  	"MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT":                    MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT,
    81  	"MAV_PROTOCOL_CAPABILITY_MISSION_INT":                    MAV_PROTOCOL_CAPABILITY_MISSION_INT,
    82  	"MAV_PROTOCOL_CAPABILITY_COMMAND_INT":                    MAV_PROTOCOL_CAPABILITY_COMMAND_INT,
    83  	"MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_BYTEWISE":          MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_BYTEWISE,
    84  	"MAV_PROTOCOL_CAPABILITY_FTP":                            MAV_PROTOCOL_CAPABILITY_FTP,
    85  	"MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET":            MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET,
    86  	"MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED":  MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED,
    87  	"MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT": MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT,
    88  	"MAV_PROTOCOL_CAPABILITY_TERRAIN":                        MAV_PROTOCOL_CAPABILITY_TERRAIN,
    89  	"MAV_PROTOCOL_CAPABILITY_RESERVED3":                      MAV_PROTOCOL_CAPABILITY_RESERVED3,
    90  	"MAV_PROTOCOL_CAPABILITY_FLIGHT_TERMINATION":             MAV_PROTOCOL_CAPABILITY_FLIGHT_TERMINATION,
    91  	"MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION":            MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION,
    92  	"MAV_PROTOCOL_CAPABILITY_MAVLINK2":                       MAV_PROTOCOL_CAPABILITY_MAVLINK2,
    93  	"MAV_PROTOCOL_CAPABILITY_MISSION_FENCE":                  MAV_PROTOCOL_CAPABILITY_MISSION_FENCE,
    94  	"MAV_PROTOCOL_CAPABILITY_MISSION_RALLY":                  MAV_PROTOCOL_CAPABILITY_MISSION_RALLY,
    95  	"MAV_PROTOCOL_CAPABILITY_RESERVED2":                      MAV_PROTOCOL_CAPABILITY_RESERVED2,
    96  	"MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST":            MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST,
    97  }
    98  
    99  // MarshalText implements the encoding.TextMarshaler interface.
   100  func (e MAV_PROTOCOL_CAPABILITY) MarshalText() ([]byte, error) {
   101  	if e == 0 {
   102  		return []byte("0"), nil
   103  	}
   104  	var names []string
   105  	for i := 0; i < 18; i++ {
   106  		mask := MAV_PROTOCOL_CAPABILITY(1 << i)
   107  		if e&mask == mask {
   108  			names = append(names, labels_MAV_PROTOCOL_CAPABILITY[mask])
   109  		}
   110  	}
   111  	return []byte(strings.Join(names, " | ")), nil
   112  }
   113  
   114  // UnmarshalText implements the encoding.TextUnmarshaler interface.
   115  func (e *MAV_PROTOCOL_CAPABILITY) UnmarshalText(text []byte) error {
   116  	labels := strings.Split(string(text), " | ")
   117  	var mask MAV_PROTOCOL_CAPABILITY
   118  	for _, label := range labels {
   119  		if value, ok := values_MAV_PROTOCOL_CAPABILITY[label]; ok {
   120  			mask |= value
   121  		} else if value, err := strconv.Atoi(label); err == nil {
   122  			mask |= MAV_PROTOCOL_CAPABILITY(value)
   123  		} else {
   124  			return fmt.Errorf("invalid label '%s'", label)
   125  		}
   126  	}
   127  	*e = mask
   128  	return nil
   129  }
   130  
   131  // String implements the fmt.Stringer interface.
   132  func (e MAV_PROTOCOL_CAPABILITY) String() string {
   133  	val, _ := e.MarshalText()
   134  	return string(val)
   135  }