dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
UAVTalk implementation

Files

file  uavtalk.h
 Include file of the UAVTalk library.
 
file  uavtalk_priv.h
 Private include file of the UAVTalk library.
 
file  uavtalk.c
 UAVTalk library, implements to telemetry protocol. See the wiki for more details.
 

Data Structures

struct  UAVTalkStats
 Tracking statistics for a UAVTalk connection. More...
 
struct  uavtalk_min_header
 Minimal UAVTalk header without an instance field. More...
 
struct  uavtalk_max_header
 Full UAVTalk header with an instance field. More...
 
struct  filereq_data
 
struct  fileresp_data
 
struct  UAVTalkInputProcessor
 State information for the UAVTalk parser. More...
 
struct  UAVTalkConnectionData
 Information for the physical link. More...
 

Macros

#define UAVTALK_MIN_HEADER_LENGTH   sizeof(uavtalk_min_header)
 
#define UAVTALK_MAX_HEADER_LENGTH   sizeof(uavtalk_max_header)
 
#define UAVTALK_CHECKSUM_LENGTH   sizeof(uavtalk_checksum)
 
#define UAVTALK_MAX_PAYLOAD_LENGTH   (UAVOBJECTS_LARGEST + 1)
 
#define UAVTALK_MIN_PACKET_LENGTH   UAVTALK_MAX_HEADER_LENGTH + UAVTALK_CHECKSUM_LENGTH
 
#define UAVTALK_MAX_PACKET_LENGTH   UAVTALK_MIN_PACKET_LENGTH + UAVTALK_MAX_PAYLOAD_LENGTH
 
#define UAVTALK_CANARI   0xCA
 
#define UAVTALK_WAITFOREVER   -1
 
#define UAVTALK_NOWAIT   0
 
#define UAVTALK_SYNC_VAL   0x3C
 
#define UAVTALK_TYPE_MASK   0x70
 
#define UAVTALK_TYPE_VER   0x20
 
#define UAVTALK_TIMESTAMPED   0x80
 
#define UAVTALK_TYPE_OBJ   (UAVTALK_TYPE_VER | 0x00)
 
#define UAVTALK_TYPE_OBJ_REQ   (UAVTALK_TYPE_VER | 0x01)
 
#define UAVTALK_TYPE_OBJ_ACK   (UAVTALK_TYPE_VER | 0x02)
 
#define UAVTALK_TYPE_ACK   (UAVTALK_TYPE_VER | 0x03)
 
#define UAVTALK_TYPE_NACK   (UAVTALK_TYPE_VER | 0x04)
 
#define UAVTALK_TYPE_FILEREQ   (UAVTALK_TYPE_VER | 0x08)
 
#define UAVTALK_TYPE_FILEDATA   (UAVTALK_TYPE_VER | 0x09)
 
#define UAVTALK_TYPE_OBJ_TS   (UAVTALK_TIMESTAMPED | UAVTALK_TYPE_OBJ)
 
#define UAVTALK_FILEDATA_EOF   0x01
 
#define UAVTALK_FILEDATA_LAST   0x02
 
#define CHECKCONHANDLE(handle, variable, failcommand)
 

Typedefs

typedef int32_t(* UAVTalkOutputCb )(void *ctx, uint8_t *data, int32_t length)
 
typedef void(* UAVTalkAckCb )(void *ctx, uint32_t obj_id, uint16_t inst_id)
 
typedef void(* UAVTalkReqCb )(void *ctx, uint32_t obj_id, uint16_t inst_id)
 
typedef int32_t(* UAVTalkFileCb )(void *ctx, uint8_t *buf, uint32_t file_id, uint32_t offset, uint32_t len)
 
typedef void * UAVTalkConnection
 
typedef uint8_t uavtalk_checksum
 

Enumerations

enum  UAVTalkRxState {
  UAVTALK_STATE_ERROR = 0, UAVTALK_STATE_SYNC, UAVTALK_STATE_TYPE, UAVTALK_STATE_SIZE,
  UAVTALK_STATE_OBJID, UAVTALK_STATE_INSTID, UAVTALK_STATE_DATA, UAVTALK_STATE_CS,
  UAVTALK_STATE_COMPLETE
}
 

Functions

UAVTalkConnection UAVTalkInitialize (void *ctx, UAVTalkOutputCb outputStream, UAVTalkAckCb ackCallback, UAVTalkReqCb reqCallback, UAVTalkFileCb fileCallback)
 
int32_t UAVTalkSendObject (UAVTalkConnection connection, UAVObjHandle obj, uint16_t instId, uint8_t acked)
 
int32_t UAVTalkSendObjectTimestamped (UAVTalkConnection connectionHandle, UAVObjHandle obj, uint16_t instId)
 
int32_t UAVTalkSendNack (UAVTalkConnection connectionHandle, uint32_t objId, uint16_t instId)
 
void UAVTalkProcessInputStream (UAVTalkConnection connectionHandle, uint8_t *rxbytes, int numbytes)
 
UAVTalkRxState UAVTalkProcessInputStreamQuiet (UAVTalkConnection connection, uint8_t rxbyte)
 
int32_t UAVTalkRelayPacket (UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle)
 
int32_t UAVTalkReceiveObject (UAVTalkConnection connectionHandle)
 
void UAVTalkGetStats (UAVTalkConnection connection, UAVTalkStats *stats)
 
uint32_t UAVTalkGetPacketObjId (UAVTalkConnection connection)
 
uint32_t UAVTalkGetPacketInstId (UAVTalkConnection connection)
 
struct filereq_data __attribute__ ((packed))
 
static int32_t objectTransaction (UAVTalkConnectionData *connection, UAVObjHandle objectId, uint16_t instId, uint8_t type)
 
static int32_t sendObject (UAVTalkConnectionData *connection, UAVObjHandle obj, uint16_t instId, uint8_t type)
 
static int32_t sendSingleObject (UAVTalkConnectionData *connection, UAVObjHandle obj, uint16_t instId, uint8_t type)
 
static int32_t receiveObject (UAVTalkConnectionData *connection)
 
static int32_t sendNack (UAVTalkConnectionData *connection, uint32_t objId, uint16_t instId)
 
static void handleFileReq (UAVTalkConnectionData *connection)
 

Variables

typedef __attribute__
 

Detailed Description

Macro Definition Documentation

#define CHECKCONHANDLE (   handle,
  variable,
  failcommand 
)
Value:
variable = (UAVTalkConnectionData*) handle; \
if (variable == NULL || variable->canari != UAVTALK_CANARI) { \
failcommand; \
}
Information for the physical link.
Definition: uavtalk_priv.h:90
if(BaroAltitudeHandle()!=NULL)
#define UAVTALK_CANARI
Definition: uavtalk_priv.h:106

Definition at line 126 of file uavtalk_priv.h.

#define UAVTALK_CANARI   0xCA

Definition at line 106 of file uavtalk_priv.h.

#define UAVTALK_CHECKSUM_LENGTH   sizeof(uavtalk_checksum)

Definition at line 69 of file uavtalk_priv.h.

#define UAVTALK_FILEDATA_EOF   0x01

Definition at line 122 of file uavtalk_priv.h.

#define UAVTALK_FILEDATA_LAST   0x02

Definition at line 123 of file uavtalk_priv.h.

#define UAVTALK_MAX_HEADER_LENGTH   sizeof(uavtalk_max_header)

Definition at line 56 of file uavtalk_priv.h.

#define UAVTALK_MAX_PACKET_LENGTH   UAVTALK_MIN_PACKET_LENGTH + UAVTALK_MAX_PAYLOAD_LENGTH

Definition at line 72 of file uavtalk_priv.h.

#define UAVTALK_MAX_PAYLOAD_LENGTH   (UAVOBJECTS_LARGEST + 1)

Definition at line 70 of file uavtalk_priv.h.

#define UAVTALK_MIN_HEADER_LENGTH   sizeof(uavtalk_min_header)

Definition at line 46 of file uavtalk_priv.h.

#define UAVTALK_MIN_PACKET_LENGTH   UAVTALK_MAX_HEADER_LENGTH + UAVTALK_CHECKSUM_LENGTH

Definition at line 71 of file uavtalk_priv.h.

#define UAVTALK_NOWAIT   0

Definition at line 108 of file uavtalk_priv.h.

#define UAVTALK_SYNC_VAL   0x3C

Definition at line 109 of file uavtalk_priv.h.

#define UAVTALK_TIMESTAMPED   0x80

Definition at line 112 of file uavtalk_priv.h.

#define UAVTALK_TYPE_ACK   (UAVTALK_TYPE_VER | 0x03)

Definition at line 116 of file uavtalk_priv.h.

#define UAVTALK_TYPE_FILEDATA   (UAVTALK_TYPE_VER | 0x09)

Definition at line 119 of file uavtalk_priv.h.

#define UAVTALK_TYPE_FILEREQ   (UAVTALK_TYPE_VER | 0x08)

Definition at line 118 of file uavtalk_priv.h.

#define UAVTALK_TYPE_MASK   0x70

Definition at line 110 of file uavtalk_priv.h.

#define UAVTALK_TYPE_NACK   (UAVTALK_TYPE_VER | 0x04)

Definition at line 117 of file uavtalk_priv.h.

#define UAVTALK_TYPE_OBJ   (UAVTALK_TYPE_VER | 0x00)

Definition at line 113 of file uavtalk_priv.h.

#define UAVTALK_TYPE_OBJ_ACK   (UAVTALK_TYPE_VER | 0x02)

Definition at line 115 of file uavtalk_priv.h.

#define UAVTALK_TYPE_OBJ_REQ   (UAVTALK_TYPE_VER | 0x01)

Definition at line 114 of file uavtalk_priv.h.

#define UAVTALK_TYPE_OBJ_TS   (UAVTALK_TIMESTAMPED | UAVTALK_TYPE_OBJ)

Definition at line 120 of file uavtalk_priv.h.

#define UAVTALK_TYPE_VER   0x20

Definition at line 111 of file uavtalk_priv.h.

#define UAVTALK_WAITFOREVER   -1

Definition at line 107 of file uavtalk_priv.h.

Typedef Documentation

typedef uint8_t uavtalk_checksum

Definition at line 68 of file uavtalk_priv.h.

typedef void(* UAVTalkAckCb)(void *ctx, uint32_t obj_id, uint16_t inst_id)

Definition at line 35 of file uavtalk.h.

typedef void* UAVTalkConnection

Definition at line 53 of file uavtalk.h.

typedef int32_t(* UAVTalkFileCb)(void *ctx, uint8_t *buf, uint32_t file_id, uint32_t offset, uint32_t len)

Definition at line 37 of file uavtalk.h.

typedef int32_t(* UAVTalkOutputCb)(void *ctx, uint8_t *data, int32_t length)

Definition at line 34 of file uavtalk.h.

typedef void(* UAVTalkReqCb)(void *ctx, uint32_t obj_id, uint16_t inst_id)

Definition at line 36 of file uavtalk.h.

Enumeration Type Documentation

Enumerator
UAVTALK_STATE_ERROR 
UAVTALK_STATE_SYNC 
UAVTALK_STATE_TYPE 
UAVTALK_STATE_SIZE 
UAVTALK_STATE_OBJID 
UAVTALK_STATE_INSTID 
UAVTALK_STATE_DATA 
UAVTALK_STATE_CS 
UAVTALK_STATE_COMPLETE 

Definition at line 55 of file uavtalk.h.

Function Documentation

struct filereq_data __attribute__ ( (packed)  )

Definition at line 38 of file serial_4way.h.

static void handleFileReq ( UAVTalkConnectionData connection)
static

Handles a request for file data.

Parameters
[in]connectionThe connection on which a request was just received.

Definition at line 577 of file uavtalk.c.

static int32_t objectTransaction ( UAVTalkConnectionData connection,
UAVObjHandle  obj,
uint16_t  instId,
uint8_t  type 
)
static

Execute the requested transaction on an object.

Parameters
[in]connectionUAVTalkConnection to be used
[in]objObject
[in]instIdThe instance ID of UAVOBJ_ALL_INSTANCES for all instances.
[in]typeTransaction type UAVTALK_TYPE_OBJ: send object, UAVTALK_TYPE_OBJ_REQ: request object update UAVTALK_TYPE_OBJ_ACK: send object with an ack
Returns
0 Success
-1 Failure

Definition at line 162 of file uavtalk.c.

static int32_t receiveObject ( UAVTalkConnectionData connection)
static

Receive an object. This function process objects received through the telemetry stream.

Parameters
[in]connectionUAVTalkConnection to be used
[in]typeType of received message (UAVTALK_TYPE_OBJ, UAVTALK_TYPE_OBJ_REQ, UAVTALK_TYPE_OBJ_ACK, UAVTALK_TYPE_ACK, UAVTALK_TYPE_NACK)
[in]objIdID of the object to work on
[in]instIdThe instance ID of UAVOBJ_ALL_INSTANCES for all instances.
[in]dataData buffer
[in]lengthBuffer length
Returns
0 Success
-1 Failure

Definition at line 673 of file uavtalk.c.

static int32_t sendNack ( UAVTalkConnectionData connection,
uint32_t  objId,
uint16_t  instId 
)
static

Definition at line 912 of file uavtalk.c.

static int32_t sendObject ( UAVTalkConnectionData connection,
UAVObjHandle  obj,
uint16_t  instId,
uint8_t  type 
)
static

Send an object through the telemetry link.

Parameters
[in]connectionUAVTalkConnection to be used
[in]objObject handle to send
[in]instIdThe instance ID or UAVOBJ_ALL_INSTANCES for all instances
[in]typeTransaction type
Returns
0 Success
-1 Failure

Definition at line 765 of file uavtalk.c.

static int32_t sendSingleObject ( UAVTalkConnectionData connection,
UAVObjHandle  obj,
uint16_t  instId,
uint8_t  type 
)
static

Send an object through the telemetry link.

Parameters
[in]connectionUAVTalkConnection to be used
[in]objObject handle to send
[in]instIdThe instance ID (can NOT be UAVOBJ_ALL_INSTANCES, use sendObject() instead)
[in]typeTransaction type
Returns
0 Success
-1 Failure

Definition at line 814 of file uavtalk.c.

uint32_t UAVTalkGetPacketInstId ( UAVTalkConnection  connectionHandle)

Get the instance ID of the current packet.

Parameters
[in]connectionHandleUAVTalkConnection to be used
Returns
The instance ID, or 0 on error.

Definition at line 564 of file uavtalk.c.

uint32_t UAVTalkGetPacketObjId ( UAVTalkConnection  connectionHandle)

Get the object ID of the current packet.

Parameters
[in]connectionHandleUAVTalkConnection to be used
Returns
The object ID, or 0 on error.

Definition at line 550 of file uavtalk.c.

void UAVTalkGetStats ( UAVTalkConnection  connectionHandle,
UAVTalkStats statsOut 
)

Get communication statistics counters since last call (reset afterwards)

Parameters
[in]connectionUAVTalkConnection to be used
[out]statsOutStatistics counters

Definition at line 93 of file uavtalk.c.

UAVTalkConnection UAVTalkInitialize ( void *  ctx,
UAVTalkOutputCb  outputStream,
UAVTalkAckCb  ackCallback,
UAVTalkReqCb  reqCallback,
UAVTalkFileCb  fileCallback 
)

Initialize the UAVTalk library

Parameters
[in]connectionUAVTalkConnection to be used
[in]outputStreamFunction pointer that is called to send a data buffer
[in]ackCallbackA function to invoke when receiving an ack ] fileCallback A function which provides file data upon demand
Returns
0 Success
-1 Failure

Definition at line 59 of file uavtalk.c.

void UAVTalkProcessInputStream ( UAVTalkConnection  connectionHandle,
uint8_t *  rxbytes,
int  numbytes 
)

Process an byte from the telemetry stream.

Parameters
[in]connectionUAVTalkConnection to be used
[in]rxbyteReceived byte
Returns
UAVTalkRxState

Definition at line 423 of file uavtalk.c.

UAVTalkRxState UAVTalkProcessInputStreamQuiet ( UAVTalkConnection  connectionHandle,
uint8_t  rxbyte 
)

Process an byte from the telemetry stream.

Parameters
[in]connectionUAVTalkConnection to be used
[in]rxbyteReceived byte
Returns
UAVTalkRxState

Definition at line 180 of file uavtalk.c.

int32_t UAVTalkReceiveObject ( UAVTalkConnection  connectionHandle)

Complete receiving a UAVTalk packet. This will cause the packet to be unpacked, acked, etc.

Parameters
[in]connectionHandleUAVTalkConnection to be used
Returns
0 Success
-1 Failure

Definition at line 531 of file uavtalk.c.

int32_t UAVTalkRelayPacket ( UAVTalkConnection  inConnectionHandle,
UAVTalkConnection  outConnectionHandle 
)

Send a parsed packet received on one connection handle out on a different connection handle. The packet must be in a complete state, meaning it is completed parsing. The packet is re-assembled from the component parts into a complete message and sent. This can be used to relay packets from one UAVTalk connection to another.

Parameters
[in]connectionUAVTalkConnection to be used
[in]rxbyteReceived byte
Returns
0 Success
-1 Failure

Definition at line 451 of file uavtalk.c.

int32_t UAVTalkSendNack ( UAVTalkConnection  connectionHandle,
uint32_t  objId,
uint16_t  instId 
)

Send a NACK through the telemetry link.

Parameters
[in]connectionUAVTalkConnection to be used
[in]objIdObject ID to send a NACK for
[in]instIdinst ID to send a NACK for– 0 implies "all"
Returns
0 Success
-1 Failure

Definition at line 903 of file uavtalk.c.

int32_t UAVTalkSendObject ( UAVTalkConnection  connectionHandle,
UAVObjHandle  obj,
uint16_t  instId,
uint8_t  acked 
)

Send the specified object through the telemetry link.

Parameters
[in]connectionUAVTalkConnection to be used
[in]objObject to send
[in]instIdThe instance ID or UAVOBJ_ALL_INSTANCES for all instances.
[in]ackedTrue if an ack is requested
Returns
0 Success
-1 Failure

Definition at line 120 of file uavtalk.c.

int32_t UAVTalkSendObjectTimestamped ( UAVTalkConnection  connectionHandle,
UAVObjHandle  obj,
uint16_t  instId 
)

Send the specified object through the telemetry link with a timestamp.

Parameters
[in]connectionUAVTalkConnection to be used
[in]objObject to send
[in]instIdThe instance ID or UAVOBJ_ALL_INSTANCES for all instances.
[in]ackedSelects if an ack is required (1:ack required, 0: ack not required)
[in]timeoutMsTime to wait for the ack, when zero it will return immediately
Returns
0 Success
-1 Failure

Definition at line 142 of file uavtalk.c.

Variable Documentation

Definition at line 43 of file serial_4way.h.