Merge branch 'rel-nano-15.05' into corvuscorax/fixedwingautotakeofftest
[librepilot.git] / flight / uavtalk / inc / uavtalk.h
blobe485882efb6b088df4e5863f1490fca2e2e5345f
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilotSystem OpenPilot System
4 * @{
5 * @addtogroup OpenPilotLibraries OpenPilot System Libraries
6 * @{
7 * @file uavtalk.h
8 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
9 * @brief Include file of the UAVTalk library
10 * @see The GNU Public License (GPL) Version 3
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef UAVTALK_H
30 #define UAVTALK_H
32 // Public types
33 typedef int32_t (*UAVTalkOutputStream)(uint8_t *data, int32_t length);
35 typedef struct {
36 uint32_t txBytes;
37 uint32_t txObjectBytes;
38 uint32_t txObjects;
39 uint32_t txErrors;
41 uint32_t rxBytes;
42 uint32_t rxObjectBytes;
43 uint32_t rxObjects;
44 uint32_t rxErrors;
45 uint32_t rxSyncErrors;
46 uint32_t rxCrcErrors;
47 } UAVTalkStats;
49 typedef void *UAVTalkConnection;
51 typedef enum { UAVTALK_STATE_ERROR = 0, UAVTALK_STATE_SYNC, UAVTALK_STATE_TYPE, UAVTALK_STATE_SIZE, UAVTALK_STATE_OBJID, UAVTALK_STATE_INSTID, UAVTALK_STATE_TIMESTAMP, UAVTALK_STATE_DATA, UAVTALK_STATE_CS, UAVTALK_STATE_COMPLETE } UAVTalkRxState;
53 // Public functions
54 UAVTalkConnection UAVTalkInitialize(UAVTalkOutputStream outputStream);
55 int32_t UAVTalkSetOutputStream(UAVTalkConnection connection, UAVTalkOutputStream outputStream);
56 UAVTalkOutputStream UAVTalkGetOutputStream(UAVTalkConnection connection);
57 int32_t UAVTalkSendObject(UAVTalkConnection connection, UAVObjHandle obj, uint16_t instId, uint8_t acked, int32_t timeoutMs);
58 int32_t UAVTalkSendObjectTimestamped(UAVTalkConnection connectionHandle, UAVObjHandle obj, uint16_t instId, uint8_t acked, int32_t timeoutMs);
59 int32_t UAVTalkSendObjectRequest(UAVTalkConnection connection, UAVObjHandle obj, uint16_t instId, int32_t timeoutMs);
60 UAVTalkRxState UAVTalkProcessInputStream(UAVTalkConnection connectionHandle, uint8_t *rxbuffer, uint8_t length);
61 UAVTalkRxState UAVTalkProcessInputStreamQuiet(UAVTalkConnection connectionHandle, uint8_t *rxbuffer, uint8_t length, uint8_t *position);
62 int32_t UAVTalkRelayPacket(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle);
63 int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle);
64 void UAVTalkGetStats(UAVTalkConnection connection, UAVTalkStats *stats, bool reset);
65 void UAVTalkAddStats(UAVTalkConnection connection, UAVTalkStats *stats, bool reset);
66 void UAVTalkResetStats(UAVTalkConnection connection);
67 void UAVTalkGetLastTimestamp(UAVTalkConnection connection, uint16_t *timestamp);
68 uint32_t UAVTalkGetPacketObjId(UAVTalkConnection connection);
70 #endif // UAVTALK_H
71 /**
72 * @}
73 * @}