Kim Hyeongmin / Mbed 2 deprecated mbed_spatial

Dependencies:   mbed

Fork of mbed_gps3 by Kim Hyeongmin

Committer:
FDLKHM
Date:
Sat May 12 07:28:33 2018 +0000
Revision:
0:0389ce4f9789
This is my code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
FDLKHM 0:0389ce4f9789 1 /****************************************************************/
FDLKHM 0:0389ce4f9789 2 /* */
FDLKHM 0:0389ce4f9789 3 /* Advanced Navigation Packet Protocol Library */
FDLKHM 0:0389ce4f9789 4 /* C Language Dynamic Spatial SDK, Version 4.0 */
FDLKHM 0:0389ce4f9789 5 /* Copyright 2014, Xavier Orr, Advanced Navigation Pty Ltd */
FDLKHM 0:0389ce4f9789 6 /* */
FDLKHM 0:0389ce4f9789 7 /****************************************************************/
FDLKHM 0:0389ce4f9789 8 /*
FDLKHM 0:0389ce4f9789 9 * Copyright (C) 2014 Advanced Navigation Pty Ltd
FDLKHM 0:0389ce4f9789 10 *
FDLKHM 0:0389ce4f9789 11 * Permission is hereby granted, free of charge, to any person obtaining
FDLKHM 0:0389ce4f9789 12 * a copy of this software and associated documentation files (the "Software"),
FDLKHM 0:0389ce4f9789 13 * to deal in the Software without restriction, including without limitation
FDLKHM 0:0389ce4f9789 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
FDLKHM 0:0389ce4f9789 15 * and/or sell copies of the Software, and to permit persons to whom the
FDLKHM 0:0389ce4f9789 16 * Software is furnished to do so, subject to the following conditions:
FDLKHM 0:0389ce4f9789 17 *
FDLKHM 0:0389ce4f9789 18 * The above copyright notice and this permission notice shall be included
FDLKHM 0:0389ce4f9789 19 * in all copies or substantial portions of the Software.
FDLKHM 0:0389ce4f9789 20 *
FDLKHM 0:0389ce4f9789 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
FDLKHM 0:0389ce4f9789 22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FDLKHM 0:0389ce4f9789 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
FDLKHM 0:0389ce4f9789 24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
FDLKHM 0:0389ce4f9789 25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FDLKHM 0:0389ce4f9789 26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
FDLKHM 0:0389ce4f9789 27 * DEALINGS IN THE SOFTWARE.
FDLKHM 0:0389ce4f9789 28 */
FDLKHM 0:0389ce4f9789 29
FDLKHM 0:0389ce4f9789 30 #include <stdint.h>
FDLKHM 0:0389ce4f9789 31 #include <string.h>
FDLKHM 0:0389ce4f9789 32 #include "an_packet_protocol.h"
FDLKHM 0:0389ce4f9789 33 #include "spatial_packets.h"
FDLKHM 0:0389ce4f9789 34
FDLKHM 0:0389ce4f9789 35 /*
FDLKHM 0:0389ce4f9789 36 * This file contains functions to decode and encode packets
FDLKHM 0:0389ce4f9789 37 *
FDLKHM 0:0389ce4f9789 38 * Decode functions take an an_packet_t and turn it into a type specific
FDLKHM 0:0389ce4f9789 39 * to that packet so that the fields can be conveniently accessed. Decode
FDLKHM 0:0389ce4f9789 40 * functions return 0 for success and 1 for failure. Decode functions are
FDLKHM 0:0389ce4f9789 41 * used when receiving packets.
FDLKHM 0:0389ce4f9789 42 *
FDLKHM 0:0389ce4f9789 43 * Example decode
FDLKHM 0:0389ce4f9789 44 *
FDLKHM 0:0389ce4f9789 45 * an_packet_t an_packet
FDLKHM 0:0389ce4f9789 46 * acknowledge_packet_t acknowledge_packet
FDLKHM 0:0389ce4f9789 47 * ...
FDLKHM 0:0389ce4f9789 48 * decode_acknowledge_packet(&acknowledge_packet, &an_packet);
FDLKHM 0:0389ce4f9789 49 * printf("acknowledge id %d with result %d\n", acknowledge_packet.packet_id, acknowledge_packet.acknowledge_result);
FDLKHM 0:0389ce4f9789 50 *
FDLKHM 0:0389ce4f9789 51 * Encode functions take a type specific structure and turn it into an
FDLKHM 0:0389ce4f9789 52 * an_packet_t. Encode functions are used when sending packets. Don't
FDLKHM 0:0389ce4f9789 53 * forget to free the returned packet with an_packet_free().
FDLKHM 0:0389ce4f9789 54 *
FDLKHM 0:0389ce4f9789 55 * Example encode
FDLKHM 0:0389ce4f9789 56 *
FDLKHM 0:0389ce4f9789 57 * an_packet_t *an_packet;
FDLKHM 0:0389ce4f9789 58 * boot_mode_packet_t boot_mode_packet;
FDLKHM 0:0389ce4f9789 59 * ...
FDLKHM 0:0389ce4f9789 60 * boot_mode_packet.boot_mode = boot_mode_bootloader;
FDLKHM 0:0389ce4f9789 61 * an_packet = encode_boot_mode_packet(&boot_mode_packet);
FDLKHM 0:0389ce4f9789 62 * serial_port_transmit(an_packet_pointer(an_packet), an_packet_size(an_packet));
FDLKHM 0:0389ce4f9789 63 * an_packet_free(&an_packet);
FDLKHM 0:0389ce4f9789 64 *
FDLKHM 0:0389ce4f9789 65 */
FDLKHM 0:0389ce4f9789 66
FDLKHM 0:0389ce4f9789 67 int decode_acknowledge_packet(acknowledge_packet_t *acknowledge_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 68 {
FDLKHM 0:0389ce4f9789 69 if (an_packet->id == packet_id_acknowledge && an_packet->length == 4)
FDLKHM 0:0389ce4f9789 70 {
FDLKHM 0:0389ce4f9789 71 acknowledge_packet->packet_id = an_packet->data[0];
FDLKHM 0:0389ce4f9789 72 memcpy(&acknowledge_packet->packet_crc, &an_packet->data[1], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 73 acknowledge_packet->acknowledge_result = an_packet->data[3];
FDLKHM 0:0389ce4f9789 74 return 0;
FDLKHM 0:0389ce4f9789 75 }
FDLKHM 0:0389ce4f9789 76 else return 1;
FDLKHM 0:0389ce4f9789 77 }
FDLKHM 0:0389ce4f9789 78
FDLKHM 0:0389ce4f9789 79 an_packet_t *encode_request_packet(uint8_t requested_packet_id)
FDLKHM 0:0389ce4f9789 80 {
FDLKHM 0:0389ce4f9789 81 an_packet_t *an_packet = an_packet_allocate(1, packet_id_request);
FDLKHM 0:0389ce4f9789 82 an_packet->data[0] = requested_packet_id;
FDLKHM 0:0389ce4f9789 83 return an_packet;
FDLKHM 0:0389ce4f9789 84 }
FDLKHM 0:0389ce4f9789 85
FDLKHM 0:0389ce4f9789 86 int decode_boot_mode_packet(boot_mode_packet_t *boot_mode_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 87 {
FDLKHM 0:0389ce4f9789 88 if (an_packet->id == packet_id_boot_mode && an_packet->length == 1)
FDLKHM 0:0389ce4f9789 89 {
FDLKHM 0:0389ce4f9789 90 boot_mode_packet->boot_mode = an_packet->data[0];
FDLKHM 0:0389ce4f9789 91 return 0;
FDLKHM 0:0389ce4f9789 92 }
FDLKHM 0:0389ce4f9789 93 else return 1;
FDLKHM 0:0389ce4f9789 94 }
FDLKHM 0:0389ce4f9789 95
FDLKHM 0:0389ce4f9789 96 an_packet_t *encode_boot_mode_packet(boot_mode_packet_t *boot_mode_packet)
FDLKHM 0:0389ce4f9789 97 {
FDLKHM 0:0389ce4f9789 98 an_packet_t *an_packet = an_packet_allocate(1, packet_id_boot_mode);
FDLKHM 0:0389ce4f9789 99 an_packet->data[0] = boot_mode_packet->boot_mode;
FDLKHM 0:0389ce4f9789 100 return an_packet;
FDLKHM 0:0389ce4f9789 101 }
FDLKHM 0:0389ce4f9789 102
FDLKHM 0:0389ce4f9789 103 int decode_device_information_packet(device_information_packet_t *device_information_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 104 {
FDLKHM 0:0389ce4f9789 105 if (an_packet->id == packet_id_device_information && an_packet->length == 24)
FDLKHM 0:0389ce4f9789 106 {
FDLKHM 0:0389ce4f9789 107 memcpy(&device_information_packet->software_version, &an_packet->data[0], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 108 memcpy(&device_information_packet->device_id, &an_packet->data[4], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 109 memcpy(&device_information_packet->hardware_revision, &an_packet->data[8], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 110 memcpy(&device_information_packet->serial_number[0], &an_packet->data[12], 3 * sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 111 return 0;
FDLKHM 0:0389ce4f9789 112 }
FDLKHM 0:0389ce4f9789 113 else return 1;
FDLKHM 0:0389ce4f9789 114 }
FDLKHM 0:0389ce4f9789 115
FDLKHM 0:0389ce4f9789 116 an_packet_t *encode_restore_factory_settings_packet()
FDLKHM 0:0389ce4f9789 117 {
FDLKHM 0:0389ce4f9789 118 uint32_t verification = 0x85429E1C;
FDLKHM 0:0389ce4f9789 119 an_packet_t *an_packet = an_packet_allocate(4, packet_id_restore_factory_settings);
FDLKHM 0:0389ce4f9789 120 memcpy(&an_packet->data[0], &verification, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 121 return an_packet;
FDLKHM 0:0389ce4f9789 122 }
FDLKHM 0:0389ce4f9789 123
FDLKHM 0:0389ce4f9789 124 an_packet_t *encode_reset_packet()
FDLKHM 0:0389ce4f9789 125 {
FDLKHM 0:0389ce4f9789 126 uint32_t verification = 0x21057A7E;
FDLKHM 0:0389ce4f9789 127 an_packet_t *an_packet = an_packet_allocate(4, packet_id_reset);
FDLKHM 0:0389ce4f9789 128 memcpy(&an_packet->data[0], &verification, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 129 return an_packet;
FDLKHM 0:0389ce4f9789 130 }
FDLKHM 0:0389ce4f9789 131
FDLKHM 0:0389ce4f9789 132 int decode_file_transfer_acknowledge_packet(file_transfer_acknowledge_packet_t *file_transfer_acknowledge_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 133 {
FDLKHM 0:0389ce4f9789 134 if (an_packet->id == packet_id_file_transfer_acknowledge && an_packet->length == 9)
FDLKHM 0:0389ce4f9789 135 {
FDLKHM 0:0389ce4f9789 136 memcpy(&file_transfer_acknowledge_packet->unique_id, &an_packet->data[0], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 137 memcpy(&file_transfer_acknowledge_packet->data_index, &an_packet->data[4], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 138 file_transfer_acknowledge_packet->response_code = an_packet->data[8];
FDLKHM 0:0389ce4f9789 139 return 0;
FDLKHM 0:0389ce4f9789 140 }
FDLKHM 0:0389ce4f9789 141 else return 1;
FDLKHM 0:0389ce4f9789 142 }
FDLKHM 0:0389ce4f9789 143
FDLKHM 0:0389ce4f9789 144 int decode_system_state_packet(system_state_packet_t *system_state_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 145 {
FDLKHM 0:0389ce4f9789 146 if (an_packet->id == packet_id_system_state && an_packet->length == 100)
FDLKHM 0:0389ce4f9789 147 {
FDLKHM 0:0389ce4f9789 148 memcpy(&system_state_packet->system_status, &an_packet->data[0], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 149 memcpy(&system_state_packet->filter_status, &an_packet->data[2], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 150 memcpy(&system_state_packet->unix_time_seconds, &an_packet->data[4], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 151 memcpy(&system_state_packet->microseconds, &an_packet->data[8], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 152 memcpy(&system_state_packet->latitude, &an_packet->data[12], sizeof(double));
FDLKHM 0:0389ce4f9789 153 memcpy(&system_state_packet->longitude, &an_packet->data[20], sizeof(double));
FDLKHM 0:0389ce4f9789 154 memcpy(&system_state_packet->height, &an_packet->data[28], sizeof(double));
FDLKHM 0:0389ce4f9789 155 memcpy(&system_state_packet->velocity[0], &an_packet->data[36], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 156 memcpy(&system_state_packet->body_acceleration[0], &an_packet->data[48], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 157 memcpy(&system_state_packet->g_force, &an_packet->data[60], sizeof(float));
FDLKHM 0:0389ce4f9789 158 memcpy(&system_state_packet->orientation[0], &an_packet->data[64], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 159 memcpy(&system_state_packet->angular_velocity[0], &an_packet->data[76], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 160 memcpy(&system_state_packet->standard_deviation[0], &an_packet->data[88], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 161 return 0;
FDLKHM 0:0389ce4f9789 162 }
FDLKHM 0:0389ce4f9789 163 else return 1;
FDLKHM 0:0389ce4f9789 164 }
FDLKHM 0:0389ce4f9789 165
FDLKHM 0:0389ce4f9789 166 int decode_unix_time_packet(unix_time_packet_t *unix_time_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 167 {
FDLKHM 0:0389ce4f9789 168 if (an_packet->id == packet_id_unix_time && an_packet->length == 8)
FDLKHM 0:0389ce4f9789 169 {
FDLKHM 0:0389ce4f9789 170 memcpy(&unix_time_packet->unix_time_seconds, &an_packet->data[0], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 171 memcpy(&unix_time_packet->microseconds, &an_packet->data[4], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 172 return 0;
FDLKHM 0:0389ce4f9789 173 }
FDLKHM 0:0389ce4f9789 174 else return 1;
FDLKHM 0:0389ce4f9789 175 }
FDLKHM 0:0389ce4f9789 176
FDLKHM 0:0389ce4f9789 177 int decode_formatted_time_packet(formatted_time_packet_t *formatted_time_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 178 {
FDLKHM 0:0389ce4f9789 179 if (an_packet->id == packet_id_formatted_time && an_packet->length == 14)
FDLKHM 0:0389ce4f9789 180 {
FDLKHM 0:0389ce4f9789 181 memcpy(&formatted_time_packet->microseconds, &an_packet->data[0], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 182 memcpy(&formatted_time_packet->year, &an_packet->data[4], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 183 memcpy(&formatted_time_packet->year_day, &an_packet->data[6], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 184 formatted_time_packet->month = an_packet->data[8];
FDLKHM 0:0389ce4f9789 185 formatted_time_packet->month_day = an_packet->data[9];
FDLKHM 0:0389ce4f9789 186 formatted_time_packet->week_day = an_packet->data[10];
FDLKHM 0:0389ce4f9789 187 formatted_time_packet->hour = an_packet->data[11];
FDLKHM 0:0389ce4f9789 188 formatted_time_packet->minute = an_packet->data[12];
FDLKHM 0:0389ce4f9789 189 formatted_time_packet->second = an_packet->data[13];
FDLKHM 0:0389ce4f9789 190 return 0;
FDLKHM 0:0389ce4f9789 191 }
FDLKHM 0:0389ce4f9789 192 else return 1;
FDLKHM 0:0389ce4f9789 193 }
FDLKHM 0:0389ce4f9789 194
FDLKHM 0:0389ce4f9789 195 int decode_status_packet(status_packet_t *status_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 196 {
FDLKHM 0:0389ce4f9789 197 if (an_packet->id == packet_id_status && an_packet->length == 4)
FDLKHM 0:0389ce4f9789 198 {
FDLKHM 0:0389ce4f9789 199 memcpy(&status_packet->system_status, &an_packet->data[0], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 200 memcpy(&status_packet->filter_status, &an_packet->data[2], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 201 return 0;
FDLKHM 0:0389ce4f9789 202 }
FDLKHM 0:0389ce4f9789 203 else return 1;
FDLKHM 0:0389ce4f9789 204 }
FDLKHM 0:0389ce4f9789 205
FDLKHM 0:0389ce4f9789 206 int decode_position_standard_deviation_packet(position_standard_deviation_packet_t *position_standard_deviation_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 207 {
FDLKHM 0:0389ce4f9789 208 if (an_packet->id == packet_id_position_standard_deviation && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 209 {
FDLKHM 0:0389ce4f9789 210 memcpy(&position_standard_deviation_packet->standard_deviation[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 211 return 0;
FDLKHM 0:0389ce4f9789 212 }
FDLKHM 0:0389ce4f9789 213 else return 1;
FDLKHM 0:0389ce4f9789 214 }
FDLKHM 0:0389ce4f9789 215
FDLKHM 0:0389ce4f9789 216 int decode_velocity_standard_deviation_packet(velocity_standard_deviation_packet_t *velocity_standard_deviation_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 217 {
FDLKHM 0:0389ce4f9789 218 if (an_packet->id == packet_id_velocity_standard_deviation && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 219 {
FDLKHM 0:0389ce4f9789 220 memcpy(&velocity_standard_deviation_packet->standard_deviation[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 221 return 0;
FDLKHM 0:0389ce4f9789 222 }
FDLKHM 0:0389ce4f9789 223 else return 1;
FDLKHM 0:0389ce4f9789 224 }
FDLKHM 0:0389ce4f9789 225
FDLKHM 0:0389ce4f9789 226 int decode_euler_orientation_standard_deviation_packet(euler_orientation_standard_deviation_packet_t *euler_orientation_standard_deviation, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 227 {
FDLKHM 0:0389ce4f9789 228 if (an_packet->id == packet_id_euler_orientation_standard_deviation && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 229 {
FDLKHM 0:0389ce4f9789 230 memcpy(&euler_orientation_standard_deviation->standard_deviation[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 231 return 0;
FDLKHM 0:0389ce4f9789 232 }
FDLKHM 0:0389ce4f9789 233 else return 1;
FDLKHM 0:0389ce4f9789 234 }
FDLKHM 0:0389ce4f9789 235
FDLKHM 0:0389ce4f9789 236 int decode_quaternion_orientation_standard_deviation_packet(quaternion_orientation_standard_deviation_packet_t *quaternion_orientation_standard_deviation_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 237 {
FDLKHM 0:0389ce4f9789 238 if (an_packet->id == packet_id_quaternion_orientation_standard_deviation && an_packet->length == 16)
FDLKHM 0:0389ce4f9789 239 {
FDLKHM 0:0389ce4f9789 240 memcpy(&quaternion_orientation_standard_deviation_packet->standard_deviation[0], &an_packet->data[0], 4 * sizeof(float));
FDLKHM 0:0389ce4f9789 241 return 0;
FDLKHM 0:0389ce4f9789 242 }
FDLKHM 0:0389ce4f9789 243 else return 1;
FDLKHM 0:0389ce4f9789 244 }
FDLKHM 0:0389ce4f9789 245
FDLKHM 0:0389ce4f9789 246 int decode_raw_sensors_packet(raw_sensors_packet_t *raw_sensors_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 247 {
FDLKHM 0:0389ce4f9789 248 if (an_packet->id == packet_id_raw_sensors && an_packet->length == 48)
FDLKHM 0:0389ce4f9789 249 {
FDLKHM 0:0389ce4f9789 250 memcpy(&raw_sensors_packet->accelerometers[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 251 memcpy(&raw_sensors_packet->gyroscopes[0], &an_packet->data[12], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 252 memcpy(&raw_sensors_packet->magnetometers[0], &an_packet->data[24], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 253 memcpy(&raw_sensors_packet->imu_temperature, &an_packet->data[36], sizeof(float));
FDLKHM 0:0389ce4f9789 254 memcpy(&raw_sensors_packet->pressure, &an_packet->data[40], sizeof(float));
FDLKHM 0:0389ce4f9789 255 memcpy(&raw_sensors_packet->pressure_temperature, &an_packet->data[44], sizeof(float));
FDLKHM 0:0389ce4f9789 256 return 0;
FDLKHM 0:0389ce4f9789 257 }
FDLKHM 0:0389ce4f9789 258 else return 1;
FDLKHM 0:0389ce4f9789 259 }
FDLKHM 0:0389ce4f9789 260
FDLKHM 0:0389ce4f9789 261 int decode_raw_gnss_packet(raw_gnss_packet_t *raw_gnss_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 262 {
FDLKHM 0:0389ce4f9789 263 if (an_packet->id == packet_id_raw_gnss && an_packet->length == 74)
FDLKHM 0:0389ce4f9789 264 {
FDLKHM 0:0389ce4f9789 265 memcpy(&raw_gnss_packet->unix_time_seconds, &an_packet->data[0], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 266 memcpy(&raw_gnss_packet->microseconds, &an_packet->data[4], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 267 memcpy(&raw_gnss_packet->position[0], &an_packet->data[8], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 268 memcpy(&raw_gnss_packet->velocity[0], &an_packet->data[32], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 269 memcpy(&raw_gnss_packet->position_standard_deviation[0], &an_packet->data[44], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 270 memcpy(&raw_gnss_packet->tilt, &an_packet->data[56], sizeof(float));
FDLKHM 0:0389ce4f9789 271 memcpy(&raw_gnss_packet->heading, &an_packet->data[60], sizeof(float));
FDLKHM 0:0389ce4f9789 272 memcpy(&raw_gnss_packet->tilt_standard_deviation, &an_packet->data[64], sizeof(float));
FDLKHM 0:0389ce4f9789 273 memcpy(&raw_gnss_packet->heading_standard_deviation, &an_packet->data[68], sizeof(float));
FDLKHM 0:0389ce4f9789 274 memcpy(&raw_gnss_packet->flags.r, &an_packet->data[72], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 275 return 0;
FDLKHM 0:0389ce4f9789 276 }
FDLKHM 0:0389ce4f9789 277 else return 1;
FDLKHM 0:0389ce4f9789 278 }
FDLKHM 0:0389ce4f9789 279
FDLKHM 0:0389ce4f9789 280 int decode_satellites_packet(satellites_packet_t *satellites_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 281 {
FDLKHM 0:0389ce4f9789 282 if (an_packet->id == packet_id_satellites && an_packet->length == 13)
FDLKHM 0:0389ce4f9789 283 {
FDLKHM 0:0389ce4f9789 284 memcpy(&satellites_packet->hdop, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 285 memcpy(&satellites_packet->vdop, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 286 memcpy(&satellites_packet->gps_satellites, &an_packet->data[8], 5 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 287 return 0;
FDLKHM 0:0389ce4f9789 288 }
FDLKHM 0:0389ce4f9789 289 else return 1;
FDLKHM 0:0389ce4f9789 290 }
FDLKHM 0:0389ce4f9789 291
FDLKHM 0:0389ce4f9789 292 int decode_detailed_satellites_packet(detailed_satellites_packet_t *detailed_satellites_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 293 {
FDLKHM 0:0389ce4f9789 294 if (an_packet->id == packet_id_satellites_detailed && (an_packet->length % 7) == 0)
FDLKHM 0:0389ce4f9789 295 {
FDLKHM 0:0389ce4f9789 296 int number_of_satellites = an_packet->length / 7;
FDLKHM 0:0389ce4f9789 297 int i;
FDLKHM 0:0389ce4f9789 298 for (i = 0; i < MAXIMUM_DETAILED_SATELLITES; i++)
FDLKHM 0:0389ce4f9789 299 {
FDLKHM 0:0389ce4f9789 300 if (i < number_of_satellites)
FDLKHM 0:0389ce4f9789 301 {
FDLKHM 0:0389ce4f9789 302 detailed_satellites_packet->satellites[i].satellite_system = an_packet->data[7 * i];
FDLKHM 0:0389ce4f9789 303 detailed_satellites_packet->satellites[i].number = an_packet->data[7 * i + 1];
FDLKHM 0:0389ce4f9789 304 detailed_satellites_packet->satellites[i].frequencies.r = an_packet->data[7 * i + 2];
FDLKHM 0:0389ce4f9789 305 detailed_satellites_packet->satellites[i].elevation = an_packet->data[7 * i + 3];
FDLKHM 0:0389ce4f9789 306 memcpy(&detailed_satellites_packet->satellites[i].azimuth, &an_packet->data[7 * i + 4], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 307 detailed_satellites_packet->satellites[i].snr = an_packet->data[7 * i + 6];
FDLKHM 0:0389ce4f9789 308 }
FDLKHM 0:0389ce4f9789 309 else memset(&detailed_satellites_packet->satellites[i], 0, sizeof(satellite_t));
FDLKHM 0:0389ce4f9789 310 }
FDLKHM 0:0389ce4f9789 311 return 0;
FDLKHM 0:0389ce4f9789 312 }
FDLKHM 0:0389ce4f9789 313 else return 1;
FDLKHM 0:0389ce4f9789 314 }
FDLKHM 0:0389ce4f9789 315
FDLKHM 0:0389ce4f9789 316 int decode_geodetic_position_packet(geodetic_position_packet_t *geodetic_position_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 317 {
FDLKHM 0:0389ce4f9789 318 if (an_packet->id == packet_id_geodetic_position && an_packet->length == 24)
FDLKHM 0:0389ce4f9789 319 {
FDLKHM 0:0389ce4f9789 320 memcpy(&geodetic_position_packet->position[0], &an_packet->data[0], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 321 return 0;
FDLKHM 0:0389ce4f9789 322 }
FDLKHM 0:0389ce4f9789 323 else return 1;
FDLKHM 0:0389ce4f9789 324 }
FDLKHM 0:0389ce4f9789 325
FDLKHM 0:0389ce4f9789 326 int decode_ecef_position_packet(ecef_position_packet_t *ecef_position_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 327 {
FDLKHM 0:0389ce4f9789 328 if (an_packet->id == packet_id_ecef_position && an_packet->length == 24)
FDLKHM 0:0389ce4f9789 329 {
FDLKHM 0:0389ce4f9789 330 memcpy(&ecef_position_packet->position[0], &an_packet->data[0], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 331 return 0;
FDLKHM 0:0389ce4f9789 332 }
FDLKHM 0:0389ce4f9789 333 else return 1;
FDLKHM 0:0389ce4f9789 334 }
FDLKHM 0:0389ce4f9789 335
FDLKHM 0:0389ce4f9789 336 int decode_utm_position_packet(utm_position_packet_t *utm_position_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 337 {
FDLKHM 0:0389ce4f9789 338 if (an_packet->id == packet_id_utm_position && an_packet->length == 25)
FDLKHM 0:0389ce4f9789 339 {
FDLKHM 0:0389ce4f9789 340 memcpy(&utm_position_packet->position, &an_packet->data[0], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 341 utm_position_packet->zone = an_packet->data[24];
FDLKHM 0:0389ce4f9789 342 return 0;
FDLKHM 0:0389ce4f9789 343 }
FDLKHM 0:0389ce4f9789 344 else return 1;
FDLKHM 0:0389ce4f9789 345 }
FDLKHM 0:0389ce4f9789 346
FDLKHM 0:0389ce4f9789 347 int decode_ned_velocity_packet(ned_velocity_packet_t *ned_velocity_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 348 {
FDLKHM 0:0389ce4f9789 349 if (an_packet->id == packet_id_ned_velocity && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 350 {
FDLKHM 0:0389ce4f9789 351 memcpy(&ned_velocity_packet->velocity, &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 352 return 0;
FDLKHM 0:0389ce4f9789 353 }
FDLKHM 0:0389ce4f9789 354 else return 1;
FDLKHM 0:0389ce4f9789 355 }
FDLKHM 0:0389ce4f9789 356
FDLKHM 0:0389ce4f9789 357 int decode_body_velocity_packet(body_velocity_packet_t *body_velocity_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 358 {
FDLKHM 0:0389ce4f9789 359 if (an_packet->id == packet_id_body_velocity && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 360 {
FDLKHM 0:0389ce4f9789 361 memcpy(&body_velocity_packet->velocity, &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 362 return 0;
FDLKHM 0:0389ce4f9789 363 }
FDLKHM 0:0389ce4f9789 364 else return 1;
FDLKHM 0:0389ce4f9789 365 }
FDLKHM 0:0389ce4f9789 366
FDLKHM 0:0389ce4f9789 367 int decode_acceleration_packet(acceleration_packet_t *acceleration, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 368 {
FDLKHM 0:0389ce4f9789 369 if (an_packet->id == packet_id_acceleration && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 370 {
FDLKHM 0:0389ce4f9789 371 memcpy(&acceleration->acceleration[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 372 return 0;
FDLKHM 0:0389ce4f9789 373 }
FDLKHM 0:0389ce4f9789 374 else return 1;
FDLKHM 0:0389ce4f9789 375 }
FDLKHM 0:0389ce4f9789 376
FDLKHM 0:0389ce4f9789 377 int decode_body_acceleration_packet(body_acceleration_packet_t *body_acceleration, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 378 {
FDLKHM 0:0389ce4f9789 379 if (an_packet->id == packet_id_body_acceleration && an_packet->length == 16)
FDLKHM 0:0389ce4f9789 380 {
FDLKHM 0:0389ce4f9789 381 memcpy(&body_acceleration->acceleration[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 382 memcpy(&body_acceleration->g_force, &an_packet->data[12], sizeof(float));
FDLKHM 0:0389ce4f9789 383 return 0;
FDLKHM 0:0389ce4f9789 384 }
FDLKHM 0:0389ce4f9789 385 else return 1;
FDLKHM 0:0389ce4f9789 386 }
FDLKHM 0:0389ce4f9789 387
FDLKHM 0:0389ce4f9789 388 int decode_euler_orientation_packet(euler_orientation_packet_t *euler_orientation_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 389 {
FDLKHM 0:0389ce4f9789 390 if (an_packet->id == packet_id_euler_orientation && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 391 {
FDLKHM 0:0389ce4f9789 392 memcpy(&euler_orientation_packet->orientation[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 393 return 0;
FDLKHM 0:0389ce4f9789 394 }
FDLKHM 0:0389ce4f9789 395 else return 1;
FDLKHM 0:0389ce4f9789 396 }
FDLKHM 0:0389ce4f9789 397
FDLKHM 0:0389ce4f9789 398 int decode_quaternion_orientation_packet(quaternion_orientation_packet_t *quaternion_orientation_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 399 {
FDLKHM 0:0389ce4f9789 400 if (an_packet->id == packet_id_quaternion_orientation && an_packet->length == 16)
FDLKHM 0:0389ce4f9789 401 {
FDLKHM 0:0389ce4f9789 402 memcpy(&quaternion_orientation_packet->orientation[0], &an_packet->data[0], 4 * sizeof(float));
FDLKHM 0:0389ce4f9789 403 return 0;
FDLKHM 0:0389ce4f9789 404 }
FDLKHM 0:0389ce4f9789 405 else return 1;
FDLKHM 0:0389ce4f9789 406 }
FDLKHM 0:0389ce4f9789 407
FDLKHM 0:0389ce4f9789 408 int decode_dcm_orientation_packet(dcm_orientation_packet_t *dcm_orientation_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 409 {
FDLKHM 0:0389ce4f9789 410 if (an_packet->id == packet_id_dcm_orientation && an_packet->length == 36)
FDLKHM 0:0389ce4f9789 411 {
FDLKHM 0:0389ce4f9789 412 memcpy(&dcm_orientation_packet->orientation[0][0], &an_packet->data[0], 9 * sizeof(float));
FDLKHM 0:0389ce4f9789 413 return 0;
FDLKHM 0:0389ce4f9789 414 }
FDLKHM 0:0389ce4f9789 415 else return 1;
FDLKHM 0:0389ce4f9789 416 }
FDLKHM 0:0389ce4f9789 417
FDLKHM 0:0389ce4f9789 418 int decode_angular_velocity_packet(angular_velocity_packet_t *angular_velocity_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 419 {
FDLKHM 0:0389ce4f9789 420 if (an_packet->id == packet_id_angular_velocity && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 421 {
FDLKHM 0:0389ce4f9789 422 memcpy(&angular_velocity_packet->angular_velocity[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 423 return 0;
FDLKHM 0:0389ce4f9789 424 }
FDLKHM 0:0389ce4f9789 425 else return 1;
FDLKHM 0:0389ce4f9789 426 }
FDLKHM 0:0389ce4f9789 427
FDLKHM 0:0389ce4f9789 428 int decode_angular_acceleration_packet(angular_acceleration_packet_t *angular_acceleration_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 429 {
FDLKHM 0:0389ce4f9789 430 if (an_packet->id == packet_id_angular_acceleration && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 431 {
FDLKHM 0:0389ce4f9789 432 memcpy(&angular_acceleration_packet->angular_acceleration[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 433 return 0;
FDLKHM 0:0389ce4f9789 434 }
FDLKHM 0:0389ce4f9789 435 else return 1;
FDLKHM 0:0389ce4f9789 436 }
FDLKHM 0:0389ce4f9789 437
FDLKHM 0:0389ce4f9789 438 int decode_external_position_velocity_packet(external_position_velocity_packet_t *external_position_velocity_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 439 {
FDLKHM 0:0389ce4f9789 440 if (an_packet->id == packet_id_external_position_velocity && an_packet->length == 60)
FDLKHM 0:0389ce4f9789 441 {
FDLKHM 0:0389ce4f9789 442 memcpy(&external_position_velocity_packet->position[0], &an_packet->data[0], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 443 memcpy(&external_position_velocity_packet->velocity[0], &an_packet->data[24], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 444 memcpy(&external_position_velocity_packet->position_standard_deviation[0], &an_packet->data[36], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 445 memcpy(&external_position_velocity_packet->velocity_standard_deviation[0], &an_packet->data[48], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 446 return 0;
FDLKHM 0:0389ce4f9789 447 }
FDLKHM 0:0389ce4f9789 448 else return 1;
FDLKHM 0:0389ce4f9789 449 }
FDLKHM 0:0389ce4f9789 450
FDLKHM 0:0389ce4f9789 451 an_packet_t *encode_external_position_velocity_packet(external_position_velocity_packet_t *external_position_velocity_packet)
FDLKHM 0:0389ce4f9789 452 {
FDLKHM 0:0389ce4f9789 453 an_packet_t *an_packet = an_packet_allocate(60, packet_id_external_position_velocity);
FDLKHM 0:0389ce4f9789 454 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 455 {
FDLKHM 0:0389ce4f9789 456 memcpy(&an_packet->data[0], &external_position_velocity_packet->position[0], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 457 memcpy(&an_packet->data[24], &external_position_velocity_packet->velocity[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 458 memcpy(&an_packet->data[36], &external_position_velocity_packet->position_standard_deviation[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 459 memcpy(&an_packet->data[48], &external_position_velocity_packet->velocity_standard_deviation[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 460 }
FDLKHM 0:0389ce4f9789 461 return an_packet;
FDLKHM 0:0389ce4f9789 462 }
FDLKHM 0:0389ce4f9789 463
FDLKHM 0:0389ce4f9789 464 int decode_external_position_packet(external_position_packet_t *external_position_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 465 {
FDLKHM 0:0389ce4f9789 466 if (an_packet->id == packet_id_external_position && an_packet->length == 36)
FDLKHM 0:0389ce4f9789 467 {
FDLKHM 0:0389ce4f9789 468 memcpy(&external_position_packet->position[0], &an_packet->data[0], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 469 memcpy(&external_position_packet->standard_deviation[0], &an_packet->data[24], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 470 return 0;
FDLKHM 0:0389ce4f9789 471 }
FDLKHM 0:0389ce4f9789 472 else return 1;
FDLKHM 0:0389ce4f9789 473 }
FDLKHM 0:0389ce4f9789 474
FDLKHM 0:0389ce4f9789 475 an_packet_t *encode_external_position_packet(external_position_packet_t *external_position_packet)
FDLKHM 0:0389ce4f9789 476 {
FDLKHM 0:0389ce4f9789 477 an_packet_t *an_packet = an_packet_allocate(36, packet_id_external_position);
FDLKHM 0:0389ce4f9789 478 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 479 {
FDLKHM 0:0389ce4f9789 480 memcpy(&an_packet->data[0], &external_position_packet->position[0], 3 * sizeof(double));
FDLKHM 0:0389ce4f9789 481 memcpy(&an_packet->data[24], &external_position_packet->standard_deviation[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 482 }
FDLKHM 0:0389ce4f9789 483 return an_packet;
FDLKHM 0:0389ce4f9789 484 }
FDLKHM 0:0389ce4f9789 485
FDLKHM 0:0389ce4f9789 486 int decode_external_velocity_packet(external_velocity_packet_t *external_velocity_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 487 {
FDLKHM 0:0389ce4f9789 488 if (an_packet->id == packet_id_external_velocity && an_packet->length == 24)
FDLKHM 0:0389ce4f9789 489 {
FDLKHM 0:0389ce4f9789 490 memcpy(&external_velocity_packet->velocity[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 491 memcpy(&external_velocity_packet->standard_deviation[0], &an_packet->data[12], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 492 return 0;
FDLKHM 0:0389ce4f9789 493 }
FDLKHM 0:0389ce4f9789 494 else return 1;
FDLKHM 0:0389ce4f9789 495 }
FDLKHM 0:0389ce4f9789 496
FDLKHM 0:0389ce4f9789 497 an_packet_t *encode_external_velocity_packet(external_velocity_packet_t *external_velocity_packet)
FDLKHM 0:0389ce4f9789 498 {
FDLKHM 0:0389ce4f9789 499 an_packet_t *an_packet = an_packet_allocate(24, packet_id_external_velocity);
FDLKHM 0:0389ce4f9789 500 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 501 {
FDLKHM 0:0389ce4f9789 502 memcpy(&an_packet->data[0], &external_velocity_packet->velocity[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 503 memcpy(&an_packet->data[12], &external_velocity_packet->standard_deviation[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 504 }
FDLKHM 0:0389ce4f9789 505 return an_packet;
FDLKHM 0:0389ce4f9789 506 }
FDLKHM 0:0389ce4f9789 507
FDLKHM 0:0389ce4f9789 508 int decode_external_body_velocity_packet(external_body_velocity_packet_t *external_body_velocity_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 509 {
FDLKHM 0:0389ce4f9789 510 if (an_packet->id == packet_id_external_body_velocity && an_packet->length == 16)
FDLKHM 0:0389ce4f9789 511 {
FDLKHM 0:0389ce4f9789 512 memcpy(&external_body_velocity_packet->velocity, &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 513 memcpy(&external_body_velocity_packet->standard_deviation, &an_packet->data[12], sizeof(float));
FDLKHM 0:0389ce4f9789 514 return 0;
FDLKHM 0:0389ce4f9789 515 }
FDLKHM 0:0389ce4f9789 516 else return 1;
FDLKHM 0:0389ce4f9789 517 }
FDLKHM 0:0389ce4f9789 518
FDLKHM 0:0389ce4f9789 519 an_packet_t *encode_external_body_velocity_packet(external_body_velocity_packet_t *external_body_velocity_packet)
FDLKHM 0:0389ce4f9789 520 {
FDLKHM 0:0389ce4f9789 521 an_packet_t *an_packet = an_packet_allocate(16, packet_id_external_body_velocity);
FDLKHM 0:0389ce4f9789 522 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 523 {
FDLKHM 0:0389ce4f9789 524 memcpy(&an_packet->data[0], &external_body_velocity_packet->velocity[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 525 memcpy(&an_packet->data[12], &external_body_velocity_packet->standard_deviation, sizeof(float));
FDLKHM 0:0389ce4f9789 526 }
FDLKHM 0:0389ce4f9789 527 return an_packet;
FDLKHM 0:0389ce4f9789 528 }
FDLKHM 0:0389ce4f9789 529
FDLKHM 0:0389ce4f9789 530 int decode_external_heading_packet(external_heading_packet_t *external_heading_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 531 {
FDLKHM 0:0389ce4f9789 532 if (an_packet->id == packet_id_external_heading && an_packet->length == 8)
FDLKHM 0:0389ce4f9789 533 {
FDLKHM 0:0389ce4f9789 534 memcpy(&external_heading_packet->heading, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 535 memcpy(&external_heading_packet->standard_deviation, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 536 return 0;
FDLKHM 0:0389ce4f9789 537 }
FDLKHM 0:0389ce4f9789 538 else return 1;
FDLKHM 0:0389ce4f9789 539 }
FDLKHM 0:0389ce4f9789 540
FDLKHM 0:0389ce4f9789 541 an_packet_t *encode_external_heading_packet(external_heading_packet_t *external_heading_packet)
FDLKHM 0:0389ce4f9789 542 {
FDLKHM 0:0389ce4f9789 543 an_packet_t *an_packet = an_packet_allocate(8, packet_id_external_heading);
FDLKHM 0:0389ce4f9789 544 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 545 {
FDLKHM 0:0389ce4f9789 546 memcpy(&an_packet->data[0], &external_heading_packet->heading, sizeof(float));
FDLKHM 0:0389ce4f9789 547 memcpy(&an_packet->data[4], &external_heading_packet->standard_deviation, sizeof(float));
FDLKHM 0:0389ce4f9789 548 }
FDLKHM 0:0389ce4f9789 549 return an_packet;
FDLKHM 0:0389ce4f9789 550 }
FDLKHM 0:0389ce4f9789 551
FDLKHM 0:0389ce4f9789 552 int decode_running_time_packet(running_time_packet_t *running_time_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 553 {
FDLKHM 0:0389ce4f9789 554 if (an_packet->id == packet_id_running_time && an_packet->length == 8)
FDLKHM 0:0389ce4f9789 555 {
FDLKHM 0:0389ce4f9789 556 memcpy(&running_time_packet->seconds, &an_packet->data[0], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 557 memcpy(&running_time_packet->microseconds, &an_packet->data[4], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 558 return 0;
FDLKHM 0:0389ce4f9789 559 }
FDLKHM 0:0389ce4f9789 560 else return 1;
FDLKHM 0:0389ce4f9789 561 }
FDLKHM 0:0389ce4f9789 562
FDLKHM 0:0389ce4f9789 563 int decode_local_magnetics_packet(local_magnetics_packet_t *local_magnetics_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 564 {
FDLKHM 0:0389ce4f9789 565 if (an_packet->id == packet_id_local_magnetics && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 566 {
FDLKHM 0:0389ce4f9789 567 memcpy(&local_magnetics_packet->magnetic_field[0], &an_packet->data[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 568 return 0;
FDLKHM 0:0389ce4f9789 569 }
FDLKHM 0:0389ce4f9789 570 else return 1;
FDLKHM 0:0389ce4f9789 571 }
FDLKHM 0:0389ce4f9789 572
FDLKHM 0:0389ce4f9789 573 int decode_odometer_state_packet(odometer_state_packet_t *odometer_state_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 574 {
FDLKHM 0:0389ce4f9789 575 if (an_packet->id == packet_id_odometer_state && an_packet->length == 20)
FDLKHM 0:0389ce4f9789 576 {
FDLKHM 0:0389ce4f9789 577 memcpy(&odometer_state_packet->pulse_count, &an_packet->data[0], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 578 memcpy(&odometer_state_packet->distance, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 579 memcpy(&odometer_state_packet->speed, &an_packet->data[8], sizeof(float));
FDLKHM 0:0389ce4f9789 580 memcpy(&odometer_state_packet->slip, &an_packet->data[12], sizeof(float));
FDLKHM 0:0389ce4f9789 581 odometer_state_packet->active = an_packet->data[16];
FDLKHM 0:0389ce4f9789 582 return 0;
FDLKHM 0:0389ce4f9789 583 }
FDLKHM 0:0389ce4f9789 584 else return 1;
FDLKHM 0:0389ce4f9789 585 }
FDLKHM 0:0389ce4f9789 586
FDLKHM 0:0389ce4f9789 587 int decode_external_time_packet(external_time_packet_t *external_time_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 588 {
FDLKHM 0:0389ce4f9789 589 if (an_packet->id == packet_id_external_time && an_packet->length == 8)
FDLKHM 0:0389ce4f9789 590 {
FDLKHM 0:0389ce4f9789 591 memcpy(&external_time_packet->unix_time_seconds, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 592 memcpy(&external_time_packet->microseconds, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 593 return 0;
FDLKHM 0:0389ce4f9789 594 }
FDLKHM 0:0389ce4f9789 595 else return 1;
FDLKHM 0:0389ce4f9789 596 }
FDLKHM 0:0389ce4f9789 597
FDLKHM 0:0389ce4f9789 598 an_packet_t *encode_external_time_packet(external_time_packet_t *external_time_packet)
FDLKHM 0:0389ce4f9789 599 {
FDLKHM 0:0389ce4f9789 600 an_packet_t *an_packet = an_packet_allocate(8, packet_id_external_time);
FDLKHM 0:0389ce4f9789 601 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 602 {
FDLKHM 0:0389ce4f9789 603 memcpy(&an_packet->data[0], &external_time_packet->unix_time_seconds, sizeof(float));
FDLKHM 0:0389ce4f9789 604 memcpy(&an_packet->data[4], &external_time_packet->microseconds, sizeof(float));
FDLKHM 0:0389ce4f9789 605 }
FDLKHM 0:0389ce4f9789 606 return an_packet;
FDLKHM 0:0389ce4f9789 607 }
FDLKHM 0:0389ce4f9789 608
FDLKHM 0:0389ce4f9789 609 int decode_external_depth_packet(external_depth_packet_t *external_depth_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 610 {
FDLKHM 0:0389ce4f9789 611 if (an_packet->id == packet_id_external_depth && an_packet->length == 8)
FDLKHM 0:0389ce4f9789 612 {
FDLKHM 0:0389ce4f9789 613 memcpy(&external_depth_packet->depth, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 614 memcpy(&external_depth_packet->standard_deviation, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 615 return 0;
FDLKHM 0:0389ce4f9789 616 }
FDLKHM 0:0389ce4f9789 617 else return 1;
FDLKHM 0:0389ce4f9789 618 }
FDLKHM 0:0389ce4f9789 619
FDLKHM 0:0389ce4f9789 620 an_packet_t *encode_external_depth_packet(external_depth_packet_t *external_depth_packet)
FDLKHM 0:0389ce4f9789 621 {
FDLKHM 0:0389ce4f9789 622 an_packet_t *an_packet = an_packet_allocate(8, packet_id_external_depth);
FDLKHM 0:0389ce4f9789 623 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 624 {
FDLKHM 0:0389ce4f9789 625 memcpy(&an_packet->data[0], &external_depth_packet->depth, sizeof(float));
FDLKHM 0:0389ce4f9789 626 memcpy(&an_packet->data[4], &external_depth_packet->standard_deviation, sizeof(float));
FDLKHM 0:0389ce4f9789 627 }
FDLKHM 0:0389ce4f9789 628 return an_packet;
FDLKHM 0:0389ce4f9789 629 }
FDLKHM 0:0389ce4f9789 630
FDLKHM 0:0389ce4f9789 631 int decode_geoid_height_packet(geoid_height_packet_t *geoid_height_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 632 {
FDLKHM 0:0389ce4f9789 633 if (an_packet->id == packet_id_geoid_height && an_packet->length == 4)
FDLKHM 0:0389ce4f9789 634 {
FDLKHM 0:0389ce4f9789 635 memcpy(&geoid_height_packet->geoid_height, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 636 return 0;
FDLKHM 0:0389ce4f9789 637 }
FDLKHM 0:0389ce4f9789 638 else return 1;
FDLKHM 0:0389ce4f9789 639 }
FDLKHM 0:0389ce4f9789 640
FDLKHM 0:0389ce4f9789 641 int decode_external_pitot_pressure_packet(external_pitot_pressure_packet_t *external_pitot_pressure_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 642 {
FDLKHM 0:0389ce4f9789 643 if (an_packet->id == packet_id_external_pitot_pressure && an_packet->length == 8)
FDLKHM 0:0389ce4f9789 644 {
FDLKHM 0:0389ce4f9789 645 memcpy(&external_pitot_pressure_packet->differential_pressure, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 646 memcpy(&external_pitot_pressure_packet->outside_air_temperature, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 647 return 0;
FDLKHM 0:0389ce4f9789 648 }
FDLKHM 0:0389ce4f9789 649 else return 1;
FDLKHM 0:0389ce4f9789 650 }
FDLKHM 0:0389ce4f9789 651
FDLKHM 0:0389ce4f9789 652 an_packet_t *encode_external_pitot_pressure_packet(external_pitot_pressure_packet_t *external_pitot_pressure_packet)
FDLKHM 0:0389ce4f9789 653 {
FDLKHM 0:0389ce4f9789 654 an_packet_t *an_packet = an_packet_allocate(8, packet_id_external_pitot_pressure);
FDLKHM 0:0389ce4f9789 655 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 656 {
FDLKHM 0:0389ce4f9789 657 memcpy(&an_packet->data[0], &external_pitot_pressure_packet->differential_pressure, sizeof(float));
FDLKHM 0:0389ce4f9789 658 memcpy(&an_packet->data[4], &external_pitot_pressure_packet->outside_air_temperature, sizeof(float));
FDLKHM 0:0389ce4f9789 659 }
FDLKHM 0:0389ce4f9789 660 return an_packet;
FDLKHM 0:0389ce4f9789 661 }
FDLKHM 0:0389ce4f9789 662
FDLKHM 0:0389ce4f9789 663 int decode_wind_packet(wind_packet_t *wind_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 664 {
FDLKHM 0:0389ce4f9789 665 if (an_packet->id == packet_id_wind && an_packet->length == 12)
FDLKHM 0:0389ce4f9789 666 {
FDLKHM 0:0389ce4f9789 667 memcpy(&wind_packet->wind_velocity[0], &an_packet->data[0], 2 * sizeof(float));
FDLKHM 0:0389ce4f9789 668 memcpy(&wind_packet->wind_standard_deviation, &an_packet->data[8], sizeof(float));
FDLKHM 0:0389ce4f9789 669 return 0;
FDLKHM 0:0389ce4f9789 670 }
FDLKHM 0:0389ce4f9789 671 else return 1;
FDLKHM 0:0389ce4f9789 672 }
FDLKHM 0:0389ce4f9789 673
FDLKHM 0:0389ce4f9789 674 an_packet_t *encode_wind_packet(wind_packet_t *wind_packet)
FDLKHM 0:0389ce4f9789 675 {
FDLKHM 0:0389ce4f9789 676 an_packet_t *an_packet = an_packet_allocate(12, packet_id_wind);
FDLKHM 0:0389ce4f9789 677 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 678 {
FDLKHM 0:0389ce4f9789 679 memcpy(&an_packet->data[0], &wind_packet->wind_velocity[0], 2 * sizeof(float));
FDLKHM 0:0389ce4f9789 680 memcpy(&an_packet->data[8], &wind_packet->wind_standard_deviation, sizeof(float));
FDLKHM 0:0389ce4f9789 681 }
FDLKHM 0:0389ce4f9789 682 return an_packet;
FDLKHM 0:0389ce4f9789 683 }
FDLKHM 0:0389ce4f9789 684
FDLKHM 0:0389ce4f9789 685 int decode_heave_packet(heave_packet_t *heave_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 686 {
FDLKHM 0:0389ce4f9789 687 if (an_packet->id == packet_id_heave && an_packet->length == 16)
FDLKHM 0:0389ce4f9789 688 {
FDLKHM 0:0389ce4f9789 689 memcpy(&heave_packet->heave_point_1, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 690 memcpy(&heave_packet->heave_point_2, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 691 memcpy(&heave_packet->heave_point_3, &an_packet->data[8], sizeof(float));
FDLKHM 0:0389ce4f9789 692 memcpy(&heave_packet->heave_point_4, &an_packet->data[12], sizeof(float));
FDLKHM 0:0389ce4f9789 693 return 0;
FDLKHM 0:0389ce4f9789 694 }
FDLKHM 0:0389ce4f9789 695 else return 1;
FDLKHM 0:0389ce4f9789 696 }
FDLKHM 0:0389ce4f9789 697
FDLKHM 0:0389ce4f9789 698 int decode_odometer_packet(odometer_packet_t *external_odometer_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 699 {
FDLKHM 0:0389ce4f9789 700 if (an_packet->id == packet_id_external_odometer && an_packet->length == 13)
FDLKHM 0:0389ce4f9789 701 {
FDLKHM 0:0389ce4f9789 702 memcpy(&external_odometer_packet->delay, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 703 memcpy(&external_odometer_packet->speed, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 704 memcpy(&external_odometer_packet->distance_travelled, &an_packet->data[8], sizeof(float));
FDLKHM 0:0389ce4f9789 705 external_odometer_packet->flags.r = an_packet->data[12];
FDLKHM 0:0389ce4f9789 706 return 0;
FDLKHM 0:0389ce4f9789 707 }
FDLKHM 0:0389ce4f9789 708 else return 1;
FDLKHM 0:0389ce4f9789 709 }
FDLKHM 0:0389ce4f9789 710
FDLKHM 0:0389ce4f9789 711 an_packet_t *encode_external_odometer_packet(odometer_packet_t *external_odometer_packet)
FDLKHM 0:0389ce4f9789 712 {
FDLKHM 0:0389ce4f9789 713 an_packet_t *an_packet = an_packet_allocate(13, packet_id_external_odometer);
FDLKHM 0:0389ce4f9789 714 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 715 {
FDLKHM 0:0389ce4f9789 716 memcpy(&an_packet->data[0], &external_odometer_packet->delay, sizeof(float));
FDLKHM 0:0389ce4f9789 717 memcpy(&an_packet->data[4], &external_odometer_packet->speed, sizeof(float));
FDLKHM 0:0389ce4f9789 718 memcpy(&an_packet->data[8], &external_odometer_packet->distance_travelled, sizeof(float));
FDLKHM 0:0389ce4f9789 719 an_packet->data[12] = external_odometer_packet->flags.r;
FDLKHM 0:0389ce4f9789 720 }
FDLKHM 0:0389ce4f9789 721 return an_packet;
FDLKHM 0:0389ce4f9789 722 }
FDLKHM 0:0389ce4f9789 723
FDLKHM 0:0389ce4f9789 724 int decode_external_air_data_packet(external_air_data_packet_t *external_air_data_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 725 {
FDLKHM 0:0389ce4f9789 726 if (an_packet->id == packet_id_external_air_data && an_packet->length == 25)
FDLKHM 0:0389ce4f9789 727 {
FDLKHM 0:0389ce4f9789 728 memcpy(&external_air_data_packet->altitude_delay, &an_packet->data[0], sizeof(float));
FDLKHM 0:0389ce4f9789 729 memcpy(&external_air_data_packet->airspeed_delay, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 730 memcpy(&external_air_data_packet->altitude, &an_packet->data[8], sizeof(float));
FDLKHM 0:0389ce4f9789 731 memcpy(&external_air_data_packet->airspeed, &an_packet->data[12], sizeof(float));
FDLKHM 0:0389ce4f9789 732 memcpy(&external_air_data_packet->altitude_standard_deviation, &an_packet->data[16], sizeof(float));
FDLKHM 0:0389ce4f9789 733 memcpy(&external_air_data_packet->airspeed_standard_deviation, &an_packet->data[20], sizeof(float));
FDLKHM 0:0389ce4f9789 734 external_air_data_packet->flags.r = an_packet->data[24];
FDLKHM 0:0389ce4f9789 735 return 0;
FDLKHM 0:0389ce4f9789 736 }
FDLKHM 0:0389ce4f9789 737 else return 1;
FDLKHM 0:0389ce4f9789 738 }
FDLKHM 0:0389ce4f9789 739
FDLKHM 0:0389ce4f9789 740 an_packet_t *encode_external_air_data_packet(external_air_data_packet_t *external_air_data_packet)
FDLKHM 0:0389ce4f9789 741 {
FDLKHM 0:0389ce4f9789 742 an_packet_t *an_packet = an_packet_allocate(25, packet_id_external_air_data);
FDLKHM 0:0389ce4f9789 743 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 744 {
FDLKHM 0:0389ce4f9789 745 memcpy(&an_packet->data[0], &external_air_data_packet->altitude_delay, sizeof(float));
FDLKHM 0:0389ce4f9789 746 memcpy(&an_packet->data[4], &external_air_data_packet->airspeed_delay, sizeof(float));
FDLKHM 0:0389ce4f9789 747 memcpy(&an_packet->data[8], &external_air_data_packet->altitude, sizeof(float));
FDLKHM 0:0389ce4f9789 748 memcpy(&an_packet->data[12], &external_air_data_packet->airspeed, sizeof(float));
FDLKHM 0:0389ce4f9789 749 memcpy(&an_packet->data[16], &external_air_data_packet->altitude_standard_deviation, sizeof(float));
FDLKHM 0:0389ce4f9789 750 memcpy(&an_packet->data[20], &external_air_data_packet->airspeed_standard_deviation, sizeof(float));
FDLKHM 0:0389ce4f9789 751 an_packet->data[24] = external_air_data_packet->flags.r;
FDLKHM 0:0389ce4f9789 752 }
FDLKHM 0:0389ce4f9789 753 return an_packet;
FDLKHM 0:0389ce4f9789 754 }
FDLKHM 0:0389ce4f9789 755
FDLKHM 0:0389ce4f9789 756 /* Start of configuration packet functions */
FDLKHM 0:0389ce4f9789 757
FDLKHM 0:0389ce4f9789 758 int decode_packet_timer_period_packet(packet_timer_period_packet_t *packet_timer_period_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 759 {
FDLKHM 0:0389ce4f9789 760 if (an_packet->id == packet_id_packet_timer_period && an_packet->length == 4)
FDLKHM 0:0389ce4f9789 761 {
FDLKHM 0:0389ce4f9789 762 packet_timer_period_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 763 packet_timer_period_packet->utc_synchronisation = an_packet->data[1];
FDLKHM 0:0389ce4f9789 764 memcpy(&packet_timer_period_packet->packet_timer_period, &an_packet->data[2], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 765 return 0;
FDLKHM 0:0389ce4f9789 766 }
FDLKHM 0:0389ce4f9789 767 else return 1;
FDLKHM 0:0389ce4f9789 768 }
FDLKHM 0:0389ce4f9789 769
FDLKHM 0:0389ce4f9789 770 an_packet_t *encode_packet_timer_period_packet(packet_timer_period_packet_t *packet_timer_period_packet)
FDLKHM 0:0389ce4f9789 771 {
FDLKHM 0:0389ce4f9789 772 an_packet_t *an_packet = an_packet_allocate(4, packet_id_packet_timer_period);
FDLKHM 0:0389ce4f9789 773 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 774 {
FDLKHM 0:0389ce4f9789 775 an_packet->data[0] = packet_timer_period_packet->permanent > 0;
FDLKHM 0:0389ce4f9789 776 an_packet->data[1] = packet_timer_period_packet->utc_synchronisation > 0;
FDLKHM 0:0389ce4f9789 777 memcpy(&an_packet->data[2], &packet_timer_period_packet->packet_timer_period, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 778 }
FDLKHM 0:0389ce4f9789 779 return an_packet;
FDLKHM 0:0389ce4f9789 780 }
FDLKHM 0:0389ce4f9789 781
FDLKHM 0:0389ce4f9789 782 int decode_packet_periods_packet(packet_periods_packet_t *packet_periods_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 783 {
FDLKHM 0:0389ce4f9789 784 if (an_packet->id == packet_id_packet_periods && (an_packet->length - 2) % 5 == 0)
FDLKHM 0:0389ce4f9789 785 {
FDLKHM 0:0389ce4f9789 786 int i;
FDLKHM 0:0389ce4f9789 787 int packet_periods_count = (an_packet->length - 2) / 5;
FDLKHM 0:0389ce4f9789 788 packet_periods_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 789 packet_periods_packet->clear_existing_packets = an_packet->data[1];
FDLKHM 0:0389ce4f9789 790 for (i = 0; i < MAXIMUM_PACKET_PERIODS; i++)
FDLKHM 0:0389ce4f9789 791 {
FDLKHM 0:0389ce4f9789 792 if (i < packet_periods_count)
FDLKHM 0:0389ce4f9789 793 {
FDLKHM 0:0389ce4f9789 794 packet_periods_packet->packet_periods[i].packet_id = an_packet->data[2 + 5 * i];
FDLKHM 0:0389ce4f9789 795 memcpy(&packet_periods_packet->packet_periods[i].period, &an_packet->data[2 + 5 * i + 1], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 796 }
FDLKHM 0:0389ce4f9789 797 else memset(&packet_periods_packet->packet_periods[i], 0, sizeof(packet_period_t));
FDLKHM 0:0389ce4f9789 798 }
FDLKHM 0:0389ce4f9789 799 return 0;
FDLKHM 0:0389ce4f9789 800 }
FDLKHM 0:0389ce4f9789 801 else return 1;
FDLKHM 0:0389ce4f9789 802 }
FDLKHM 0:0389ce4f9789 803
FDLKHM 0:0389ce4f9789 804 an_packet_t *encode_packet_periods_packet(packet_periods_packet_t *packet_periods_packet)
FDLKHM 0:0389ce4f9789 805 {
FDLKHM 0:0389ce4f9789 806 int i;
FDLKHM 0:0389ce4f9789 807 an_packet_t *an_packet = an_packet_allocate(252, packet_id_packet_periods);
FDLKHM 0:0389ce4f9789 808 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 809 {
FDLKHM 0:0389ce4f9789 810 an_packet->data[0] = packet_periods_packet->permanent > 0;
FDLKHM 0:0389ce4f9789 811 an_packet->data[1] = packet_periods_packet->clear_existing_packets;
FDLKHM 0:0389ce4f9789 812 for (i = 0; i < MAXIMUM_PACKET_PERIODS; i++)
FDLKHM 0:0389ce4f9789 813 {
FDLKHM 0:0389ce4f9789 814 if (packet_periods_packet->packet_periods[i].packet_id)
FDLKHM 0:0389ce4f9789 815 {
FDLKHM 0:0389ce4f9789 816 an_packet->data[2 + 5 * i] = packet_periods_packet->packet_periods[i].packet_id;
FDLKHM 0:0389ce4f9789 817 memcpy(&an_packet->data[2 + 5 * i + 1], &packet_periods_packet->packet_periods[i].period, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 818 }
FDLKHM 0:0389ce4f9789 819 else break;
FDLKHM 0:0389ce4f9789 820 }
FDLKHM 0:0389ce4f9789 821 an_packet->length = 2 + 5 * i;
FDLKHM 0:0389ce4f9789 822 }
FDLKHM 0:0389ce4f9789 823 return an_packet;
FDLKHM 0:0389ce4f9789 824 }
FDLKHM 0:0389ce4f9789 825
FDLKHM 0:0389ce4f9789 826 int decode_baud_rates_packet(baud_rates_packet_t *baud_rates_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 827 {
FDLKHM 0:0389ce4f9789 828 if (an_packet->id == packet_id_baud_rates && an_packet->length == 17)
FDLKHM 0:0389ce4f9789 829 {
FDLKHM 0:0389ce4f9789 830 baud_rates_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 831 memcpy(&baud_rates_packet->primary_baud_rate, &an_packet->data[1], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 832 memcpy(&baud_rates_packet->gpio_1_2_baud_rate, &an_packet->data[5], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 833 memcpy(&baud_rates_packet->auxiliary_baud_rate, &an_packet->data[9], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 834 memcpy(&baud_rates_packet->reserved, &an_packet->data[13], sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 835 return 0;
FDLKHM 0:0389ce4f9789 836 }
FDLKHM 0:0389ce4f9789 837 else return 1;
FDLKHM 0:0389ce4f9789 838 }
FDLKHM 0:0389ce4f9789 839
FDLKHM 0:0389ce4f9789 840 an_packet_t *encode_baud_rates_packet(baud_rates_packet_t *baud_rates_packet)
FDLKHM 0:0389ce4f9789 841 {
FDLKHM 0:0389ce4f9789 842 an_packet_t *an_packet = an_packet_allocate(17, packet_id_baud_rates);
FDLKHM 0:0389ce4f9789 843 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 844 {
FDLKHM 0:0389ce4f9789 845 an_packet->data[0] = baud_rates_packet->permanent;
FDLKHM 0:0389ce4f9789 846 memcpy(&an_packet->data[1], &baud_rates_packet->primary_baud_rate, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 847 memcpy(&an_packet->data[5], &baud_rates_packet->gpio_1_2_baud_rate, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 848 memcpy(&an_packet->data[9], &baud_rates_packet->auxiliary_baud_rate, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 849 memcpy(&an_packet->data[13], &baud_rates_packet->reserved, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 850 }
FDLKHM 0:0389ce4f9789 851 return an_packet;
FDLKHM 0:0389ce4f9789 852 }
FDLKHM 0:0389ce4f9789 853
FDLKHM 0:0389ce4f9789 854 int decode_sensor_ranges_packet(sensor_ranges_packet_t *sensor_ranges_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 855 {
FDLKHM 0:0389ce4f9789 856 if (an_packet->id == packet_id_sensor_ranges && an_packet->length == 4)
FDLKHM 0:0389ce4f9789 857 {
FDLKHM 0:0389ce4f9789 858 memcpy(sensor_ranges_packet, an_packet->data, 4 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 859 return 0;
FDLKHM 0:0389ce4f9789 860 }
FDLKHM 0:0389ce4f9789 861 else return 1;
FDLKHM 0:0389ce4f9789 862 }
FDLKHM 0:0389ce4f9789 863
FDLKHM 0:0389ce4f9789 864 an_packet_t *encode_sensor_ranges_packet(sensor_ranges_packet_t *sensor_ranges_packet)
FDLKHM 0:0389ce4f9789 865 {
FDLKHM 0:0389ce4f9789 866 an_packet_t *an_packet = an_packet_allocate(4, packet_id_sensor_ranges);
FDLKHM 0:0389ce4f9789 867 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 868 {
FDLKHM 0:0389ce4f9789 869 memcpy(an_packet->data, sensor_ranges_packet, 4 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 870 }
FDLKHM 0:0389ce4f9789 871 return an_packet;
FDLKHM 0:0389ce4f9789 872 }
FDLKHM 0:0389ce4f9789 873
FDLKHM 0:0389ce4f9789 874 int decode_installation_alignment_packet(installation_alignment_packet_t *installation_alignment_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 875 {
FDLKHM 0:0389ce4f9789 876 if (an_packet->id == packet_id_installation_alignment && an_packet->length == 73)
FDLKHM 0:0389ce4f9789 877 {
FDLKHM 0:0389ce4f9789 878 installation_alignment_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 879 memcpy(&installation_alignment_packet->alignment_dcm[0][0], &an_packet->data[1], 9 * sizeof(float));
FDLKHM 0:0389ce4f9789 880 memcpy(&installation_alignment_packet->gnss_antenna_offset[0], &an_packet->data[37], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 881 memcpy(&installation_alignment_packet->odometer_offset[0], &an_packet->data[49], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 882 memcpy(&installation_alignment_packet->external_data_offset[0], &an_packet->data[61], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 883 return 0;
FDLKHM 0:0389ce4f9789 884 }
FDLKHM 0:0389ce4f9789 885 else return 1;
FDLKHM 0:0389ce4f9789 886 }
FDLKHM 0:0389ce4f9789 887
FDLKHM 0:0389ce4f9789 888 an_packet_t *encode_installation_alignment_packet(installation_alignment_packet_t *installation_alignment_packet)
FDLKHM 0:0389ce4f9789 889 {
FDLKHM 0:0389ce4f9789 890 an_packet_t *an_packet = an_packet_allocate(73, packet_id_installation_alignment);
FDLKHM 0:0389ce4f9789 891 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 892 {
FDLKHM 0:0389ce4f9789 893 an_packet->data[0] = installation_alignment_packet->permanent;
FDLKHM 0:0389ce4f9789 894 memcpy(&an_packet->data[1], &installation_alignment_packet->alignment_dcm[0][0], 9 * sizeof(float));
FDLKHM 0:0389ce4f9789 895 memcpy(&an_packet->data[37], &installation_alignment_packet->gnss_antenna_offset[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 896 memcpy(&an_packet->data[49], &installation_alignment_packet->odometer_offset[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 897 memcpy(&an_packet->data[61], &installation_alignment_packet->external_data_offset[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 898 }
FDLKHM 0:0389ce4f9789 899 return an_packet;
FDLKHM 0:0389ce4f9789 900 }
FDLKHM 0:0389ce4f9789 901
FDLKHM 0:0389ce4f9789 902 int decode_filter_options_packet(filter_options_packet_t *filter_options_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 903 {
FDLKHM 0:0389ce4f9789 904 if (an_packet->id == packet_id_filter_options && an_packet->length == 17)
FDLKHM 0:0389ce4f9789 905 {
FDLKHM 0:0389ce4f9789 906 memcpy(filter_options_packet, &an_packet->data[0], 9 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 907 return 0;
FDLKHM 0:0389ce4f9789 908 }
FDLKHM 0:0389ce4f9789 909 else return 1;
FDLKHM 0:0389ce4f9789 910 }
FDLKHM 0:0389ce4f9789 911
FDLKHM 0:0389ce4f9789 912 an_packet_t *encode_filter_options_packet(filter_options_packet_t *filter_options_packet)
FDLKHM 0:0389ce4f9789 913 {
FDLKHM 0:0389ce4f9789 914 an_packet_t *an_packet = an_packet_allocate(17, packet_id_filter_options);
FDLKHM 0:0389ce4f9789 915 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 916 {
FDLKHM 0:0389ce4f9789 917 memcpy(&an_packet->data[0], filter_options_packet, 9 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 918 memset(&an_packet->data[9], 0, 8 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 919 }
FDLKHM 0:0389ce4f9789 920 return an_packet;
FDLKHM 0:0389ce4f9789 921 }
FDLKHM 0:0389ce4f9789 922
FDLKHM 0:0389ce4f9789 923 int decode_gpio_configuration_packet(gpio_configuration_packet_t *gpio_configuration_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 924 {
FDLKHM 0:0389ce4f9789 925 if (an_packet->id == packet_id_gpio_configuration && an_packet->length == 13)
FDLKHM 0:0389ce4f9789 926 {
FDLKHM 0:0389ce4f9789 927 memcpy(gpio_configuration_packet, &an_packet->data[0], 5 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 928 return 0;
FDLKHM 0:0389ce4f9789 929 }
FDLKHM 0:0389ce4f9789 930 else return 1;
FDLKHM 0:0389ce4f9789 931 }
FDLKHM 0:0389ce4f9789 932
FDLKHM 0:0389ce4f9789 933 an_packet_t *encode_gpio_configuration_packet(gpio_configuration_packet_t *gpio_configuration_packet)
FDLKHM 0:0389ce4f9789 934 {
FDLKHM 0:0389ce4f9789 935 an_packet_t *an_packet = an_packet_allocate(13, packet_id_gpio_configuration);
FDLKHM 0:0389ce4f9789 936 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 937 {
FDLKHM 0:0389ce4f9789 938 memcpy(&an_packet->data[0], gpio_configuration_packet, 5 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 939 memset(&an_packet->data[5], 0, 8 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 940 }
FDLKHM 0:0389ce4f9789 941 return an_packet;
FDLKHM 0:0389ce4f9789 942 }
FDLKHM 0:0389ce4f9789 943
FDLKHM 0:0389ce4f9789 944 int decode_magnetic_calibration_values_packet(magnetic_calibration_values_packet_t *magnetic_calibration_values_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 945 {
FDLKHM 0:0389ce4f9789 946 if (an_packet->id == packet_id_magnetic_calibration_values && an_packet->length == 49)
FDLKHM 0:0389ce4f9789 947 {
FDLKHM 0:0389ce4f9789 948 magnetic_calibration_values_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 949 memcpy(magnetic_calibration_values_packet->hard_iron, &an_packet->data[5], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 950 memcpy(magnetic_calibration_values_packet->soft_iron, &an_packet->data[13], 9 * sizeof(float));
FDLKHM 0:0389ce4f9789 951 return 0;
FDLKHM 0:0389ce4f9789 952 }
FDLKHM 0:0389ce4f9789 953 else return 1;
FDLKHM 0:0389ce4f9789 954 }
FDLKHM 0:0389ce4f9789 955
FDLKHM 0:0389ce4f9789 956 an_packet_t *encode_magnetic_calibration_values_packet(magnetic_calibration_values_packet_t *magnetic_calibration_values_packet)
FDLKHM 0:0389ce4f9789 957 {
FDLKHM 0:0389ce4f9789 958 an_packet_t *an_packet = an_packet_allocate(49, packet_id_magnetic_calibration_values);
FDLKHM 0:0389ce4f9789 959 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 960 {
FDLKHM 0:0389ce4f9789 961 an_packet->data[0] = magnetic_calibration_values_packet->permanent;
FDLKHM 0:0389ce4f9789 962 memcpy(&an_packet->data[1], magnetic_calibration_values_packet->hard_iron, 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 963 memcpy(&an_packet->data[13], magnetic_calibration_values_packet->soft_iron, 9 * sizeof(float));
FDLKHM 0:0389ce4f9789 964 }
FDLKHM 0:0389ce4f9789 965 return an_packet;
FDLKHM 0:0389ce4f9789 966 }
FDLKHM 0:0389ce4f9789 967
FDLKHM 0:0389ce4f9789 968 an_packet_t *encode_magnetic_calibration_configuration_packet(magnetic_calibration_configuration_packet_t *magnetic_calibration_configuration_packet)
FDLKHM 0:0389ce4f9789 969 {
FDLKHM 0:0389ce4f9789 970 an_packet_t *an_packet = an_packet_allocate(1, packet_id_magnetic_calibration_configuration);
FDLKHM 0:0389ce4f9789 971 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 972 {
FDLKHM 0:0389ce4f9789 973 an_packet->data[0] = magnetic_calibration_configuration_packet->magnetic_calibration_action;
FDLKHM 0:0389ce4f9789 974 }
FDLKHM 0:0389ce4f9789 975 return an_packet;
FDLKHM 0:0389ce4f9789 976 }
FDLKHM 0:0389ce4f9789 977
FDLKHM 0:0389ce4f9789 978 int decode_magnetic_calibration_status_packet(magnetic_calibration_status_packet_t *magnetic_calibration_status_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 979 {
FDLKHM 0:0389ce4f9789 980 if (an_packet->id == packet_id_magnetic_calibration_status && an_packet->length == 3)
FDLKHM 0:0389ce4f9789 981 {
FDLKHM 0:0389ce4f9789 982 magnetic_calibration_status_packet->magnetic_calibration_status = an_packet->data[0];
FDLKHM 0:0389ce4f9789 983 magnetic_calibration_status_packet->magnetic_calibration_progress_percentage = an_packet->data[1];
FDLKHM 0:0389ce4f9789 984 magnetic_calibration_status_packet->local_magnetic_error_percentage = an_packet->data[2];
FDLKHM 0:0389ce4f9789 985 return 0;
FDLKHM 0:0389ce4f9789 986 }
FDLKHM 0:0389ce4f9789 987 return 1;
FDLKHM 0:0389ce4f9789 988 }
FDLKHM 0:0389ce4f9789 989
FDLKHM 0:0389ce4f9789 990 int decode_odometer_configuration_packet(odometer_configuration_packet_t *odometer_configuration_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 991 {
FDLKHM 0:0389ce4f9789 992 if (an_packet->id == packet_id_odometer_configuration && an_packet->length == 8)
FDLKHM 0:0389ce4f9789 993 {
FDLKHM 0:0389ce4f9789 994 odometer_configuration_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 995 odometer_configuration_packet->automatic_calibration = an_packet->data[1];
FDLKHM 0:0389ce4f9789 996 memcpy(&odometer_configuration_packet->pulse_length, &an_packet->data[4], sizeof(float));
FDLKHM 0:0389ce4f9789 997 return 0;
FDLKHM 0:0389ce4f9789 998 }
FDLKHM 0:0389ce4f9789 999 else return 1;
FDLKHM 0:0389ce4f9789 1000 }
FDLKHM 0:0389ce4f9789 1001
FDLKHM 0:0389ce4f9789 1002 an_packet_t *encode_odometer_configuration_packet(odometer_configuration_packet_t *odometer_configuration_packet)
FDLKHM 0:0389ce4f9789 1003 {
FDLKHM 0:0389ce4f9789 1004 an_packet_t *an_packet = an_packet_allocate(8, packet_id_odometer_configuration);
FDLKHM 0:0389ce4f9789 1005 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 1006 {
FDLKHM 0:0389ce4f9789 1007 an_packet->data[0] = odometer_configuration_packet->permanent;
FDLKHM 0:0389ce4f9789 1008 an_packet->data[1] = odometer_configuration_packet->automatic_calibration;
FDLKHM 0:0389ce4f9789 1009 memset(&an_packet->data[2], 0, 2 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 1010 memcpy(&an_packet->data[4], &odometer_configuration_packet->pulse_length, sizeof(float));
FDLKHM 0:0389ce4f9789 1011 }
FDLKHM 0:0389ce4f9789 1012 return an_packet;
FDLKHM 0:0389ce4f9789 1013 }
FDLKHM 0:0389ce4f9789 1014
FDLKHM 0:0389ce4f9789 1015 an_packet_t *encode_zero_alignment_packet(zero_alignment_packet_t *zero_alignment_packet)
FDLKHM 0:0389ce4f9789 1016 {
FDLKHM 0:0389ce4f9789 1017 uint32_t verification = 0x9A4E8055;
FDLKHM 0:0389ce4f9789 1018 an_packet_t *an_packet = an_packet_allocate(5, packet_id_zero_alignment);
FDLKHM 0:0389ce4f9789 1019 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 1020 {
FDLKHM 0:0389ce4f9789 1021 an_packet->data[0] = zero_alignment_packet->permanent;
FDLKHM 0:0389ce4f9789 1022 memcpy(&an_packet->data[1], &verification, sizeof(uint32_t));
FDLKHM 0:0389ce4f9789 1023 }
FDLKHM 0:0389ce4f9789 1024 return an_packet;
FDLKHM 0:0389ce4f9789 1025 }
FDLKHM 0:0389ce4f9789 1026
FDLKHM 0:0389ce4f9789 1027 int decode_heave_offset_packet(heave_offset_packet_t *heave_offset_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 1028 {
FDLKHM 0:0389ce4f9789 1029 if (an_packet->id == packet_id_heave_offset && an_packet->length == 49)
FDLKHM 0:0389ce4f9789 1030 {
FDLKHM 0:0389ce4f9789 1031 heave_offset_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 1032 memcpy(&heave_offset_packet->heave_point_1_offset[0], &an_packet->data[1], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1033 memcpy(&heave_offset_packet->heave_point_2_offset[0], &an_packet->data[13], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1034 memcpy(&heave_offset_packet->heave_point_3_offset[0], &an_packet->data[25], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1035 memcpy(&heave_offset_packet->heave_point_4_offset[0], &an_packet->data[37], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1036 return 0;
FDLKHM 0:0389ce4f9789 1037 }
FDLKHM 0:0389ce4f9789 1038 else return 1;
FDLKHM 0:0389ce4f9789 1039 }
FDLKHM 0:0389ce4f9789 1040
FDLKHM 0:0389ce4f9789 1041 an_packet_t *encode_heave_offset_packet(heave_offset_packet_t *heave_offset_packet)
FDLKHM 0:0389ce4f9789 1042 {
FDLKHM 0:0389ce4f9789 1043 an_packet_t *an_packet = an_packet_allocate(49, packet_id_odometer_configuration);
FDLKHM 0:0389ce4f9789 1044 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 1045 {
FDLKHM 0:0389ce4f9789 1046 an_packet->data[0] = heave_offset_packet->permanent;
FDLKHM 0:0389ce4f9789 1047 memcpy(&an_packet->data[1], &heave_offset_packet->heave_point_1_offset[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1048 memcpy(&an_packet->data[13], &heave_offset_packet->heave_point_2_offset[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1049 memcpy(&an_packet->data[25], &heave_offset_packet->heave_point_3_offset[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1050 memcpy(&an_packet->data[37], &heave_offset_packet->heave_point_4_offset[0], 3 * sizeof(float));
FDLKHM 0:0389ce4f9789 1051 }
FDLKHM 0:0389ce4f9789 1052 return an_packet;
FDLKHM 0:0389ce4f9789 1053 }
FDLKHM 0:0389ce4f9789 1054
FDLKHM 0:0389ce4f9789 1055 int decode_gpio_output_configuration_packet(gpio_output_configuration_packet_t *gpio_output_configuration_packet, an_packet_t *an_packet)
FDLKHM 0:0389ce4f9789 1056 {
FDLKHM 0:0389ce4f9789 1057 if (an_packet->id == packet_id_gpio_output_configuration && an_packet->length == 33)
FDLKHM 0:0389ce4f9789 1058 {
FDLKHM 0:0389ce4f9789 1059 gpio_output_configuration_packet->permanent = an_packet->data[0];
FDLKHM 0:0389ce4f9789 1060 gpio_output_configuration_packet->nmea_fix_behaviour = an_packet->data[1];
FDLKHM 0:0389ce4f9789 1061 memcpy(&gpio_output_configuration_packet->gpzda_rate.r, &an_packet->data[2], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1062 memcpy(&gpio_output_configuration_packet->gpgga_rate.r, &an_packet->data[4], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1063 memcpy(&gpio_output_configuration_packet->gpvtg_rate.r, &an_packet->data[6], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1064 memcpy(&gpio_output_configuration_packet->gprmc_rate.r, &an_packet->data[8], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1065 memcpy(&gpio_output_configuration_packet->gphdt_rate.r, &an_packet->data[10], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1066 memcpy(&gpio_output_configuration_packet->gpgll_rate.r, &an_packet->data[12], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1067 memcpy(&gpio_output_configuration_packet->pashr_rate.r, &an_packet->data[14], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1068 memcpy(&gpio_output_configuration_packet->tss1_rate.r, &an_packet->data[16], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1069 memcpy(&gpio_output_configuration_packet->simrad_rate.r, &an_packet->data[18], sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1070 return 0;
FDLKHM 0:0389ce4f9789 1071 }
FDLKHM 0:0389ce4f9789 1072 else return 1;
FDLKHM 0:0389ce4f9789 1073 }
FDLKHM 0:0389ce4f9789 1074
FDLKHM 0:0389ce4f9789 1075 an_packet_t *encode_gpio_output_configuration_packet(gpio_output_configuration_packet_t *gpio_output_configuration_packet)
FDLKHM 0:0389ce4f9789 1076 {
FDLKHM 0:0389ce4f9789 1077 an_packet_t *an_packet = an_packet_allocate(33, packet_id_gpio_output_configuration);
FDLKHM 0:0389ce4f9789 1078 if (an_packet != NULL)
FDLKHM 0:0389ce4f9789 1079 {
FDLKHM 0:0389ce4f9789 1080 an_packet->data[0] = gpio_output_configuration_packet->permanent;
FDLKHM 0:0389ce4f9789 1081 an_packet->data[1] = gpio_output_configuration_packet->nmea_fix_behaviour;
FDLKHM 0:0389ce4f9789 1082 memcpy(&an_packet->data[2], &gpio_output_configuration_packet->gpzda_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1083 memcpy(&an_packet->data[4], &gpio_output_configuration_packet->gpgga_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1084 memcpy(&an_packet->data[6], &gpio_output_configuration_packet->gpvtg_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1085 memcpy(&an_packet->data[8], &gpio_output_configuration_packet->gprmc_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1086 memcpy(&an_packet->data[10], &gpio_output_configuration_packet->gphdt_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1087 memcpy(&an_packet->data[12], &gpio_output_configuration_packet->gpgll_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1088 memcpy(&an_packet->data[14], &gpio_output_configuration_packet->pashr_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1089 memcpy(&an_packet->data[16], &gpio_output_configuration_packet->tss1_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1090 memcpy(&an_packet->data[18], &gpio_output_configuration_packet->simrad_rate.r, sizeof(uint16_t));
FDLKHM 0:0389ce4f9789 1091 memset(&an_packet->data[20], 0, 13 * sizeof(uint8_t));
FDLKHM 0:0389ce4f9789 1092 }
FDLKHM 0:0389ce4f9789 1093 return an_packet;
FDLKHM 0:0389ce4f9789 1094 }