コード例 #1
0
ファイル: overosync.c プロジェクト: CheBuzz/TauLabs
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t OveroSyncStart(void)
{
	overosync = (struct overosync *) PIOS_malloc(sizeof(*overosync));
	if(overosync == NULL)
		return -1;

	overosync->buffer_lock = PIOS_Mutex_Create();
	if(overosync->buffer_lock == NULL)
		return -1;

	overosync->active_transaction_id = 0;
	overosync->loading_transaction_id = 0;
	overosync->write_pointer = 0;
	overosync->sent_bytes = 0;
	overosync->framesync_error = 0;

	// Process all registered objects and connect queue for updates
	UAVObjIterate(&registerObject);
	
	// Start telemetry tasks
	overoSyncTaskHandle = PIOS_Thread_Create(overoSyncTask, "OveroSync", STACK_SIZE_BYTES, NULL, TASK_PRIORITY);
	
	TaskMonitorAdd(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);
	
	return 0;
}
コード例 #2
0
ファイル: telemetry.c プロジェクト: Hoenerk/OpenPilot-1
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t TelemetryStart(void)
{
    // Process all registered objects and connect queue for updates
    UAVObjIterate(&registerObject);

    // Listen to objects of interest
    GCSTelemetryStatsConnectQueue(priorityQueue);

    // Start telemetry tasks
    xTaskCreate(telemetryTxTask, (signed char *)"TelTx", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY_TX, &telemetryTxTaskHandle);
    PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle);
    xTaskCreate(telemetryRxTask, (signed char *)"TelRx", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY_RX, &telemetryRxTaskHandle);
    PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle);

#ifdef PIOS_INCLUDE_RFM22B
    xTaskCreate(radioRxTask, (signed char *)"RadioRx", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY_RADRX, &radioRxTaskHandle);
    PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_RADIORX, radioRxTaskHandle);
#endif

#if defined(PIOS_TELEM_PRIORITY_QUEUE)
    xTaskCreate(telemetryTxPriTask, (signed char *)"TelPriTx", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY_TXPRI, &telemetryTxPriTaskHandle);
    PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTXPRI, telemetryTxPriTaskHandle);
#endif

    return 0;
}
コード例 #3
0
ファイル: telemetry.c プロジェクト: nzmichaelh/openpilot
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t TelemetryInitialize(void)
{
	UAVObjEvent ev;

	// Initialize vars
	timeOfLastObjectUpdate = 0;

	// Create object queues
	queue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent));
#if defined(PIOS_TELEM_PRIORITY_QUEUE)
	priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent));
#endif
	
	// Get telemetry settings object
	updateSettings();

	// Initialise UAVTalk
	UAVTalkInitialize(&transmitData);

	// Process all registered objects and connect queue for updates
	UAVObjIterate(&registerObject);

	// Create periodic event that will be used to update the telemetry stats
	txErrors = 0;
	txRetries = 0;
	memset(&ev, 0, sizeof(UAVObjEvent));
	EventPeriodicQueueCreate(&ev, priorityQueue, STATS_UPDATE_PERIOD_MS);

	// Listen to objects of interest
	GCSTelemetryStatsConnectQueue(priorityQueue);
	TelemetrySettingsConnectQueue(priorityQueue);

	return 0;
}
コード例 #4
0
ファイル: telemetry.c プロジェクト: mirasanti/vbrain
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t TelemetryStart(void)
{
	// Process all registered objects and connect queue for updates
	UAVObjIterate(&registerObject);
    
	// Listen to objects of interest
	GCSTelemetryStatsConnectQueue(priorityQueue);

	// Register to receive data from the radio packet handler.
	// This must be after the radio module is initialized.
#ifdef PIOS_PACKET_HANDLER
	if (PIOS_PACKET_HANDLER)
		PHRegisterDataHandler(PIOS_PACKET_HANDLER, receivePacketData);
#endif
    
	// Start telemetry tasks
	xTaskCreate(telemetryTxTask, (signed char *)"TelTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TX, &telemetryTxTaskHandle);
	xTaskCreate(telemetryRxTask, (signed char *)"TelRx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_RX, &telemetryRxTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle);

#if defined(PIOS_TELEM_PRIORITY_QUEUE)
	xTaskCreate(telemetryTxPriTask, (signed char *)"TelPriTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TXPRI, &telemetryTxPriTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTXPRI, telemetryTxPriTaskHandle);
#endif

	return 0;
}
コード例 #5
0
ファイル: overosync.c プロジェクト: B-robur/OpenPilot
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t OveroSyncStart(void)
{
    overosync = (struct overosync *)pios_malloc(sizeof(*overosync));
    if (overosync == NULL) {
        return -1;
    }

    overosync->transaction_lock = xSemaphoreCreateMutex();
    if (overosync->transaction_lock == NULL) {
        return -1;
    }

    overosync->buffer_lock = xSemaphoreCreateMutex();
    if (overosync->buffer_lock == NULL) {
        return -1;
    }

    overosync->active_transaction_id  = 0;
    overosync->loading_transaction_id = 0;
    overosync->write_pointer   = 0;
    overosync->sent_bytes      = 0;
    overosync->framesync_error = 0;

    // Process all registered objects and connect queue for updates
    UAVObjIterate(&registerObject);

    // Start telemetry tasks
    xTaskCreate(overoSyncTask, (signed char *)"OveroSync", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &overoSyncTaskHandle);

    PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);

    return 0;
}
コード例 #6
0
ファイル: telemetry.c プロジェクト: jgoppert/openpilot
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t TelemetryInitialize(void)
{
	UAVObjEvent ev;

	// Initialize vars
	timeOfLastObjectUpdate = 0;

	// Create object queues
	queue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent));
#if defined(PIOS_TELEM_PRIORITY_QUEUE)
	priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent));
#endif
	
	// Get telemetry settings object
	updateSettings();

	// Initialise UAVTalk
	UAVTalkInitialize(&transmitData);

	// Process all registered objects and connect queue for updates
	UAVObjIterate(&registerObject);

	// Create periodic event that will be used to update the telemetry stats
	txErrors = 0;
	txRetries = 0;
	memset(&ev, 0, sizeof(UAVObjEvent));
	EventPeriodicQueueCreate(&ev, priorityQueue, STATS_UPDATE_PERIOD_MS);

	// Listen to objects of interest
	GCSTelemetryStatsConnectQueue(priorityQueue);
	TelemetrySettingsConnectQueue(priorityQueue);

	// Start telemetry tasks
	xTaskCreate(telemetryTxTask, (signed char *)"TelTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TX, &telemetryTxTaskHandle);
	xTaskCreate(telemetryRxTask, (signed char *)"TelRx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_RX, &telemetryRxTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle);

#if defined(PIOS_TELEM_PRIORITY_QUEUE)
	xTaskCreate(telemetryTxPriTask, (signed char *)"TelPriTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TXPRI, &telemetryTxPriTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTXPRI, telemetryTxPriTaskHandle);
#endif
	
	return 0;
}
コード例 #7
0
ファイル: telemetry.c プロジェクト: SergDoc/TauLabs
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t TelemetryStart(void)
{
	// Process all registered objects and connect queue for updates
	UAVObjIterate(&registerObject);
    
	// Listen to objects of interest
	GCSTelemetryStatsConnectQueue(priorityQueue);
    
	// Start telemetry tasks
	telemetryTxTaskHandle = PIOS_Thread_Create(telemetryTxTask, "TelTx", STACK_SIZE_BYTES, NULL, TASK_PRIORITY_TX);
	telemetryRxTaskHandle = PIOS_Thread_Create(telemetryRxTask, "TelRx", STACK_SIZE_BYTES, NULL, TASK_PRIORITY_RX);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle);

#if defined(PIOS_TELEM_PRIORITY_QUEUE)
	telemetryTxPriTaskHandle = PIOS_Thread_Create(telemetryTxPriTask, "TelPriTx", STACK_SIZE_BYTES, NULL, TASK_PRIORITY_TXPRI);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTXPRI, telemetryTxPriTaskHandle);
#endif

	return 0;
}
コード例 #8
0
/**
 * Initialise the telemetry module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t MAVLinkStart(void)
{
	// Process all registered objects and connect queue for updates
	UAVObjIterate(&registerObject);

	// Listen to objects of interest
	GCSTelemetryStatsConnectQueue(priorityQueue);
	TelemetrySettingsConnectQueue(priorityQueue);

	// Start telemetry tasks
	xTaskCreate(telemetryTxTask, (signed char *)"MAVLinkTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TX, &telemetryTxTaskHandle);
	xTaskCreate(telemetryRxTask, (signed char *)"MAVLinkRx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_RX, &telemetryRxTaskHandle);
	xTaskCreate(mavlinkStateMachineTask, (signed char*) "MAVLinkSM", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_STATE_MACHINE, &mavlinkStateMachineTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle);

#if defined(PIOS_TELEM_PRIORITY_QUEUE)
	xTaskCreate(telemetryTxPriTask, (signed char *)"MAVLPriTx", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY_TXPRI, &telemetryTxPriTaskHandle);
	TaskMonitorAdd(TASKINFO_RUNNING_TELEMETRYTXPRI, telemetryTxPriTaskHandle);
#endif

	return 0;
}
コード例 #9
0
ファイル: overosync.c プロジェクト: CheBuzz/TauLabs
/**
 * Start the overo sync module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t OveroSyncStart(void)
{
	//Check if module is enabled or not
	if (module_enabled == false) {
		return -1;
	}
	
	overosync = (struct overosync *) PIOS_malloc(sizeof(*overosync));
	if(overosync == NULL)
		return -1;

	overosync->sent_bytes = 0;

	// Process all registered objects and connect queue for updates
	UAVObjIterate(&register_object);
	
	// Start telemetry tasks
	overoSyncTaskHandle = PIOS_Thread_Create(overoSyncTask, "OveroSync", STACK_SIZE_BYTES, NULL, TASK_PRIORITY);
	
	TaskMonitorAdd(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);
	
	return 0;
}
コード例 #10
0
ファイル: overosync.c プロジェクト: B-robur/OpenPilot
/**
 * Initialise the overosync module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t OveroSyncStart(void)
{
    // Check if module is enabled or not
    if (overoEnabled == false) {
        return -1;
    }

    overosync = (struct overosync *)pios_malloc(sizeof(*overosync));
    if (overosync == NULL) {
        return -1;
    }

    overosync->sent_bytes = 0;

    // Process all registered objects and connect queue for updates
    UAVObjIterate(&registerObject);

    // Start overosync tasks
    xTaskCreate(overoSyncTask, (signed char *)"OveroSync", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &overoSyncTaskHandle);

    PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_OVEROSYNC, overoSyncTaskHandle);

    return 0;
}
コード例 #11
0
ファイル: logging.c プロジェクト: Trex4Git/dRonin
static void loggingTask(void *parameters)
{
	UAVObjEvent ev;

	bool armed = false;
	uint32_t now = PIOS_Thread_Systime();

#if defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC)
	bool write_open = false;
	bool read_open = false;
	int32_t read_sector = 0;
	uint8_t read_data[LOGGINGSTATS_FILESECTOR_NUMELEM];
#endif

	// Get settings automatically for now on
	LoggingSettingsConnectCopy(&settings);


	LoggingStatsGet(&loggingData);
	loggingData.BytesLogged = 0;
	
#if defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC)
	if (destination_spi_flash)
	{
		loggingData.MinFileId = PIOS_STREAMFS_MinFileId(streamfs_id);
		loggingData.MaxFileId = PIOS_STREAMFS_MaxFileId(streamfs_id);
	}
#endif

	if (settings.LogBehavior == LOGGINGSETTINGS_LOGBEHAVIOR_LOGONSTART) {
		loggingData.Operation = LOGGINGSTATS_OPERATION_INITIALIZING;
	} else {
		loggingData.Operation = LOGGINGSTATS_OPERATION_IDLE;
	}

	LoggingStatsSet(&loggingData);

	// Loop forever
	while (1) 
	{
		LoggingStatsGet(&loggingData);

		// Check for change in armed state if logging on armed

		if (settings.LogBehavior == LOGGINGSETTINGS_LOGBEHAVIOR_LOGONARM) {
			FlightStatusData flightStatus;
			FlightStatusGet(&flightStatus);

			if (flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMED && !armed) {
				// Start logging because just armed
				loggingData.Operation = LOGGINGSTATS_OPERATION_INITIALIZING;
				armed = true;
				LoggingStatsSet(&loggingData);
			} else if (flightStatus.Armed == FLIGHTSTATUS_ARMED_DISARMED && armed) {
				loggingData.Operation = LOGGINGSTATS_OPERATION_IDLE;
				armed = false;
				LoggingStatsSet(&loggingData);
			}
		}

		switch (loggingData.Operation) {
		case LOGGINGSTATS_OPERATION_FORMAT:
			// Format the file system
#if defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC)
			if (destination_spi_flash){
				if (read_open || write_open) {
					PIOS_STREAMFS_Close(streamfs_id);
					read_open = false;
					write_open = false;
				}

				PIOS_STREAMFS_Format(streamfs_id);
				loggingData.MinFileId = PIOS_STREAMFS_MinFileId(streamfs_id);
				loggingData.MaxFileId = PIOS_STREAMFS_MaxFileId(streamfs_id);
			}
#endif /* defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC) */
			loggingData.Operation = LOGGINGSTATS_OPERATION_IDLE;
			LoggingStatsSet(&loggingData);
			break;
		case LOGGINGSTATS_OPERATION_INITIALIZING:
			// Unregister all objects
			UAVObjIterate(&unregister_object);
			// Register objects to be logged
			switch (settings.Profile) {
				case LOGGINGSETTINGS_PROFILE_DEFAULT:
					register_default_profile();
					break;
				case LOGGINGSETTINGS_PROFILE_CUSTOM:
					UAVObjIterate(&register_object);
					break;
			}
#if defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC)
			if (destination_spi_flash){
				// Close the file if it is open for reading
				if (read_open) {
					PIOS_STREAMFS_Close(streamfs_id);
					read_open = false;
				}
				// Open the file if it is not open for writing
				if (!write_open) {
					if (PIOS_STREAMFS_OpenWrite(streamfs_id) != 0) {
						loggingData.Operation = LOGGINGSTATS_OPERATION_ERROR;
						continue;
					} else {
						write_open = true;
					}
					loggingData.MinFileId = PIOS_STREAMFS_MinFileId(streamfs_id);
					loggingData.MaxFileId = PIOS_STREAMFS_MaxFileId(streamfs_id);
					LoggingStatsSet(&loggingData);
				}
			}
			else {
				read_open = false;
				write_open = true;
			}
#endif /* defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC) */

			// Write information at start of the log file
			writeHeader();

			// Log settings
			if (settings.LogSettingsOnStart == LOGGINGSETTINGS_LOGSETTINGSONSTART_TRUE){
				UAVObjIterate(&logSettings);
			}

			// Empty the queue
			while(PIOS_Queue_Receive(logging_queue, &ev, 0))

			LoggingStatsBytesLoggedSet(&written_bytes);
			loggingData.Operation = LOGGINGSTATS_OPERATION_LOGGING;
			LoggingStatsSet(&loggingData);
			break;
		case LOGGINGSTATS_OPERATION_LOGGING:
			{
				// Sleep between writing
				PIOS_Thread_Sleep_Until(&now, LOGGING_PERIOD_MS);

				// Log the objects registred to the shared queue
				for (int i=0; i<LOGGING_QUEUE_SIZE; i++) {
					if (PIOS_Queue_Receive(logging_queue, &ev, 0) == true) {
						UAVTalkSendObjectTimestamped(uavTalkCon, ev.obj, ev.instId, false, 0);
					}
					else {
						break;
					}
				}

				LoggingStatsBytesLoggedSet(&written_bytes);

				now = PIOS_Thread_Systime();
			}
			break;
		case LOGGINGSTATS_OPERATION_DOWNLOAD:
#if defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC)
			if (destination_spi_flash) {
				if (!read_open) {
					// Start reading
					if (PIOS_STREAMFS_OpenRead(streamfs_id, loggingData.FileRequest) != 0) {
						loggingData.Operation = LOGGINGSTATS_OPERATION_ERROR;
					} else {
						read_open = true;
						read_sector = -1;
					}
				}
				if (read_open && read_sector == loggingData.FileSectorNum) {
					// Request received for same sector. Reupdate.
					memcpy(loggingData.FileSector, read_data, LOGGINGSTATS_FILESECTOR_NUMELEM);
					loggingData.Operation = LOGGINGSTATS_OPERATION_IDLE;
				} else if (read_open && (read_sector + 1) == loggingData.FileSectorNum) {
					int32_t bytes_read = PIOS_COM_ReceiveBuffer(logging_com_id, read_data, LOGGINGSTATS_FILESECTOR_NUMELEM, 1);
					if (bytes_read < 0 || bytes_read > LOGGINGSTATS_FILESECTOR_NUMELEM) {
						// close on error
						loggingData.Operation = LOGGINGSTATS_OPERATION_ERROR;
						PIOS_STREAMFS_Close(streamfs_id);
						read_open = false;
					} else if (bytes_read < LOGGINGSTATS_FILESECTOR_NUMELEM) {
						// Check it has really run out of bytes by reading again
						int32_t bytes_read2 = PIOS_COM_ReceiveBuffer(logging_com_id, &read_data[bytes_read], LOGGINGSTATS_FILESECTOR_NUMELEM - bytes_read, 1);
						memcpy(loggingData.FileSector, read_data, LOGGINGSTATS_FILESECTOR_NUMELEM);
						if ((bytes_read + bytes_read2) < LOGGINGSTATS_FILESECTOR_NUMELEM) {
							// indicate end of file
							loggingData.Operation = LOGGINGSTATS_OPERATION_COMPLETE;
							PIOS_STREAMFS_Close(streamfs_id);
							read_open = false;
						} else {
							// Indicate sent
							loggingData.Operation = LOGGINGSTATS_OPERATION_IDLE;
						}
					} else {
						// Indicate sent
						loggingData.Operation = LOGGINGSTATS_OPERATION_IDLE;
						memcpy(loggingData.FileSector, read_data, LOGGINGSTATS_FILESECTOR_NUMELEM);
					}
					read_sector = loggingData.FileSectorNum;
				}
				LoggingStatsSet(&loggingData);
			}
#endif /* defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC) */

			// fall-through to default case
		default:
			//  Makes sure that we are not hogging the processor
			PIOS_Thread_Sleep(10);
#if defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC)
			if (destination_spi_flash) {
				// Close the file if necessary
				if (write_open) {
					PIOS_STREAMFS_Close(streamfs_id);
					loggingData.MinFileId = PIOS_STREAMFS_MinFileId(streamfs_id);
					loggingData.MaxFileId = PIOS_STREAMFS_MaxFileId(streamfs_id);
					LoggingStatsSet(&loggingData);
					write_open = false;
				}
			}
#endif /* defined(PIOS_INCLUDE_FLASH) && defined(PIOS_INCLUDE_FLASH_JEDEC) */
		}
	}
}
コード例 #12
0
ファイル: overosync.c プロジェクト: CheBuzz/TauLabs
/**
 * Telemetry transmit task, regular priority
 *
 * Logic: We need to double buffer the DMA transfers.  Pack the buffer until either
 * 1) it is full (and then we should record the number of missed events then)
 * 2) the current transaction is done (we should immediately schedule since we are slave)
 * when done packing the buffer we should call PIOS_SPI_TransferBlock, change the active buffer
 * and then take the semaphrore
 */
static void overoSyncTask(void *parameters)
{
	UAVObjEvent ev;

	// Kick off SPI transfers (once one is completed another will automatically transmit)
	overosync->sent_objects = 0;
	overosync->failed_objects = 0;
	overosync->received_objects = 0;
	
	uint32_t lastUpdateTime = PIOS_Thread_Systime();
	uint32_t updateTime;

	bool initialized = false;
	uint8_t last_connected = OVEROSYNCSTATS_CONNECTED_FALSE;

	// Loop forever
	while (1) {
		// Wait for queue message
		if (PIOS_Queue_Receive(queue, &ev, PIOS_QUEUE_TIMEOUT_MAX) == true) {

			// For the first seconds do not send updates to allow the
			// overo to boot.  Then enable it and act normally.
			if (!initialized && PIOS_Thread_Systime() < 5000) {
				continue;
			} else if (!initialized) {
				initialized = true;
				PIOS_OVERO_Enable(pios_overo_id);
			}

			// Process event.  This calls transmitData
			UAVTalkSendObjectTimestamped(uavTalkCon, ev.obj, ev.instId, false, 0);
			
			updateTime = PIOS_Thread_Systime();
			if(((uint32_t) (updateTime - lastUpdateTime)) > 1000) {
				// Update stats.  This will trigger a local send event too
				OveroSyncStatsData syncStats;
				syncStats.Send = overosync->sent_bytes;
				syncStats.Connected = syncStats.Send > 500 ? OVEROSYNCSTATS_CONNECTED_TRUE : OVEROSYNCSTATS_CONNECTED_FALSE;
				syncStats.DroppedUpdates = overosync->failed_objects;
				syncStats.Packets = PIOS_OVERO_GetPacketCount(pios_overo_id);
				OveroSyncStatsSet(&syncStats);
				overosync->failed_objects = 0;
				overosync->sent_bytes = 0;
				lastUpdateTime = updateTime;

				// When first connected, send all the settings.  Right now this
				// will fail since all the settings will overfill the buffer and
				if (last_connected == OVEROSYNCSTATS_CONNECTED_FALSE &&
					syncStats.Connected == OVEROSYNCSTATS_CONNECTED_TRUE) {
					UAVObjIterate(&send_settings);
				}

				// Because the previous code only happens on connection and the
				// remote logging program doesn't send the settings to the log
				// when arming starts we send all settings every thirty seconds
				static uint32_t second_count = 0;
				if (second_count ++ > 30) {
					UAVObjIterate(&send_settings);
					second_count = 0;
				}
				last_connected = syncStats.Connected;
			}

			// TODO: Check the receive buffer
		}
	}
}