Example #1
0
/**
 * Telemetry transmit task. Processes queue events and periodic updates.
 */
static void telemetryRxTask(void *parameters)
{
	uint32_t inputPort;

	// Task loop
	while (1) {
#if defined(PIOS_INCLUDE_USB_HID)
		// Determine input port (USB takes priority over telemetry port)
		if (PIOS_USB_HID_CheckAvailable(0)) {
			inputPort = PIOS_COM_TELEM_USB;
		} else
#endif /* PIOS_INCLUDE_USB_HID */
		{
			inputPort = telemetryPort;
		}

		if (inputPort) {
			// Block until data are available
			uint8_t serial_data[1];
			uint16_t bytes_to_process;

			bytes_to_process = PIOS_COM_ReceiveBuffer(inputPort, serial_data, sizeof(serial_data), 500);
			if (bytes_to_process > 0) {
				for (uint8_t i = 0; i < bytes_to_process; i++) {
					UAVTalkProcessInputStream(serial_data[i]);
				}
			}
		} else {
			vTaskDelay(5);
		}
	}
}
Example #2
0
static void uavoRelayTask(void *parameters)
{
	UAVObjEvent ev;

	// Loop forever
	while (1) {

		PIOS_Thread_Sleep(50);

		// Wait for queue message
		if (PIOS_Queue_Receive(queue, &ev, 2) == true) {
			// Process event.  This calls transmitData
			UAVTalkSendObject(uavTalkCon, ev.obj, ev.instId, false, 0);
		}

		// Process incoming data in sufficient chunks that we keep up
		uint8_t serial_data[8];
		uint16_t bytes_to_process;

		bytes_to_process = PIOS_COM_ReceiveBuffer(uavorelay_com_id, serial_data, sizeof(serial_data), 0);
		do {
			bytes_to_process = PIOS_COM_ReceiveBuffer(uavorelay_com_id, serial_data, sizeof(serial_data), 0);
			for (uint8_t i = 0; i < bytes_to_process; i++)
				UAVTalkProcessInputStream(uavTalkCon,serial_data[i]);
		} while (bytes_to_process > 0);

	}
}
Example #3
0
/**
 * Telemetry transmit task. Processes queue events and periodic updates.
 */
static void telemetryRxTask(void *parameters)
{
	uint32_t inputPort;
	int32_t len;

	// Task loop
	while (1) {
#if defined(PIOS_INCLUDE_USB_HID)
		// Determine input port (USB takes priority over telemetry port)
		if (PIOS_USB_HID_CheckAvailable(0)) {
			inputPort = PIOS_COM_TELEM_USB;
		} else
#endif /* PIOS_INCLUDE_USB_HID */
		{
			inputPort = telemetryPort;
		}

		// Block until data are available
		// TODO: Currently we periodically check the buffer for data, update once the PIOS_COM is made blocking
		len = PIOS_COM_ReceiveBufferUsed(inputPort);
		for (int32_t n = 0; n < len; ++n) {
			UAVTalkProcessInputStream(PIOS_COM_ReceiveBuffer(inputPort));
		}
		vTaskDelay(5);	// <- remove when blocking calls are implemented

	}
}