65 if (!connection)
return 0;
71 .outCb = outputStream,
74 .fileCb = fileCallback,
199 switch (iproc->
state)
223 iproc->
type = rxbyte;
301 }
else if (iproc->
length > 0) {
392 if (rxbyte != iproc->
cs) {
430 for (
int i = 0;
i < numbytes;
i++) {
466 if (!outConnection->
outCb) {
480 outConnection->
txBuffer[4] = (uint8_t)(inIproc->
objId & 0xFF);
481 outConnection->
txBuffer[5] = (uint8_t)((inIproc->
objId >> 8) & 0xFF);
482 outConnection->
txBuffer[6] = (uint8_t)((inIproc->
objId >> 16) & 0xFF);
483 outConnection->
txBuffer[7] = (uint8_t)((inIproc->
objId >> 24) & 0xFF);
484 int32_t headerLength = 8;
489 outConnection->
txBuffer[9] = (uint8_t)((inIproc->
instId >> 8) & 0xFF);
494 if (inIproc->
length > 0) {
499 outConnection->
txBuffer[2] = (uint8_t)((headerLength + inIproc->
length) & 0xFF);
500 outConnection->
txBuffer[3] = (uint8_t)(((headerLength + inIproc->
length) >> 8) & 0xFF);
594 connection->
txBuffer[4] = (uint8_t)(file_id & 0xFF);
595 connection->
txBuffer[5] = (uint8_t)((file_id >> 8) & 0xFF);
596 connection->
txBuffer[6] = (uint8_t)((file_id >> 16) & 0xFF);
597 connection->
txBuffer[7] = (uint8_t)((file_id >> 24) & 0xFF);
599 uint8_t data_offs = 8;
604 data_offs +=
sizeof(*resp);
606 uint32_t file_offset = req->
offset;
608 for (
int i = 0; ;
i++) {
609 resp->
offset = file_offset;
612 int32_t cb_numbytes = -1;
615 cb_numbytes = connection->
fileCb(connection->
cbCtx,
617 file_id, file_offset, 100);
620 uint8_t total_len = data_offs;
622 if (cb_numbytes > 0) {
623 total_len += cb_numbytes;
625 file_offset += cb_numbytes;
639 connection->
txBuffer[2] = (uint8_t)((total_len) & 0xFF);
640 connection->
txBuffer[3] = (uint8_t)(((total_len) >> 8) & 0xFF);
646 int32_t rc = (*connection->
outCb)(connection->
cbCtx,
647 connection->
txBuffer, total_len + 1);
649 if (rc == total_len) {
680 uint32_t objId = iproc->
objId;
681 uint16_t instId = iproc->
instId;
696 if (connection->
ackCb) {
697 connection->
ackCb(connection->
cbCtx, objId, instId);
702 if (connection->
reqCb) {
703 connection->
reqCb(connection->
cbCtx, objId, instId);
785 for (n = 0; n < numInst; ++n) {
820 if (!connection->
outCb)
return -1;
842 connection->
txBuffer[4] = (uint8_t)(objId & 0xFF);
843 connection->
txBuffer[5] = (uint8_t)((objId >> 8) & 0xFF);
844 connection->
txBuffer[6] = (uint8_t)((objId >> 16) & 0xFF);
845 connection->
txBuffer[7] = (uint8_t)((objId >> 24) & 0xFF);
851 connection->
txBuffer[8] = (uint8_t)(instId & 0xFF);
852 connection->
txBuffer[9] = (uint8_t)((instId >> 8) & 0xFF);
859 connection->
txBuffer[dataOffset] = (uint8_t)(time & 0xFF);
860 connection->
txBuffer[dataOffset + 1] = (uint8_t)((time >> 8) & 0xFF);
873 connection->
txBuffer[2] = (uint8_t)((dataOffset+length) & 0xFF);
874 connection->
txBuffer[3] = (uint8_t)(((dataOffset+length) >> 8) & 0xFF);
883 if (rc == tx_msg_len) {
909 return sendNack(connection, objId, instId);
917 if (!connection->
outCb)
return -1;
923 connection->
txBuffer[4] = (uint8_t)(objId & 0xFF);
924 connection->
txBuffer[5] = (uint8_t)((objId >> 8) & 0xFF);
925 connection->
txBuffer[6] = (uint8_t)((objId >> 16) & 0xFF);
926 connection->
txBuffer[7] = (uint8_t)((objId >> 24) & 0xFF);
933 connection->
txBuffer[8] = (uint8_t)(instId & 0xFF);
934 connection->
txBuffer[9] = (uint8_t)((instId >> 8) & 0xFF);
938 connection->
txBuffer[2] = (uint8_t)((dataOffset) & 0xFF);
939 connection->
txBuffer[3] = (uint8_t)(((dataOffset) >> 8) & 0xFF);
948 if (rc == tx_msg_len) {
#define UAVTALK_FILEDATA_EOF
uint32_t PIOS_Thread_Systime(void)
#define UAVTALK_MAX_HEADER_LENGTH
#define UAVTALK_MIN_HEADER_LENGTH
int32_t(* UAVTalkOutputCb)(void *ctx, uint8_t *data, int32_t length)
void(* UAVTalkAckCb)(void *ctx, uint32_t obj_id, uint16_t inst_id)
UAVObjHandle UAVObjGetByID(uint32_t id)
static int32_t sendNack(UAVTalkConnectionData *connection, uint32_t objId, uint16_t instId)
int32_t UAVTalkSendObjectTimestamped(UAVTalkConnection connectionHandle, UAVObjHandle obj, uint16_t instId)
static int32_t sendSingleObject(UAVTalkConnectionData *connection, UAVObjHandle obj, uint16_t instId, uint8_t type)
#define UAVTALK_MAX_PAYLOAD_LENGTH
int32_t UAVTalkSendNack(UAVTalkConnection connectionHandle, uint32_t objId, uint16_t instId)
#define UAVTALK_TYPE_NACK
static void ackCallback(void *ctx, uint32_t obj_id, uint16_t inst_id)
void UAVTalkGetStats(UAVTalkConnection connection, UAVTalkStats *stats)
static int32_t objectTransaction(UAVTalkConnectionData *connection, UAVObjHandle objectId, uint16_t instId, uint8_t type)
int32_t UAVObjUnpack(UAVObjHandle obj_handle, uint16_t instId, const uint8_t *dataIn)
#define CHECKCONHANDLE(handle, variable, failcommand)
uint32_t UAVObjGetNumBytes(UAVObjHandle obj)
#define UAVOBJ_ALL_INSTANCES
int32_t UAVObjPack(UAVObjHandle obj_handle, uint16_t instId, uint8_t *dataOut)
UAVTalkInputProcessor iproc
void * PIOS_malloc(size_t size)
void(* UAVTalkReqCb)(void *ctx, uint32_t obj_id, uint16_t inst_id)
void UAVTalkProcessInputStream(UAVTalkConnection connectionHandle, uint8_t *rxbytes, int numbytes)
void * PIOS_malloc_no_dma(size_t size)
static void reqCallback(void *ctx, uint32_t obj_id, uint16_t inst_id)
struct pios_recursive_mutex * PIOS_Recursive_Mutex_Create(void)
UAVTalkConnection UAVTalkInitialize(void *ctx, UAVTalkOutputCb outputStream, UAVTalkAckCb ackCallback, UAVTalkReqCb reqCallback, UAVTalkFileCb fileCallback)
uint8_t PIOS_CRC_updateByte(uint8_t crc, const uint8_t data)
uint32_t UAVObjGetID(UAVObjHandle obj)
bool UAVObjIsSingleInstance(UAVObjHandle obj)
int32_t(* UAVTalkFileCb)(void *ctx, uint8_t *buf, uint32_t file_id, uint32_t offset, uint32_t len)
#define UAVTALK_TYPE_MASK
#define UAVTALK_MAX_PACKET_LENGTH
Private include file of the UAVTalk library.
bool PIOS_Recursive_Mutex_Lock(struct pios_recursive_mutex *mtx, uint32_t timeout_ms)
struct pios_recursive_mutex * lock
uint32_t UAVTalkGetPacketInstId(UAVTalkConnection connection)
#define UAVTALK_TYPE_OBJ_REQ
Tracking statistics for a UAVTalk connection.
#define UAVTALK_CHECKSUM_LENGTH
#define UAVTALK_FILEDATA_LAST
Information for the physical link.
#define UAVTALK_TYPE_OBJ_ACK
static void handleFileReq(UAVTalkConnectionData *connection)
#define UAVTALK_TYPE_OBJ_TS
int32_t UAVTalkSendObject(UAVTalkConnection connection, UAVObjHandle obj, uint16_t instId, uint8_t acked)
UAVTalkRxState UAVTalkProcessInputStreamQuiet(UAVTalkConnection connection, uint8_t rxbyte)
Includes PiOS and core architecture components.
uint16_t UAVObjGetNumInstances(UAVObjHandle obj)
uint8_t PIOS_CRC_updateCRC(uint8_t crc, const uint8_t *data, int32_t length)
Update a CRC with a data buffer.
int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle)
#define UAVTALK_TYPE_FILEDATA
#define UAVTALK_TYPE_FILEREQ
#define UAVTALK_TIMESTAMPED
int32_t UAVTalkRelayPacket(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle)
#define PIOS_Assert(test)
Include file of the UAVTalk library.
static int32_t receiveObject(UAVTalkConnectionData *connection)
bool PIOS_Recursive_Mutex_Unlock(struct pios_recursive_mutex *mtx)
uint32_t UAVTalkGetPacketObjId(UAVTalkConnection connection)
static int32_t sendObject(UAVTalkConnectionData *connection, UAVObjHandle obj, uint16_t instId, uint8_t type)
#define PIOS_MUTEX_TIMEOUT_MAX