CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_ADSB/sagetech-sdk/sgDecodeFlightId.c
Views: 1799
1
/**
2
* @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved.
3
*
4
* @file sgDecodeFlightId.c
5
* @author Jacob.Garrison
6
*
7
* @date Mar 10, 2021
8
*
9
*/
10
11
#include <string.h>
12
13
#include "sg.h"
14
#include "sgUtil.h"
15
16
#define SG_ID_LEN 8 // The number of bytes in the flight id field
17
18
typedef struct __attribute__((packed))
19
{
20
uint8_t start;
21
uint8_t type;
22
uint8_t id;
23
uint8_t payloadLen;
24
char flightId[SG_ID_LEN];
25
uint8_t rsvd[4];
26
uint8_t checksum;
27
} flightid_t;
28
29
/*
30
* Documented in the header file.
31
*/
32
bool sgDecodeFlightId(uint8_t *buffer, sg_flightid_t *id)
33
{
34
flightid_t sgId;
35
memcpy(&sgId, buffer, sizeof(flightid_t));
36
37
strcpy(id->flightId, sgId.flightId);
38
memset(&id->flightId[SG_ID_LEN], '\0', 1); // Ensure flight id is null-terminated
39
40
return true;
41
}
42
43