Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_ADSB/sagetech-sdk/sgEncodeTargetReq.c
Views: 1799
/**1* @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved.2*3* @file sgEncodeTargetReq.c4* @author Jacob.Garrison5*6* @date Feb 19, 20217*8* This file receives a populated target request struct and9* converts it into a target request message buffer.10*/1112#include <stdbool.h>13#include <stdlib.h>1415#include "sg.h"16#include "sgUtil.h"1718#define SG_PAYLOAD_LEN_TARGETREQ SG_MSG_LEN_TARGETREQ - 5 /// the payload length.1920#define PBASE 4 /// the payload offset.2122#define OFFSET_REQ_TYPE 0 /// the adsb reporting type and transmit port offset23#define OFFSET_MAX_TARGETS 1 /// the maximum number of targets offset24#define OFFSET_ICAO 3 /// the requested target icao offset25#define OFFSET_REPORTS 6 /// the requested report type offset26/*27* Documented in the header file.28*/29bool sgEncodeTargetReq(uint8_t *buffer, sg_targetreq_t *tgt, uint8_t msgId)30{3132// populate header33buffer[0] = SG_MSG_START_BYTE;34buffer[1] = SG_MSG_TYPE_HOST_TARGETREQ;35buffer[2] = msgId;36buffer[3] = SG_PAYLOAD_LEN_TARGETREQ;3738// populate Request Type39buffer[PBASE + OFFSET_REQ_TYPE] = tgt->transmitPort << 6 |40tgt->reqType;4142// populate Max Targets43uint162Buf(&buffer[PBASE + OFFSET_MAX_TARGETS], tgt->maxTargets);4445// populate Requested ICAO46icao2Buf(&buffer[PBASE + OFFSET_ICAO], tgt->icao);4748// populated Requested Reports49buffer[PBASE + OFFSET_REPORTS] = tgt->ownship << 7 |50tgt->commA << 6 |51tgt->military << 5 |52tgt->tisb << 4 |53tgt->airRefVel << 3 |54tgt->targetState << 2 |55tgt->modeStatus << 1 |56tgt->stateVector;5758// populate checksum59appendChecksum(buffer, SG_MSG_LEN_TARGETREQ);6061return true;62}636465