/** * Execute a transaction while forwarding a stream. * \param[in] connection UAVLinkConnection to be used * \param[in] obj Object * \param[in] instId The instance ID of UAVOBJ_ALL_INSTANCES for all instances. * \param[in] type Transaction type * UAVLINK_TYPE_OBJ: send object, * UAVLINK_TYPE_OBJ_REQ: request object update * UAVLINK_TYPE_OBJ_ACK: send object with an ack * \return 0 Success * \return -1 Failure */ int32_t streamStream(UAVLinkConnection connectionHandle, uint8_t Id, uint8_t length, uint8_t *buf) { UAVLinkConnectionData *connection; CHECKCONHANDLE(connectionHandle,connection,return -1); // Send stream and wait for ack // Get transaction lock (will block if a transaction is pending) //xSemaphoreTakeRecursive(connection->transLock, portMAX_DELAY); // Send object //xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY); //connection->respId = Id; sendStreamPacket(connection, Id, length, buf); //xSemaphoreGiveRecursive(connection->lock); // Wait for response (or timeout) //respReceived = xSemaphoreTake(connection->respSema, timeoutMs/portTICK_RATE_MS); // Check if a response was received //if (respReceived == pdFALSE) //{ // Cancel transaction //xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY); //xSemaphoreTake(connection->respSema, 0); // non blocking call to make sure the value is reset to zero (binary sema) //connection->respId = 0; //xSemaphoreGiveRecursive(connection->lock); //xSemaphoreGiveRecursive(connection->transLock); //return -1; //} //else //{ // xSemaphoreGiveRecursive(connection->transLock); return 0; //} }
/** * Execute a transaction while forwarding a stream. * \param[in] connection UAVLinkConnection to be used * \param[in] objId of object * * \param[in] instId The instance ID of UAVOBJ_ALL_INSTANCES for all instances. * \param[in] type Transaction type * UAVLINK_TYPE_OBJ: send object, * UAVLINK_TYPE_OBJ_REQ: request object update * UAVLINK_TYPE_OBJ_ACK: send object with an ack * \return 0 Success * \return -1 Failure */ int32_t UAVLinkSendStream(UAVLinkConnection connectionHandle, uint8_t Id, uint8_t *buf, uint8_t length) { UAVLinkConnectionData *connection; CHECKCONHANDLE(connectionHandle,connection,return -1); // Send stream and wait for ack connection->resp = 0; connection->respId = Id; sendStreamPacket(connection, Id, length, buf); return 0; }
void ChannelServer::addStreamSubscription(StreamIdx idx) { auto &count = streamingSubscriberCounts_[idx]; ++count; // If this is the first subscriber, register the streaming callback, which // will also cause hardware polling to start. if (count == 1) { auto self = shared_from_this(); hw_->setStreamPacketCallback( idx, [this, self, idx](const StreamPacket &packet) { sendStreamPacket(idx, packet); }); } }