diff --git a/HISTORY.txt b/HISTORY.txt index 4d22602df..d0492dd1f 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,5 +1,13 @@ Short summary of changes. For a complete list see the git log. +2012-07-10 +On Windows the installation mode was changed from per-user to per-machine +(for all users) installation. It is recommended to completely uninstall +previous version before installing new one to remove per-user installed +files. Per-machine installation requires elevated (administrator) previleges +during install. But since the same rights are now required to install +optional CDC driver (virtual communication port), it was deemed acceptable. + 2012-06-04 AeroSimRC support merged into next diff --git a/Makefile b/Makefile index f55524cc4..6564abc44 100644 --- a/Makefile +++ b/Makefile @@ -488,7 +488,7 @@ uavobjgenerator: $(MAKE) --no-print-directory -w ; \ ) -UAVOBJ_TARGETS := gcs flight python matlab java +UAVOBJ_TARGETS := gcs flight python matlab java wireshark .PHONY:uavobjects uavobjects: $(addprefix uavobjects_, $(UAVOBJ_TARGETS)) diff --git a/flight/Modules/FlightPlan/lib/uavobject.py b/flight/Modules/FlightPlan/lib/uavobject.py index aafe76a43..bf2d622e8 100644 --- a/flight/Modules/FlightPlan/lib/uavobject.py +++ b/flight/Modules/FlightPlan/lib/uavobject.py @@ -109,7 +109,10 @@ class UAVObject: def addField(self, field): append(self.fields, field) - + ''' + # + # Support for getName was removed from embedded UAVO database to save RAM + Flash + # def getName(self): """__NATIVE__ UAVObjHandle objHandle; @@ -143,6 +146,7 @@ class UAVObject: return PM_RET_OK; """ pass + ''' def read(self): """__NATIVE__ diff --git a/flight/Modules/ManualControl/manualcontrol.c b/flight/Modules/ManualControl/manualcontrol.c index cc188e602..cad5d065d 100644 --- a/flight/Modules/ManualControl/manualcontrol.c +++ b/flight/Modules/ManualControl/manualcontrol.c @@ -58,7 +58,6 @@ #define TASK_PRIORITY (tskIDLE_PRIORITY+4) #define UPDATE_PERIOD_MS 20 #define THROTTLE_FAILSAFE -0.1f -#define FLIGHT_MODE_LIMIT 1.0f/3.0f #define ARMED_TIME_MS 1000 #define ARMED_THRESHOLD 0.50f //safe band to allow a bit of calibration error or trim offset (in microseconds) @@ -236,19 +235,23 @@ static void manualControlTask(void *parameters) settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_PITCH] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE || settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_YAW] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE || settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE || - settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE || // Check all channel mappings are valid cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL] == (uint16_t) PIOS_RCVR_INVALID || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_PITCH] == (uint16_t) PIOS_RCVR_INVALID || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_YAW] == (uint16_t) PIOS_RCVR_INVALID || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] == (uint16_t) PIOS_RCVR_INVALID || - cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t) PIOS_RCVR_INVALID || - // Check the driver is exists + // Check the driver exists cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL] == (uint16_t) PIOS_RCVR_NODRIVER || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_PITCH] == (uint16_t) PIOS_RCVR_NODRIVER || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_YAW] == (uint16_t) PIOS_RCVR_NODRIVER || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] == (uint16_t) PIOS_RCVR_NODRIVER || - cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t) PIOS_RCVR_NODRIVER) { + // Check the FlightModeNumber is valid + settings.FlightModeNumber < 1 || settings.FlightModeNumber > MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_NUMELEM || + // Similar checks for FlightMode channel but only if more than one flight mode has been set. Otherwise don't care + ((settings.FlightModeNumber > 1) && ( + settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE || + cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t) PIOS_RCVR_INVALID || + cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t) PIOS_RCVR_NODRIVER))) { AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL); cmd.Connected = MANUALCONTROLCOMMAND_CONNECTED_FALSE; @@ -357,7 +360,6 @@ static void manualControlTask(void *parameters) AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); } - processFlightMode(&settings, flightMode); } @@ -847,30 +849,27 @@ static void processArm(ManualControlCommandData * cmd, ManualControlSettingsData } /** - * @brief Determine which of three positions the flight mode switch is in and set flight mode accordingly + * @brief Determine which of N positions the flight mode switch is in and set flight mode accordingly * @param[out] cmd Pointer to the command structure to set the flight mode in * @param[in] settings The settings which indicate which position is which mode * @param[in] flightMode the value of the switch position */ -static void processFlightMode(ManualControlSettingsData * settings, float flightMode) +static void processFlightMode(ManualControlSettingsData *settings, float flightMode) { FlightStatusData flightStatus; FlightStatusGet(&flightStatus); - uint8_t newMode; - // Note here the code is ass - if (flightMode < -FLIGHT_MODE_LIMIT) - newMode = settings->FlightModePosition[0]; - else if (flightMode > FLIGHT_MODE_LIMIT) - newMode = settings->FlightModePosition[2]; - else - newMode = settings->FlightModePosition[1]; + // Convert flightMode value into the switch position in the range [0..N-1] + uint8_t pos = ((int16_t)(flightMode * 256.0f) + 256) * settings->FlightModeNumber >> 9; + if (pos >= settings->FlightModeNumber) + pos = settings->FlightModeNumber - 1; - if(flightStatus.FlightMode != newMode) { + uint8_t newMode = settings->FlightModePosition[pos]; + + if (flightStatus.FlightMode != newMode) { flightStatus.FlightMode = newMode; FlightStatusSet(&flightStatus); } - } /** diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index e1f7b767a..d48c6de06 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -297,9 +297,9 @@ static int32_t RadioComBridgeInitialize(void) PipXSettingsPairIDGet(&(data->pairStats[0].pairID)); // Configure our UAVObjects for updates. - UAVObjConnectQueue(UAVObjGetByName("PipXStatus"), data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); - UAVObjConnectQueue(UAVObjGetByName("GCSReceiver"), data->uavtalkEventQueue ? data->uavtalkEventQueue : data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); - UAVObjConnectQueue(UAVObjGetByName("ObjectPersistence"), data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL); + UAVObjConnectQueue(UAVObjGetByID(PIPXSTATUS_OBJID), data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); + UAVObjConnectQueue(UAVObjGetByID(GCSRECEIVER_OBJID), data->uavtalkEventQueue ? data->uavtalkEventQueue : data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ); + UAVObjConnectQueue(UAVObjGetByID(OBJECTPERSISTENCE_OBJID), data->gcsEventQueue, EV_UPDATED | EV_UPDATED_MANUAL); // Initialize the UAVTalk comm parameters. data->gcs_uavtalk_params.UAVTalkCon = data->GCSUAVTalkCon; diff --git a/flight/Modules/Stabilization/stabilization.c b/flight/Modules/Stabilization/stabilization.c index b08a90076..43bb9b0d5 100644 --- a/flight/Modules/Stabilization/stabilization.c +++ b/flight/Modules/Stabilization/stabilization.c @@ -444,7 +444,6 @@ static float bound(float val) static void SettingsUpdatedCb(UAVObjEvent * ev) { - memset(pids,0,sizeof (pid_type) * PID_MAX); StabilizationSettingsGet(&settings); // Set the roll rate PID constants diff --git a/flight/PiOS.posix/inc/pios_struct_helper.h b/flight/PiOS.posix/inc/pios_struct_helper.h new file mode 100644 index 000000000..6196d9b26 --- /dev/null +++ b/flight/PiOS.posix/inc/pios_struct_helper.h @@ -0,0 +1,12 @@ +/* Taken from include/linux/kernel.h from the Linux kernel tree */ + +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) diff --git a/flight/PiOS.posix/posix/Libraries/FreeRTOS/Source/portable/GCC/Posix/port.c b/flight/PiOS.posix/posix/Libraries/FreeRTOS/Source/portable/GCC/Posix/port.c index 1deb36cc7..18215c10f 100644 --- a/flight/PiOS.posix/posix/Libraries/FreeRTOS/Source/portable/GCC/Posix/port.c +++ b/flight/PiOS.posix/posix/Libraries/FreeRTOS/Source/portable/GCC/Posix/port.c @@ -274,7 +274,6 @@ void vPortStartFirstTask( void ) */ portBASE_TYPE xPortStartScheduler( void ) { - portBASE_TYPE xResult; sigset_t xSignalToBlock; /** @@ -337,9 +336,9 @@ portBASE_TYPE xPortStartScheduler( void ) PORT_PRINT( "Cleaning Up, Exiting.\n" ); /* Cleanup the mutexes */ - xResult = pthread_mutex_destroy( &xRunningThreadMutex ); - xResult = pthread_mutex_destroy( &xYieldingThreadMutex ); - xResult = pthread_mutex_destroy( &xGuardMutex ); + pthread_mutex_destroy( &xRunningThreadMutex ); + pthread_mutex_destroy( &xYieldingThreadMutex ); + pthread_mutex_destroy( &xGuardMutex ); vPortFree( (void *)pxThreads ); /* Should not get here! */ @@ -353,13 +352,12 @@ portBASE_TYPE xPortStartScheduler( void ) void vPortEndScheduler( void ) { portBASE_TYPE xNumberOfThreads; -portBASE_TYPE xResult; for ( xNumberOfThreads = 0; xNumberOfThreads < MAX_NUMBER_OF_TASKS; xNumberOfThreads++ ) { if ( ( pthread_t )NULL != pxThreads[ xNumberOfThreads ].hThread ) { /* Kill all of the threads, they are in the detached state. */ - xResult = pthread_cancel( pxThreads[ xNumberOfThreads ].hThread ); + pthread_cancel( pxThreads[ xNumberOfThreads ].hThread ); } } @@ -683,7 +681,6 @@ void vPortForciblyEndThread( void *pxTaskToDelete ) xTaskHandle hTaskToDelete = ( xTaskHandle )pxTaskToDelete; xThreadState* xTaskToDelete; xThreadState* xTaskToResume; -portBASE_TYPE xResult; PORT_ENTER(); @@ -706,7 +703,7 @@ portBASE_TYPE xResult; /* Send a signal to wake the task so that it definitely cancels. */ pthread_testcancel(); - xResult = pthread_cancel( xTaskToDelete->hThread ); + pthread_cancel( xTaskToDelete->hThread ); } else diff --git a/flight/PiOS/inc/pios_struct_helper.h b/flight/PiOS/inc/pios_struct_helper.h new file mode 100644 index 000000000..6196d9b26 --- /dev/null +++ b/flight/PiOS/inc/pios_struct_helper.h @@ -0,0 +1,12 @@ +/* Taken from include/linux/kernel.h from the Linux kernel tree */ + +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) diff --git a/flight/Project/gdb/simposix b/flight/Project/gdb/simposix new file mode 100644 index 000000000..877eb2920 --- /dev/null +++ b/flight/Project/gdb/simposix @@ -0,0 +1 @@ +handle SIGUSR1 noprint nostop \ No newline at end of file diff --git a/flight/SimPosix/Makefile b/flight/SimPosix/Makefile index 9c3a8cdcf..84a9bb060 100644 --- a/flight/SimPosix/Makefile +++ b/flight/SimPosix/Makefile @@ -38,7 +38,7 @@ OUTDIR := $(TOP)/build/$(TARGET) # Set developer code and compile options # Set to YES for debugging -DEBUG ?= NO +DEBUG ?= YES # Set to YES when using Code Sourcery toolchain CODE_SOURCERY ?= NO diff --git a/flight/UAVObjects/inc/uavobjectmanager.h b/flight/UAVObjects/inc/uavobjectmanager.h index fe7c21d07..62aff543d 100644 --- a/flight/UAVObjects/inc/uavobjectmanager.h +++ b/flight/UAVObjects/inc/uavobjectmanager.h @@ -133,7 +133,7 @@ typedef void (*UAVObjEventCallback)(UAVObjEvent* ev); /** * Callback used to initialize the object fields to their default values. */ -typedef void (*UAVObjInitializeCallback)(UAVObjHandle obj, uint16_t instId); +typedef void (*UAVObjInitializeCallback)(UAVObjHandle obj_handle, uint16_t instId); /** * Event manager statistics @@ -148,25 +148,23 @@ typedef struct { int32_t UAVObjInitialize(); void UAVObjGetStats(UAVObjStats* statsOut); void UAVObjClearStats(); -UAVObjHandle UAVObjRegister(uint32_t id, const char* name, const char* metaName, int32_t isMetaobject, +UAVObjHandle UAVObjRegister(uint32_t id, int32_t isSingleInstance, int32_t isSettings, uint32_t numBytes, UAVObjInitializeCallback initCb); UAVObjHandle UAVObjGetByID(uint32_t id); -UAVObjHandle UAVObjGetByName(char* name); uint32_t UAVObjGetID(UAVObjHandle obj); -const char* UAVObjGetName(UAVObjHandle obj); uint32_t UAVObjGetNumBytes(UAVObjHandle obj); uint16_t UAVObjGetNumInstances(UAVObjHandle obj); UAVObjHandle UAVObjGetLinkedObj(UAVObjHandle obj); -uint16_t UAVObjCreateInstance(UAVObjHandle obj, UAVObjInitializeCallback initCb); -int32_t UAVObjIsSingleInstance(UAVObjHandle obj); -int32_t UAVObjIsMetaobject(UAVObjHandle obj); -int32_t UAVObjIsSettings(UAVObjHandle obj); -int32_t UAVObjUnpack(UAVObjHandle obj, uint16_t instId, const uint8_t* dataIn); -int32_t UAVObjPack(UAVObjHandle obj, uint16_t instId, uint8_t* dataOut); -int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId); -int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId); -int32_t UAVObjDelete(UAVObjHandle obj, uint16_t instId); -int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, FILEINFO* file); +uint16_t UAVObjCreateInstance(UAVObjHandle obj_handle, UAVObjInitializeCallback initCb); +bool UAVObjIsSingleInstance(UAVObjHandle obj); +bool UAVObjIsMetaobject(UAVObjHandle obj); +bool UAVObjIsSettings(UAVObjHandle obj); +int32_t UAVObjUnpack(UAVObjHandle obj_handle, uint16_t instId, const uint8_t* dataIn); +int32_t UAVObjPack(UAVObjHandle obj_handle, uint16_t instId, uint8_t* dataOut); +int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId); +int32_t UAVObjLoad(UAVObjHandle obj_handle, uint16_t instId); +int32_t UAVObjDelete(UAVObjHandle obj_handle, uint16_t instId); +int32_t UAVObjSaveToFile(UAVObjHandle obj_handle, uint16_t instId, FILEINFO* file); UAVObjHandle UAVObjLoadFromFile(FILEINFO* file); int32_t UAVObjSaveSettings(); int32_t UAVObjLoadSettings(); @@ -174,18 +172,17 @@ int32_t UAVObjDeleteSettings(); int32_t UAVObjSaveMetaobjects(); int32_t UAVObjLoadMetaobjects(); int32_t UAVObjDeleteMetaobjects(); -int32_t UAVObjSetData(UAVObjHandle obj, const void* dataIn); -int32_t UAVObjSetDataField(UAVObjHandle obj, const void* dataIn, uint32_t offset, uint32_t size); -int32_t UAVObjGetData(UAVObjHandle obj, void* dataOut); -int32_t UAVObjGetDataField(UAVObjHandle obj, void* dataOut, uint32_t offset, uint32_t size); -int32_t UAVObjSetInstanceData(UAVObjHandle obj, uint16_t instId, const void* dataIn); -int32_t UAVObjSetInstanceDataField(UAVObjHandle obj, uint16_t instId, const void* dataIn, uint32_t offset, uint32_t size); -int32_t UAVObjGetInstanceData(UAVObjHandle obj, uint16_t instId, void* dataOut); -int32_t UAVObjGetInstanceDataField(UAVObjHandle obj, uint16_t instId, void* dataOut, uint32_t offset, uint32_t size); -int32_t UAVObjSetMetadata(UAVObjHandle obj, const UAVObjMetadata* dataIn); -int32_t UAVObjGetMetadata(UAVObjHandle obj, UAVObjMetadata* dataOut); +int32_t UAVObjSetData(UAVObjHandle obj_handle, const void* dataIn); +int32_t UAVObjSetDataField(UAVObjHandle obj_handle, const void* dataIn, uint32_t offset, uint32_t size); +int32_t UAVObjGetData(UAVObjHandle obj_handle, void* dataOut); +int32_t UAVObjGetDataField(UAVObjHandle obj_handle, void* dataOut, uint32_t offset, uint32_t size); +int32_t UAVObjSetInstanceData(UAVObjHandle obj_handle, uint16_t instId, const void* dataIn); +int32_t UAVObjSetInstanceDataField(UAVObjHandle obj_handle, uint16_t instId, const void* dataIn, uint32_t offset, uint32_t size); +int32_t UAVObjGetInstanceData(UAVObjHandle obj_handle, uint16_t instId, void* dataOut); +int32_t UAVObjGetInstanceDataField(UAVObjHandle obj_handle, uint16_t instId, void* dataOut, uint32_t offset, uint32_t size); +int32_t UAVObjSetMetadata(UAVObjHandle obj_handle, const UAVObjMetadata* dataIn); +int32_t UAVObjGetMetadata(UAVObjHandle obj_handle, UAVObjMetadata* dataOut); uint8_t UAVObjGetMetadataAccess(const UAVObjMetadata* dataOut); -void UAVObjMetadataInitialize(UAVObjMetadata* dataOut); UAVObjAccessType UAVObjGetAccess(const UAVObjMetadata* dataOut); void UAVObjSetAccess(UAVObjMetadata* dataOut, UAVObjAccessType mode); UAVObjAccessType UAVObjGetGcsAccess(const UAVObjMetadata* dataOut); @@ -199,14 +196,14 @@ void UAVObjSetTelemetryUpdateMode(UAVObjMetadata* dataOut, UAVObjUpdateMode val) UAVObjUpdateMode UAVObjGetGcsTelemetryUpdateMode(const UAVObjMetadata* dataOut); void UAVObjSetTelemetryGcsUpdateMode(UAVObjMetadata* dataOut, UAVObjUpdateMode val); int8_t UAVObjReadOnly(UAVObjHandle obj); -int32_t UAVObjConnectQueue(UAVObjHandle obj, xQueueHandle queue, uint8_t eventMask); -int32_t UAVObjDisconnectQueue(UAVObjHandle obj, xQueueHandle queue); -int32_t UAVObjConnectCallback(UAVObjHandle obj, UAVObjEventCallback cb, uint8_t eventMask); -int32_t UAVObjDisconnectCallback(UAVObjHandle obj, UAVObjEventCallback cb); +int32_t UAVObjConnectQueue(UAVObjHandle obj_handle, xQueueHandle queue, uint8_t eventMask); +int32_t UAVObjDisconnectQueue(UAVObjHandle obj_handle, xQueueHandle queue); +int32_t UAVObjConnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb, uint8_t eventMask); +int32_t UAVObjDisconnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb); void UAVObjRequestUpdate(UAVObjHandle obj); -void UAVObjRequestInstanceUpdate(UAVObjHandle obj, uint16_t instId); +void UAVObjRequestInstanceUpdate(UAVObjHandle obj_handle, uint16_t instId); void UAVObjUpdated(UAVObjHandle obj); -void UAVObjInstanceUpdated(UAVObjHandle obj, uint16_t instId); +void UAVObjInstanceUpdated(UAVObjHandle obj_handle, uint16_t instId); void UAVObjIterate(void (*iterator)(UAVObjHandle obj)); #endif // UAVOBJECTMANAGER_H diff --git a/flight/UAVObjects/inc/uavobjecttemplate.h b/flight/UAVObjects/inc/uavobjecttemplate.h index f106dd8ba..2938c218f 100644 --- a/flight/UAVObjects/inc/uavobjecttemplate.h +++ b/flight/UAVObjects/inc/uavobjecttemplate.h @@ -42,8 +42,6 @@ // Object constants #define $(NAMEUC)_OBJID $(OBJIDHEX) -#define $(NAMEUC)_NAME "$(NAME)" -#define $(NAMEUC)_METANAME "$(NAME)Meta" #define $(NAMEUC)_ISSINGLEINST $(ISSINGLEINST) #define $(NAMEUC)_ISSETTINGS $(ISSETTINGS) #define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data) diff --git a/flight/UAVObjects/uavobjectmanager.c b/flight/UAVObjects/uavobjectmanager.c index 8dc077967..2b2b69018 100644 --- a/flight/UAVObjects/uavobjectmanager.c +++ b/flight/UAVObjects/uavobjectmanager.c @@ -1,20 +1,20 @@ /** - ****************************************************************************** - * @addtogroup UAVObjects OpenPilot UAVObjects - * @{ - * @addtogroup UAV Object Manager - * @brief The core UAV Objects functions, most of which are wrappered by - * autogenerated defines - * @{ - * - * - * @file uavobjectmanager.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Object manager library. This library holds a collection of all objects. - * It can be used by all modules/libraries to find an object reference. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ +****************************************************************************** +* @addtogroup UAVObjects OpenPilot UAVObjects +* @{ +* @addtogroup UAV Object Manager +* @brief The core UAV Objects functions, most of which are wrappered by +* autogenerated defines +* @{ +* +* +* @file uavobjectmanager.h +* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. +* @brief Object manager library. This library holds a collection of all objects. +* It can be used by all modules/libraries to find an object reference. +* @see The GNU Public License (GPL) Version 3 +* +*****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,7 @@ */ #include "openpilot.h" +#include "pios_struct_helper.h" // Constants @@ -39,84 +40,144 @@ // Macros #define SET_BITS(var, shift, value, mask) var = (var & ~(mask << shift)) | (value << shift); -#define OLGetIsMetaobject(olp) ((olp)->flags & OL_IS_METAOBJECT) -#define OLSetIsMetaobject(olp, val) ((olp)->flags = (((val) == 0) ? ((olp)->flags & ~OL_IS_METAOBJECT) : ((olp)->flags | OL_IS_METAOBJECT))) -#define OLGetIsSingleInstance(olp) ((olp)->flags & OL_IS_SINGLE_INSTANCE) -#define OLSetIsSingleInstance(olp, val) ((olp)->flags = (((val) == 0) ? ((olp)->flags & ~OL_IS_SINGLE_INSTANCE) : ((olp)->flags | OL_IS_SINGLE_INSTANCE))) -#define OLGetIsSettings(olp) ((olp)->flags & OL_IS_SETTINGS) -#define OLSetIsSettings(olp, val) ((olp)->flags = (((val) == 0) ? ((olp)->flags & ~OL_IS_SETTINGS) : ((olp)->flags | OL_IS_SETTINGS))) /** * List of event queues and the eventmask associated with the queue. */ -struct ObjectEventListStruct { - xQueueHandle queue; - UAVObjEventCallback cb; - uint8_t eventMask; - struct ObjectEventListStruct *next; -}; -typedef struct ObjectEventListStruct ObjectEventList; -/** - * List of object instances, holds the actual data structure and instance ID - */ -struct ObjectInstListStruct { - void *data; - uint16_t instId; - struct ObjectInstListStruct *next; -}; -typedef struct ObjectInstListStruct ObjectInstList; +/** opaque type for instances **/ +typedef void* InstanceHandle; -typedef enum { - OL_IS_METAOBJECT = 0x01, /** Set if this is a metaobject */ - OL_IS_SINGLE_INSTANCE = 0x02, /** Set if this object has a single instance */ - OL_IS_SETTINGS = 0x04 /** Set if this object is a settings object */ -} ObjectListFlags; - -/** - * List of objects registered in the object manager - */ -struct ObjectListStruct { - uint32_t id; - /** The object ID */ - const char *name; - /** The object name */ - ObjectListFlags flags; - /** The object list mode flags */ - uint16_t numBytes; - /** Number of data bytes contained in the object (for a single instance) */ - uint16_t numInstances; - /** Number of instances */ - struct ObjectListStruct *linkedObj; - /** Linked object, for regular objects this is the metaobject and for metaobjects it is the parent object */ - ObjectInstList instances; - /** List of object instances, instance 0 always exists */ - ObjectEventList *events; - /** Event queues registered on the object */ - struct ObjectListStruct *next; - /** Needed by linked list library (utlist.h) */ +struct ObjectEventEntry { + xQueueHandle queue; + UAVObjEventCallback cb; + uint8_t eventMask; + struct ObjectEventEntry * next; }; -typedef struct ObjectListStruct ObjectList; + +/* + MetaInstance == [UAVOBase [UAVObjMetadata]] + SingleInstance == [UAVOBase [UAVOData [InstanceData]]] + MultiInstance == [UAVOBase [UAVOData [NumInstances [InstanceData0 [next]]]] + ____________________/ + \-->[InstanceData1 [next]] + _________...________/ + \-->[InstanceDataN [next]] + */ + +/* + * UAVO Base Type + * - All Types of UAVObjects are of this base type + * - The flags determine what type(s) this object + */ +struct UAVOBase { + /* Let these objects be added to an event queue */ + struct ObjectEventEntry * next_event; + + /* Describe the type of object that follows this header */ + struct UAVOInfo { + bool isMeta : 1; + bool isSingle : 1; + bool isSettings : 1; + } flags; + +} __attribute__((packed)); + +/* Augmented type for Meta UAVO */ +struct UAVOMeta { + struct UAVOBase base; + UAVObjMetadata instance0; +} __attribute__((packed)); + +/* Shared data structure for all data-carrying UAVObjects (UAVOSingle and UAVOMulti) */ +struct UAVOData { + struct UAVOBase base; + uint32_t id; + /* + * Embed the Meta object as another complete UAVO + * inside the payload for this UAVO. + */ + struct UAVOMeta metaObj; + struct UAVOData * next; + uint16_t instance_size; +} __attribute__((packed)); + +/* Augmented type for Single Instance Data UAVO */ +struct UAVOSingle { + struct UAVOData uavo; + + uint8_t instance0[]; + /* + * Additional space will be malloc'd here to hold the + * the data for this instance. + */ +} __attribute__((packed)); + +/* Part of a linked list of instances chained off of a multi instance UAVO. */ +struct UAVOMultiInst { + struct UAVOMultiInst * next; + uint8_t instance[]; + /* + * Additional space will be malloc'd here to hold the + * the data for this instance. + */ +} __attribute__((packed)); + +/* Augmented type for Multi Instance Data UAVO */ +struct UAVOMulti { + struct UAVOData uavo; + + uint16_t num_instances; + struct UAVOMultiInst instance0; + /* + * Additional space will be malloc'd here to hold the + * the data for instance 0. + */ +} __attribute__((packed)); + +/** all information about a metaobject are hardcoded constants **/ +#define MetaNumBytes sizeof(UAVObjMetadata) +#define MetaBaseObjectPtr(obj) ((struct UAVOData *)((obj)-offsetof(struct UAVOData, metaObj))) +#define MetaObjectPtr(obj) ((struct UAVODataMeta*) &((obj)->metaObj)) +#define MetaDataPtr(obj) ((UAVObjMetadata*)&((obj)->instance0)) +#define LinkedMetaDataPtr(obj) ((UAVObjMetadata*)&((obj)->metaObj.instance0)) +#define MetaObjectId(id) ((id)+1) + +/** all information about instances are dependant on object type **/ +#define ObjSingleInstanceDataOffset(obj) ((void*)(&(( (struct UAVOSingle*)obj )->instance0))) +#define InstanceDataOffset(inst) ((void*)&(( (struct UAVOMultiInst*)inst )->instance)) +#define InstanceData(instance) (void*)instance // Private functions -static int32_t sendEvent(ObjectList * obj, uint16_t instId, - UAVObjEventType event); -static ObjectInstList *createInstance(ObjectList * obj, uint16_t instId); -static ObjectInstList *getInstance(ObjectList * obj, uint16_t instId); -static int32_t connectObj(UAVObjHandle obj, xQueueHandle queue, - UAVObjEventCallback cb, uint8_t eventMask); -static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, - UAVObjEventCallback cb); +static int32_t sendEvent(struct UAVOBase * obj, uint16_t instId, + UAVObjEventType event); +static InstanceHandle createInstance(struct UAVOData * obj, uint16_t instId); +static InstanceHandle getInstance(struct UAVOData * obj, uint16_t instId); +static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue, + UAVObjEventCallback cb, uint8_t eventMask); +static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue, + UAVObjEventCallback cb); #if defined(PIOS_INCLUDE_SDCARD) -static void objectFilename(ObjectList * obj, uint8_t * filename); +static void objectFilename(UAVObjHandle obj_handle, uint8_t * filename); static void customSPrintf(uint8_t * buffer, uint8_t * format, ...); #endif // Private variables -static ObjectList *objList; +static struct UAVOData * uavo_list; static xSemaphoreHandle mutex; -static UAVObjMetadata defMetadata; +static const UAVObjMetadata defMetadata = { + .flags = (ACCESS_READWRITE << UAVOBJ_ACCESS_SHIFT | + ACCESS_READWRITE << UAVOBJ_GCS_ACCESS_SHIFT | + 1 << UAVOBJ_TELEMETRY_ACKED_SHIFT | + 1 << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | + UPDATEMODE_ONCHANGE << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | + UPDATEMODE_ONCHANGE << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT), + .telemetryUpdatePeriod = 0, + .gcsTelemetryUpdatePeriod = 0, + .loggingUpdatePeriod = 0, +}; + static UAVObjStats stats; /** @@ -126,31 +187,32 @@ static UAVObjStats stats; */ int32_t UAVObjInitialize() { - // Initialize variables - objList = NULL; - memset(&stats, 0, sizeof(UAVObjStats)); + // Initialize variables + uavo_list = NULL; + memset(&stats, 0, sizeof(UAVObjStats)); - // Create mutex - mutex = xSemaphoreCreateRecursiveMutex(); - if (mutex == NULL) - return -1; + // Create mutex + mutex = xSemaphoreCreateRecursiveMutex(); + if (mutex == NULL) + return -1; - // Initialize default metadata structure (metadata of metaobjects) - UAVObjMetadataInitialize(&defMetadata); - - // Done - return 0; + // Done + return 0; } +/***************** + * Statistics + ****************/ + /** * Get the statistics counters * @param[out] statsOut The statistics counters will be copied there */ void UAVObjGetStats(UAVObjStats * statsOut) { - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - memcpy(statsOut, &stats, sizeof(UAVObjStats)); - xSemaphoreGiveRecursive(mutex); + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + memcpy(statsOut, &stats, sizeof(UAVObjStats)); + xSemaphoreGiveRecursive(mutex); } /** @@ -158,17 +220,84 @@ void UAVObjGetStats(UAVObjStats * statsOut) */ void UAVObjClearStats() { - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - memset(&stats, 0, sizeof(UAVObjStats)); - xSemaphoreGiveRecursive(mutex); + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + memset(&stats, 0, sizeof(UAVObjStats)); + xSemaphoreGiveRecursive(mutex); } +/************************ + * Object Initialization + ***********************/ + +static void UAVObjInitMetaData (struct UAVOMeta * obj_meta) +{ + /* Fill in the common part of the UAVO */ + struct UAVOBase * uavo_base = &(obj_meta->base); + memset(uavo_base, 0, sizeof(*uavo_base)); + uavo_base->flags.isMeta = true; + uavo_base->flags.isSingle = true; + uavo_base->next_event = NULL; + + /* Clear the instance data carried in the UAVO */ + memset(&(obj_meta->instance0), 0, sizeof(obj_meta->instance0)); +} + +static struct UAVOData * UAVObjAllocSingle(uint32_t num_bytes) +{ + /* Compute the complete size of the object, including the data for a single embedded instance */ + uint32_t object_size = sizeof(struct UAVOSingle) + num_bytes; + + /* Allocate the object from the heap */ + struct UAVOSingle * uavo_single = (struct UAVOSingle *) pvPortMalloc(object_size); + if (!uavo_single) + return (NULL); + + /* Fill in the common part of the UAVO */ + struct UAVOBase * uavo_base = &(uavo_single->uavo.base); + memset(uavo_base, 0, sizeof(*uavo_base)); + uavo_base->flags.isSingle = true; + uavo_base->next_event = NULL; + + /* Clear the instance data carried in the UAVO */ + memset(&(uavo_single->instance0), 0, num_bytes); + + /* Give back the generic UAVO part */ + return (&(uavo_single->uavo)); +} + +static struct UAVOData * UAVObjAllocMulti(uint32_t num_bytes) +{ + /* Compute the complete size of the object, including the data for a single embedded instance */ + uint32_t object_size = sizeof(struct UAVOMulti) + num_bytes; + + /* Allocate the object from the heap */ + struct UAVOMulti * uavo_multi = (struct UAVOMulti *) pvPortMalloc(object_size); + if (!uavo_multi) + return (NULL); + + /* Fill in the common part of the UAVO */ + struct UAVOBase * uavo_base = &(uavo_multi->uavo.base); + memset(uavo_base, 0, sizeof(*uavo_base)); + uavo_base->flags.isSingle = false; + uavo_base->next_event = NULL; + + /* Set up the type-specific part of the UAVO */ + uavo_multi->num_instances = 1; + + /* Clear the instance data carried in the UAVO */ + memset (&(uavo_multi->instance0), 0, num_bytes); + + /* Give back the generic UAVO part */ + return (&(uavo_multi->uavo)); +} + +/************************** + * UAVObject Database APIs + *************************/ + /** * Register and new object in the object manager. * \param[in] id Unique object ID - * \param[in] name Object name - * \param[in] nameName Metaobject name - * \param[in] isMetaobject Is this a metaobject (1:true, 0:false) * \param[in] isSingleInstance Is this a single instance or multi-instance object * \param[in] isSettings Is this a settings object * \param[in] numBytes Number of bytes of object data (for one instance) @@ -176,85 +305,60 @@ void UAVObjClearStats() * \return Object handle, or NULL if failure. * \return */ -UAVObjHandle UAVObjRegister(uint32_t id, const char *name, - const char *metaName, int32_t isMetaobject, - int32_t isSingleInstance, int32_t isSettings, - uint32_t numBytes, - UAVObjInitializeCallback initCb) +UAVObjHandle UAVObjRegister(uint32_t id, + int32_t isSingleInstance, int32_t isSettings, + uint32_t num_bytes, + UAVObjInitializeCallback initCb) { - ObjectList *objEntry; - ObjectInstList *instEntry; - ObjectList *metaObj; + struct UAVOData * uavo_data = NULL; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Check that the object is not already registered - LL_FOREACH(objList, objEntry) { - if (objEntry->id == id) { - // Already registered, ignore - xSemaphoreGiveRecursive(mutex); - return NULL; - } - } + /* Don't allow duplicate registrations */ + if (UAVObjGetByID(id)) + goto unlock_exit; - // Create and append entry - objEntry = (ObjectList *) pvPortMalloc(sizeof(ObjectList)); - if (objEntry == NULL) { - xSemaphoreGiveRecursive(mutex); - return NULL; - } - objEntry->id = id; - objEntry->name = name; - OLSetIsMetaobject(objEntry, isMetaobject); - OLSetIsSingleInstance(objEntry, isSingleInstance); - OLSetIsSettings(objEntry, isSettings); - objEntry->numBytes = numBytes; - objEntry->events = NULL; - objEntry->numInstances = 0; - objEntry->instances.data = NULL; - objEntry->instances.instId = 0xFFFF; - objEntry->instances.next = NULL; - objEntry->linkedObj = NULL; // will be set later - LL_APPEND(objList, objEntry); + /* Map the various flags to one of the UAVO types we understand */ + if (isSingleInstance) { + uavo_data = UAVObjAllocSingle (num_bytes); + } else { + uavo_data = UAVObjAllocMulti (num_bytes); + } - // Create instance zero - instEntry = createInstance(objEntry, 0); - if (instEntry == NULL) { - xSemaphoreGiveRecursive(mutex); - return NULL; - } - // Create metaobject and update linkedObj - if (isMetaobject) { - objEntry->linkedObj = NULL; // will be set later - } else { - // Create metaobject - metaObj = - (ObjectList *) UAVObjRegister(id + 1, metaName, - NULL, 1, 1, 0, - sizeof - (UAVObjMetadata), - NULL); - // Link two objects - objEntry->linkedObj = metaObj; - metaObj->linkedObj = objEntry; - } + if (!uavo_data) + goto unlock_exit; - // Initialize object fields and metadata to default values - if (initCb != NULL) { - initCb((UAVObjHandle) objEntry, 0); - } - // Attempt to load object's metadata from the SD card (not done directly on the metaobject, but through the object) - if (!OLGetIsMetaobject(objEntry)) { - UAVObjLoad((UAVObjHandle) objEntry->linkedObj, 0); - } - // If this is a settings object, attempt to load from SD card - if (OLGetIsSettings(objEntry)) { - UAVObjLoad((UAVObjHandle) objEntry, 0); - } - // Release lock - xSemaphoreGiveRecursive(mutex); - return (UAVObjHandle) objEntry; + /* Fill in the details about this UAVO */ + uavo_data->id = id; + uavo_data->instance_size = num_bytes; + if (isSettings) { + uavo_data->base.flags.isSettings = true; + } + + /* Initialize the embedded meta UAVO */ + UAVObjInitMetaData (&uavo_data->metaObj); + + /* Add the newly created object to the global list of objects */ + LL_APPEND(uavo_list, uavo_data); + + /* Initialize object fields and metadata to default values */ + if (initCb) + initCb((UAVObjHandle) uavo_data, 0); + + /* Always try to load the meta object from flash */ + UAVObjLoad((UAVObjHandle) &(uavo_data->metaObj), 0); + + /* Attempt to load settings object from flash */ + if (uavo_data->base.flags.isSettings) + UAVObjLoad((UAVObjHandle) uavo_data, 0); + + // fire events for outer object and its embedded meta object + UAVObjInstanceUpdated((UAVObjHandle) uavo_data, 0); + UAVObjInstanceUpdated((UAVObjHandle) &(uavo_data->metaObj), 0); + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return (UAVObjHandle) uavo_data; } /** @@ -264,52 +368,27 @@ UAVObjHandle UAVObjRegister(uint32_t id, const char *name, */ UAVObjHandle UAVObjGetByID(uint32_t id) { - ObjectList *objEntry; + UAVObjHandle * found_obj = (UAVObjHandle *) NULL; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Get lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Look for object - LL_FOREACH(objList, objEntry) { - if (objEntry->id == id) { - // Release lock - xSemaphoreGiveRecursive(mutex); - // Done, object found - return (UAVObjHandle) objEntry; - } - } + // Look for object + struct UAVOData * tmp_obj; + LL_FOREACH(uavo_list, tmp_obj) { + if (tmp_obj->id == id) { + found_obj = (UAVObjHandle *)tmp_obj; + goto unlock_exit; + } + if (MetaObjectId(tmp_obj->id) == id) { + found_obj = (UAVObjHandle *)&(tmp_obj->metaObj); + goto unlock_exit; + } + } - // Object not found, release lock and return error - xSemaphoreGiveRecursive(mutex); - return NULL; -} - -/** - * Retrieve an object from the list given its name - * \param[in] name The name of the object - * \return The object or NULL if not found. - */ -UAVObjHandle UAVObjGetByName(char *name) -{ - ObjectList *objEntry; - - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Look for object - LL_FOREACH(objList, objEntry) { - if (objEntry->name != NULL - && strcmp(objEntry->name, name) == 0) { - // Release lock - xSemaphoreGiveRecursive(mutex); - // Done, object found - return (UAVObjHandle) objEntry; - } - } - - // Object not found, release lock and return error - xSemaphoreGiveRecursive(mutex); - return NULL; +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return found_obj; } /** @@ -317,19 +396,24 @@ UAVObjHandle UAVObjGetByName(char *name) * \param[in] obj The object handle * \return The object ID */ -uint32_t UAVObjGetID(UAVObjHandle obj) +uint32_t UAVObjGetID(UAVObjHandle obj_handle) { - return ((ObjectList *) obj)->id; -} + PIOS_Assert(obj_handle); -/** - * Get the object's name - * \param[in] obj The object handle - * \return The object's name - */ -const char *UAVObjGetName(UAVObjHandle obj) -{ - return ((ObjectList *) obj)->name; + /* Recover the common object header */ + struct UAVOBase * uavo_base = (struct UAVOBase *) obj_handle; + + if (UAVObjIsMetaobject(obj_handle)) { + /* We have a meta object, find our containing UAVO */ + struct UAVOData * uavo_data = container_of ((struct UAVOMeta *)uavo_base, struct UAVOData, metaObj); + + return MetaObjectId (uavo_data->id); + } else { + /* We have a data object, augment our pointer */ + struct UAVOData * uavo_data = (struct UAVOData *) uavo_base; + + return (uavo_data->id); + } } /** @@ -339,7 +423,23 @@ const char *UAVObjGetName(UAVObjHandle obj) */ uint32_t UAVObjGetNumBytes(UAVObjHandle obj) { - return ((ObjectList *) obj)->numBytes; + PIOS_Assert(obj); + + uint32_t instance_size; + + /* Recover the common object header */ + struct UAVOBase * uavo_base = (struct UAVOBase *) obj; + + if (uavo_base->flags.isMeta) { + instance_size = MetaNumBytes; + } else { + /* We have a data object, augment our pointer */ + struct UAVOData * uavo = (struct UAVOData *) uavo_base; + + instance_size = uavo->instance_size; + } + + return (instance_size); } /** @@ -349,9 +449,24 @@ uint32_t UAVObjGetNumBytes(UAVObjHandle obj) * \param[in] obj The object handle * \return The object linked object handle */ -UAVObjHandle UAVObjGetLinkedObj(UAVObjHandle obj) +UAVObjHandle UAVObjGetLinkedObj(UAVObjHandle obj_handle) { - return (UAVObjHandle) (((ObjectList *) obj)->linkedObj); + PIOS_Assert(obj_handle); + + /* Recover the common object header */ + struct UAVOBase * uavo_base = (struct UAVOBase *) obj_handle; + + if (UAVObjIsMetaobject(obj_handle)) { + /* We have a meta object, find our containing UAVO. */ + struct UAVOData * uavo_data = container_of ((struct UAVOMeta *)uavo_base, struct UAVOData, metaObj); + + return (UAVObjHandle) uavo_data; + } else { + /* We have a data object, augment our pointer */ + struct UAVOData * uavo_data = (struct UAVOData *) uavo_base; + + return (UAVObjHandle) &(uavo_data->metaObj); + } } /** @@ -359,13 +474,19 @@ UAVObjHandle UAVObjGetLinkedObj(UAVObjHandle obj) * \param[in] obj The object handle * \return The number of instances */ -uint16_t UAVObjGetNumInstances(UAVObjHandle obj) +uint16_t UAVObjGetNumInstances(UAVObjHandle obj_handle) { - uint32_t numInstances; - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - numInstances = ((ObjectList *) obj)->numInstances; - xSemaphoreGiveRecursive(mutex); - return numInstances; + PIOS_Assert(obj_handle); + + if (UAVObjIsSingleInstance(obj_handle)) { + /* Only one instance is allowed */ + return 1; + } else { + /* Multi-instance object. Inspect the object */ + /* Augment our pointer to reflect the proper type */ + struct UAVOMulti * uavo_multi = (struct UAVOMulti *) obj_handle; + return uavo_multi->num_instances; + } } /** @@ -373,29 +494,37 @@ uint16_t UAVObjGetNumInstances(UAVObjHandle obj) * \param[in] obj The object handle * \return The instance ID or 0 if an error */ -uint16_t UAVObjCreateInstance(UAVObjHandle obj, - UAVObjInitializeCallback initCb) +uint16_t UAVObjCreateInstance(UAVObjHandle obj_handle, + UAVObjInitializeCallback initCb) { - ObjectList *objEntry; - ObjectInstList *instEntry; + PIOS_Assert(obj_handle); - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + if (UAVObjIsMetaobject(obj_handle)) { + return 0; + } - // Create new instance - objEntry = (ObjectList *) obj; - instEntry = createInstance(objEntry, objEntry->numInstances); - if (instEntry == NULL) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Initialize instance data - if (initCb != NULL) { - initCb(obj, instEntry->instId); - } - // Unlock - xSemaphoreGiveRecursive(mutex); - return instEntry->instId; + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + + InstanceHandle instEntry; + uint16_t instId = 0; + + // Create new instance + instId = UAVObjGetNumInstances(obj_handle); + instEntry = createInstance( (struct UAVOData *)obj_handle, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + + // Initialize instance data + if (initCb) { + initCb(obj_handle, instId); + } + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + + return instId; } /** @@ -403,9 +532,14 @@ uint16_t UAVObjCreateInstance(UAVObjHandle obj, * \param[in] obj The object handle * \return True (1) if this is a single instance object */ -int32_t UAVObjIsSingleInstance(UAVObjHandle obj) +bool UAVObjIsSingleInstance(UAVObjHandle obj_handle) { - return OLGetIsSingleInstance((ObjectList *) obj); + PIOS_Assert(obj_handle); + + /* Recover the common object header */ + struct UAVOBase * uavo_base = (struct UAVOBase *) obj_handle; + + return uavo_base->flags.isSingle; } /** @@ -413,9 +547,14 @@ int32_t UAVObjIsSingleInstance(UAVObjHandle obj) * \param[in] obj The object handle * \return True (1) if this is metaobject */ -int32_t UAVObjIsMetaobject(UAVObjHandle obj) +bool UAVObjIsMetaobject(UAVObjHandle obj_handle) { - return OLGetIsMetaobject((ObjectList *) obj); + PIOS_Assert(obj_handle); + + /* Recover the common object header */ + struct UAVOBase * uavo_base = (struct UAVOBase *) obj_handle; + + return uavo_base->flags.isMeta; } /** @@ -423,9 +562,14 @@ int32_t UAVObjIsMetaobject(UAVObjHandle obj) * \param[in] obj The object handle * \return True (1) if this is a settings object */ -int32_t UAVObjIsSettings(UAVObjHandle obj) +bool UAVObjIsSettings(UAVObjHandle obj_handle) { - return OLGetIsSettings((ObjectList *) obj); + PIOS_Assert(obj_handle); + + /* Recover the common object header */ + struct UAVOBase * uavo_base = (struct UAVOBase *) obj_handle; + + return uavo_base->flags.isSettings; } /** @@ -435,39 +579,49 @@ int32_t UAVObjIsSettings(UAVObjHandle obj) * \param[in] dataIn The byte array * \return 0 if success or -1 if failure */ -int32_t UAVObjUnpack(UAVObjHandle obj, uint16_t instId, - const uint8_t * dataIn) +int32_t UAVObjUnpack(UAVObjHandle obj_handle, uint16_t instId, + const uint8_t * dataIn) { - ObjectList *objEntry; - ObjectInstList *instEntry; + PIOS_Assert(obj_handle); - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Cast handle to object - objEntry = (ObjectList *) obj; + int32_t rc = -1; - // Get the instance - instEntry = getInstance(objEntry, instId); + if (UAVObjIsMetaobject(obj_handle)) { + if (instId != 0) { + goto unlock_exit; + } + memcpy(MetaDataPtr((struct UAVOMeta *)obj_handle), dataIn, MetaNumBytes); + } else { + struct UAVOData *obj; + InstanceHandle instEntry; - // If the instance does not exist create it and any other instances before it - if (instEntry == NULL) { - instEntry = createInstance(objEntry, instId); - if (instEntry == NULL) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - // Set the data - memcpy(instEntry->data, dataIn, objEntry->numBytes); + // Cast handle to object + obj = (struct UAVOData *) obj_handle; - // Fire event - sendEvent(objEntry, instId, EV_UNPACKED); + // Get the instance + instEntry = getInstance(obj, instId); - // Unlock - xSemaphoreGiveRecursive(mutex); - return 0; + // If the instance does not exist create it and any other instances before it + if (instEntry == NULL) { + instEntry = createInstance(obj, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + } + // Set the data + memcpy(InstanceData(instEntry), dataIn, obj->instance_size); + } + + // Fire event + sendEvent((struct UAVOBase*)obj_handle, instId, EV_UNPACKED); + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -477,30 +631,41 @@ int32_t UAVObjUnpack(UAVObjHandle obj, uint16_t instId, * \param[out] dataOut The byte array * \return 0 if success or -1 if failure */ -int32_t UAVObjPack(UAVObjHandle obj, uint16_t instId, uint8_t * dataOut) +int32_t UAVObjPack(UAVObjHandle obj_handle, uint16_t instId, uint8_t * dataOut) { - ObjectList *objEntry; - ObjectInstList *instEntry; + PIOS_Assert(obj_handle); - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Cast handle to object - objEntry = (ObjectList *) obj; + int32_t rc = -1; - // Get the instance - instEntry = getInstance(objEntry, instId); - if (instEntry == NULL) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Pack data - memcpy(dataOut, instEntry->data, objEntry->numBytes); + if (UAVObjIsMetaobject(obj_handle)) { + if (instId != 0) { + goto unlock_exit; + } + memcpy(dataOut, MetaDataPtr((struct UAVOMeta *)obj_handle), MetaNumBytes); + } else { + struct UAVOData *obj; + InstanceHandle instEntry; - // Unlock - xSemaphoreGiveRecursive(mutex); - return 0; + // Cast handle to object + obj = (struct UAVOData *) obj_handle; + + // Get the instance + instEntry = getInstance(obj, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + // Pack data + memcpy(dataOut, InstanceData(instEntry), obj->instance_size); + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -512,50 +677,72 @@ int32_t UAVObjPack(UAVObjHandle obj, uint16_t instId, uint8_t * dataOut) * @param[in] file File to append to * @return 0 if success or -1 if failure */ -int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, - FILEINFO * file) +int32_t UAVObjSaveToFile(UAVObjHandle obj_handle, uint16_t instId, + FILEINFO * file) { + PIOS_Assert(obj_handle); + #if defined(PIOS_INCLUDE_SDCARD) - uint32_t bytesWritten; - ObjectList *objEntry; - ObjectInstList *instEntry; + uint32_t bytesWritten; + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + if (UAVObjIsMetaobject(obj_handle)) { + // Get the instance information + if (instId != 0) { + xSemaphoreGiveRecursive(mutex); + return -1; + } + // Write the object ID + uint32_t objId = UAVObjGetID(obj_handle); + PIOS_FWRITE(file, &objId, sizeof(objId), + &bytesWritten); - // Cast to object - objEntry = (ObjectList *) obj; + // Write the data and check that the write was successful + PIOS_FWRITE(file, MetaDataPtr((struct UAVOMeta *)obj_handle), MetaNumBytes, + &bytesWritten); + if (bytesWritten != MetaNumBytes) { + xSemaphoreGiveRecursive(mutex); + return -1; + } + } else { + struct UAVOData * uavo; + InstanceHandle instEntry; - // Get the instance information - instEntry = getInstance(objEntry, instId); - if (instEntry == NULL) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Write the object ID - PIOS_FWRITE(file, &objEntry->id, sizeof(objEntry->id), - &bytesWritten); + // Cast to object + uavo = (struct UAVOData *) obj_handle; - // Write the instance ID - if (!OLGetIsSingleInstance(objEntry)) { - PIOS_FWRITE(file, &instEntry->instId, - sizeof(instEntry->instId), &bytesWritten); - } - // Write the data and check that the write was successful - PIOS_FWRITE(file, instEntry->data, objEntry->numBytes, - &bytesWritten); - if (bytesWritten != objEntry->numBytes) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Done - xSemaphoreGiveRecursive(mutex); + // Get the instance information + instEntry = getInstance(uavo, instId); + if (instEntry == NULL) { + xSemaphoreGiveRecursive(mutex); + return -1; + } + // Write the object ID + PIOS_FWRITE(file, &uavo->id, sizeof(uavo->id), + &bytesWritten); + + // Write the instance ID + if (!UAVObjIsSingleInstance(obj_handle)) { + PIOS_FWRITE(file, &instId, + sizeof(instId), &bytesWritten); + } + // Write the data and check that the write was successful + PIOS_FWRITE(file, InstanceData(instEntry), uavo->instance_size, + &bytesWritten); + if (bytesWritten != uavo->instance_size) { + xSemaphoreGiveRecursive(mutex); + return -1; + } + } + // Done + xSemaphoreGiveRecursive(mutex); #endif /* PIOS_INCLUDE_SDCARD */ - return 0; + return 0; } /** @@ -568,59 +755,60 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, * @param[in] file File to append to * @return 0 if success or -1 if failure */ -int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId) +int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId) { + PIOS_Assert(obj_handle); + #if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS) - ObjectList *objEntry = (ObjectList *) obj; + if (UAVObjIsMetaobject(obj_handle)) { + if (instId != 0) + return -1; - if (objEntry == NULL) - return -1; + if (PIOS_FLASHFS_ObjSave(obj_handle, instId, (uint8_t*) MetaDataPtr((struct UAVOMeta *)obj_handle)) != 0) + return -1; + } else { + InstanceHandle instEntry = getInstance( (struct UAVOData *)obj_handle, instId); - ObjectInstList *instEntry = getInstance(objEntry, instId); + if (instEntry == NULL) + return -1; - if (instEntry == NULL) - return -1; + if (InstanceData(instEntry) == NULL) + return -1; - if (instEntry->data == NULL) - return -1; - - if (PIOS_FLASHFS_ObjSave(obj, instId, instEntry->data) != 0) - return -1; + if (PIOS_FLASHFS_ObjSave(obj_handle, instId, InstanceData(instEntry)) != 0) + return -1; + } #endif #if defined(PIOS_INCLUDE_SDCARD) - FILEINFO file; - ObjectList *objEntry; - uint8_t filename[14]; + FILEINFO file; + uint8_t filename[14]; - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Cast to object - objEntry = (ObjectList *) obj; + // Get filename + objectFilename(obj_handle, filename); - // Get filename - objectFilename(objEntry, filename); - - // Open file - if (PIOS_FOPEN_WRITE(filename, file)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Append object - if (UAVObjSaveToFile(obj, instId, &file) == -1) { - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Done, close file and unlock - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); + // Open file + if (PIOS_FOPEN_WRITE(filename, file)) { + xSemaphoreGiveRecursive(mutex); + return -1; + } + // Append object + if (UAVObjSaveToFile(obj_handle, instId, &file) == -1) { + PIOS_FCLOSE(file); + xSemaphoreGiveRecursive(mutex); + return -1; + } + // Done, close file and unlock + PIOS_FCLOSE(file); + xSemaphoreGiveRecursive(mutex); #endif /* PIOS_INCLUDE_SDCARD */ - return 0; + return 0; } /** @@ -631,68 +819,87 @@ int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId) UAVObjHandle UAVObjLoadFromFile(FILEINFO * file) { #if defined(PIOS_INCLUDE_SDCARD) - uint32_t bytesRead; - ObjectList *objEntry; - ObjectInstList *instEntry; - uint32_t objId; - uint16_t instId; - UAVObjHandle obj; + uint32_t bytesRead; + struct UAVOBase *objEntry; + InstanceHandle instEntry; + uint32_t objId; + uint16_t instId; + UAVObjHandle obj_handle; - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return NULL; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return NULL; + } + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Read the object ID - if (PIOS_FREAD(file, &objId, sizeof(objId), &bytesRead)) { - xSemaphoreGiveRecursive(mutex); - return NULL; - } - // Get the object - obj = UAVObjGetByID(objId); - if (obj == 0) { - xSemaphoreGiveRecursive(mutex); - return NULL; - } - objEntry = (ObjectList *) obj; + // Read the object ID + if (PIOS_FREAD(file, &objId, sizeof(objId), &bytesRead)) { + xSemaphoreGiveRecursive(mutex); + return NULL; + } + // Get the object + obj_handle = UAVObjGetByID(objId); + if (obj_handle == 0) { + xSemaphoreGiveRecursive(mutex); + return NULL; + } + objEntry = (struct UAVOBase *) obj_handle; - // Get the instance ID - instId = 0; - if (!OLGetIsSingleInstance(objEntry)) { - if (PIOS_FREAD + // Get the instance ID + instId = 0; + if (!UAVObjIsSingleInstance(obj_handle)) { + if (PIOS_FREAD (file, &instId, sizeof(instId), &bytesRead)) { - xSemaphoreGiveRecursive(mutex); - return NULL; - } - } - // Get the instance information - instEntry = getInstance(objEntry, instId); + xSemaphoreGiveRecursive(mutex); + return NULL; + } + } - // If the instance does not exist create it and any other instances before it - if (instEntry == NULL) { - instEntry = createInstance(objEntry, instId); - if (instEntry == NULL) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return NULL; - } - } - // Read the instance data - if (PIOS_FREAD - (file, instEntry->data, objEntry->numBytes, &bytesRead)) { - xSemaphoreGiveRecursive(mutex); - return NULL; - } - // Fire event - sendEvent(objEntry, instId, EV_UNPACKED); + if (UAVObjIsMetaobject(obj_handle)) { + // If the instance does not exist create it and any other instances before it + if (instId != 0) { + // Error, unlock and return + xSemaphoreGiveRecursive(mutex); + return NULL; + } + // Read the instance data + if (PIOS_FREAD + (file, MetaDataPtr((struct UAVOMeta *)obj_handle), MetaNumBytes, &bytesRead)) { + xSemaphoreGiveRecursive(mutex); + return NULL; + } + } else { - // Unlock - xSemaphoreGiveRecursive(mutex); - return obj; + // Get the instance information + instEntry = getInstance((struct UAVOData *)objEntry, instId); + + // If the instance does not exist create it and any other instances before it + if (instEntry == NULL) { + instEntry = createInstance((struct UAVOData *)objEntry, instId); + if (instEntry == NULL) { + // Error, unlock and return + xSemaphoreGiveRecursive(mutex); + return NULL; + } + } + // Read the instance data + if (PIOS_FREAD + (file, InstanceData(instEntry), ((struct UAVOData *)objEntry)->instance_size, &bytesRead)) { + xSemaphoreGiveRecursive(mutex); + return NULL; + } + + } + + // Fire event + sendEvent(objEntry, instId, EV_UNPACKED); + + // Unlock + xSemaphoreGiveRecursive(mutex); + return obj_handle; #else /* PIOS_INCLUDE_SDCARD */ - return NULL; + return NULL; #endif } @@ -704,74 +911,74 @@ UAVObjHandle UAVObjLoadFromFile(FILEINFO * file) * @param[in] instId The object instance * @return 0 if success or -1 if failure */ -int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId) +int32_t UAVObjLoad(UAVObjHandle obj_handle, uint16_t instId) { + PIOS_Assert(obj_handle); + #if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS) - ObjectList *objEntry = (ObjectList *) obj; + if (UAVObjIsMetaobject(obj_handle)) { + if (instId != 0) + return -1; - if (objEntry == NULL) - return -1; + // Fire event on success + if (PIOS_FLASHFS_ObjLoad(obj_handle, instId, (uint8_t*) MetaDataPtr((struct UAVOMeta *)obj_handle)) == 0) + sendEvent((struct UAVOBase*)obj_handle, instId, EV_UNPACKED); + else + return -1; + } else { - ObjectInstList *instEntry = getInstance(objEntry, instId); + InstanceHandle instEntry = getInstance( (struct UAVOData *)obj_handle, instId); - if (instEntry == NULL) - return -1; + if (instEntry == NULL) + return -1; - if (instEntry->data == NULL) - return -1; + // Fire event on success + if (PIOS_FLASHFS_ObjLoad(obj_handle, instId, InstanceData(instEntry)) == 0) + sendEvent((struct UAVOBase*)obj_handle, instId, EV_UNPACKED); + else + return -1; + } - // Fire event on success - int32_t retval; - if ((retval = PIOS_FLASHFS_ObjLoad(obj, instId, instEntry->data)) == 0) - sendEvent(objEntry, instId, EV_UNPACKED); - else - return retval; #endif #if defined(PIOS_INCLUDE_SDCARD) - FILEINFO file; - ObjectList *objEntry; - UAVObjHandle loadedObj; - ObjectList *loadedObjEntry; - uint8_t filename[14]; + FILEINFO file; + UAVObjHandle loadedObj; + uint8_t filename[14]; - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Cast to object - objEntry = (ObjectList *) obj; + // Get filename + objectFilename(obj_handle, filename); - // Get filename - objectFilename(objEntry, filename); - - // Open file - if (PIOS_FOPEN_READ(filename, file)) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Load object - loadedObj = UAVObjLoadFromFile(&file); - if (loadedObj == 0) { - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Check that the IDs match - loadedObjEntry = (ObjectList *) loadedObj; - if (loadedObjEntry->id != objEntry->id) { - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Done, close file and unlock - PIOS_FCLOSE(file); - xSemaphoreGiveRecursive(mutex); + // Open file + if (PIOS_FOPEN_READ(filename, file)) { + xSemaphoreGiveRecursive(mutex); + return -1; + } + // Load object + loadedObj = UAVObjLoadFromFile(&file); + if (loadedObj == 0) { + PIOS_FCLOSE(file); + xSemaphoreGiveRecursive(mutex); + return -1; + } + // Check that the IDs match + if (UAVObjGetID(loadedObj) != UAVObjGetID(obj_handle)) { + PIOS_FCLOSE(file); + xSemaphoreGiveRecursive(mutex); + return -1; + } + // Done, close file and unlock + PIOS_FCLOSE(file); + xSemaphoreGiveRecursive(mutex); #endif /* PIOS_INCLUDE_SDCARD */ - return 0; + return 0; } /** @@ -780,35 +987,32 @@ int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId) * @param[in] instId The object instance * @return 0 if success or -1 if failure */ -int32_t UAVObjDelete(UAVObjHandle obj, uint16_t instId) +int32_t UAVObjDelete(UAVObjHandle obj_handle, uint16_t instId) { + PIOS_Assert(obj_handle); #if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS) - PIOS_FLASHFS_ObjDelete(obj, instId); + PIOS_FLASHFS_ObjDelete(obj_handle, instId); #endif #if defined(PIOS_INCLUDE_SDCARD) - ObjectList *objEntry; - uint8_t filename[14]; + uint8_t filename[14]; - // Check for file system availability - if (PIOS_SDCARD_IsMounted() == 0) { - return -1; - } - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Check for file system availability + if (PIOS_SDCARD_IsMounted() == 0) { + return -1; + } + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Cast to object - objEntry = (ObjectList *) obj; + // Get filename + objectFilename(obj_handle, filename); - // Get filename - objectFilename(objEntry, filename); + // Delete file + PIOS_FUNLINK(filename); - // Delete file - PIOS_FUNLINK(filename); - - // Done - xSemaphoreGiveRecursive(mutex); + // Done + xSemaphoreGiveRecursive(mutex); #endif /* PIOS_INCLUDE_SDCARD */ - return 0; + return 0; } /** @@ -817,27 +1021,30 @@ int32_t UAVObjDelete(UAVObjHandle obj, uint16_t instId) */ int32_t UAVObjSaveSettings() { - ObjectList *objEntry; + struct UAVOData *obj; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Get lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Save all settings objects - LL_FOREACH(objList, objEntry) { - // Check if this is a settings object - if (OLGetIsSettings(objEntry)) { - // Save object - if (UAVObjSave((UAVObjHandle) objEntry, 0) == - -1) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - } + int32_t rc = -1; - // Done - xSemaphoreGiveRecursive(mutex); - return 0; + // Save all settings objects + LL_FOREACH(uavo_list, obj) { + // Check if this is a settings object + if (UAVObjIsSettings(obj)) { + // Save object + if (UAVObjSave((UAVObjHandle) obj, 0) == + -1) { + goto unlock_exit; + } + } + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -846,27 +1053,30 @@ int32_t UAVObjSaveSettings() */ int32_t UAVObjLoadSettings() { - ObjectList *objEntry; + struct UAVOData *obj; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Get lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Load all settings objects - LL_FOREACH(objList, objEntry) { - // Check if this is a settings object - if (OLGetIsSettings(objEntry)) { - // Load object - if (UAVObjLoad((UAVObjHandle) objEntry, 0) == - -1) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - } + int32_t rc = -1; - // Done - xSemaphoreGiveRecursive(mutex); - return 0; + // Load all settings objects + LL_FOREACH(uavo_list, obj) { + // Check if this is a settings object + if (UAVObjIsSettings(obj)) { + // Load object + if (UAVObjLoad((UAVObjHandle) obj, 0) == + -1) { + goto unlock_exit; + } + } + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -875,27 +1085,30 @@ int32_t UAVObjLoadSettings() */ int32_t UAVObjDeleteSettings() { - ObjectList *objEntry; + struct UAVOData *obj; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Get lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Save all settings objects - LL_FOREACH(objList, objEntry) { - // Check if this is a settings object - if (OLGetIsSettings(objEntry)) { - // Save object - if (UAVObjDelete((UAVObjHandle) objEntry, 0) - == -1) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - } + int32_t rc = -1; - // Done - xSemaphoreGiveRecursive(mutex); - return 0; + // Save all settings objects + LL_FOREACH(uavo_list, obj) { + // Check if this is a settings object + if (UAVObjIsSettings(obj)) { + // Save object + if (UAVObjDelete((UAVObjHandle) obj, 0) + == -1) { + goto unlock_exit; + } + } + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -904,27 +1117,27 @@ int32_t UAVObjDeleteSettings() */ int32_t UAVObjSaveMetaobjects() { - ObjectList *objEntry; + struct UAVOData *obj; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Get lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Save all settings objects - LL_FOREACH(objList, objEntry) { - // Check if this is a settings object - if (OLGetIsMetaobject(objEntry)) { - // Save object - if (UAVObjSave((UAVObjHandle) objEntry, 0) == - -1) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - } + int32_t rc = -1; - // Done - xSemaphoreGiveRecursive(mutex); - return 0; + // Save all settings objects + LL_FOREACH(uavo_list, obj) { + // Save object + if (UAVObjSave( (UAVObjHandle) MetaObjectPtr(obj), 0) == + -1) { + goto unlock_exit; + } + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -933,27 +1146,27 @@ int32_t UAVObjSaveMetaobjects() */ int32_t UAVObjLoadMetaobjects() { - ObjectList *objEntry; + struct UAVOData *obj; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Get lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Load all settings objects - LL_FOREACH(objList, objEntry) { - // Check if this is a settings object - if (OLGetIsMetaobject(objEntry)) { - // Load object - if (UAVObjLoad((UAVObjHandle) objEntry, 0) == - -1) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - } + int32_t rc = -1; - // Done - xSemaphoreGiveRecursive(mutex); - return 0; + // Load all settings objects + LL_FOREACH(uavo_list, obj) { + // Load object + if (UAVObjLoad((UAVObjHandle) MetaObjectPtr(obj), 0) == + -1) { + goto unlock_exit; + } + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -962,253 +1175,293 @@ int32_t UAVObjLoadMetaobjects() */ int32_t UAVObjDeleteMetaobjects() { - ObjectList *objEntry; + struct UAVOData *obj; - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Load all settings objects - LL_FOREACH(objList, objEntry) { - // Check if this is a settings object - if (OLGetIsMetaobject(objEntry)) { - // Load object - if (UAVObjDelete((UAVObjHandle) objEntry, 0) - == -1) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - } - - // Done - xSemaphoreGiveRecursive(mutex); - return 0; -} - -/** - * Set the object data - * \param[in] obj The object handle - * \param[in] dataIn The object's data structure - * \return 0 if success or -1 if failure - */ -int32_t UAVObjSetData(UAVObjHandle obj, const void *dataIn) -{ - return UAVObjSetInstanceData(obj, 0, dataIn); -} - -/** - * Set the object data - * \param[in] obj The object handle - * \param[in] dataIn The object's data structure - * \return 0 if success or -1 if failure - */ -int32_t UAVObjSetDataField(UAVObjHandle obj, const void* dataIn, uint32_t offset, uint32_t size) -{ - return UAVObjSetInstanceDataField(obj, 0, dataIn, offset, size); -} - -/** - * Get the object data - * \param[in] obj The object handle - * \param[out] dataOut The object's data structure - * \return 0 if success or -1 if failure - */ -int32_t UAVObjGetData(UAVObjHandle obj, void *dataOut) -{ - return UAVObjGetInstanceData(obj, 0, dataOut); -} - -/** - * Get the object data - * \param[in] obj The object handle - * \param[out] dataOut The object's data structure - * \return 0 if success or -1 if failure - */ -int32_t UAVObjGetDataField(UAVObjHandle obj, void* dataOut, uint32_t offset, uint32_t size) -{ - return UAVObjGetInstanceDataField(obj, 0, dataOut, offset, size); -} - -/** - * Set the data of a specific object instance - * \param[in] obj The object handle - * \param[in] instId The object instance ID - * \param[in] dataIn The object's data structure - * \return 0 if success or -1 if failure - */ -int32_t UAVObjSetInstanceData(UAVObjHandle obj, uint16_t instId, - const void *dataIn) -{ - ObjectList *objEntry; - ObjectInstList *instEntry; - UAVObjMetadata *mdata; - - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Cast to object info - objEntry = (ObjectList *) obj; - - // Check access level - if (!OLGetIsMetaobject(objEntry)) { - mdata = - (UAVObjMetadata *) (objEntry->linkedObj->instances. - data); - if (UAVObjGetAccess(mdata) == ACCESS_READONLY) { - xSemaphoreGiveRecursive(mutex); - return -1; - } - } - // Get instance information - instEntry = getInstance(objEntry, instId); - if (instEntry == NULL) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Set data - memcpy(instEntry->data, dataIn, objEntry->numBytes); - - // Fire event - sendEvent(objEntry, instId, EV_UPDATED); - - // Unlock - xSemaphoreGiveRecursive(mutex); - return 0; -} - -/** - * Set the data of a specific object instance - * \param[in] obj The object handle - * \param[in] instId The object instance ID - * \param[in] dataIn The object's data structure - * \return 0 if success or -1 if failure - */ -int32_t UAVObjSetInstanceDataField(UAVObjHandle obj, uint16_t instId, const void* dataIn, uint32_t offset, uint32_t size) -{ - ObjectList* objEntry; - ObjectInstList* instEntry; - UAVObjMetadata* mdata; - - // Lock + // Get lock xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Cast to object info - objEntry = (ObjectList*)obj; + int32_t rc = -1; - // Check access level - if ( !OLGetIsMetaobject(objEntry) ) - { - mdata = (UAVObjMetadata*)(objEntry->linkedObj->instances.data); - if ( UAVObjGetAccess(mdata) == ACCESS_READONLY ) - { - xSemaphoreGiveRecursive(mutex); - return -1; + // Load all settings objects + LL_FOREACH(uavo_list, obj) { + // Load object + if (UAVObjDelete((UAVObjHandle) MetaObjectPtr(obj), 0) + == -1) { + goto unlock_exit; } } - // Get instance information - instEntry = getInstance(objEntry, instId); - if ( instEntry == NULL ) - { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } + rc = 0; - // return if we set too much of what we have - if ( (size + offset) > objEntry->numBytes) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - - // Set data - memcpy(instEntry->data + offset, dataIn, size); - - // Fire event - sendEvent(objEntry, instId, EV_UPDATED); - - // Unlock +unlock_exit: xSemaphoreGiveRecursive(mutex); - return 0; + return rc; } /** - * Get the data of a specific object instance + * Set the object data * \param[in] obj The object handle - * \param[in] instId The object instance ID - * \param[out] dataOut The object's data structure + * \param[in] dataIn The object's data structure * \return 0 if success or -1 if failure */ -int32_t UAVObjGetInstanceData(UAVObjHandle obj, uint16_t instId, - void *dataOut) +int32_t UAVObjSetData(UAVObjHandle obj_handle, const void *dataIn) { - ObjectList *objEntry; - ObjectInstList *instEntry; - - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - - // Cast to object info - objEntry = (ObjectList *) obj; - - // Get instance information - instEntry = getInstance(objEntry, instId); - if (instEntry == NULL) { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - // Set data - memcpy(dataOut, instEntry->data, objEntry->numBytes); - - // Unlock - xSemaphoreGiveRecursive(mutex); - return 0; + return UAVObjSetInstanceData(obj_handle, 0, dataIn); } /** - * Get the data of a specific object instance + * Set the object data + * \param[in] obj The object handle + * \param[in] dataIn The object's data structure + * \return 0 if success or -1 if failure + */ +int32_t UAVObjSetDataField(UAVObjHandle obj_handle, const void* dataIn, uint32_t offset, uint32_t size) +{ + return UAVObjSetInstanceDataField(obj_handle, 0, dataIn, offset, size); +} + +/** + * Get the object data * \param[in] obj The object handle - * \param[in] instId The object instance ID * \param[out] dataOut The object's data structure * \return 0 if success or -1 if failure */ -int32_t UAVObjGetInstanceDataField(UAVObjHandle obj, uint16_t instId, void* dataOut, uint32_t offset, uint32_t size) +int32_t UAVObjGetData(UAVObjHandle obj_handle, void *dataOut) { - ObjectList* objEntry; - ObjectInstList* instEntry; + return UAVObjGetInstanceData(obj_handle, 0, dataOut); +} + +/** + * Get the object data + * \param[in] obj The object handle + * \param[out] dataOut The object's data structure + * \return 0 if success or -1 if failure + */ +int32_t UAVObjGetDataField(UAVObjHandle obj_handle, void* dataOut, uint32_t offset, uint32_t size) +{ + return UAVObjGetInstanceDataField(obj_handle, 0, dataOut, offset, size); +} + +/** + * Set the data of a specific object instance + * \param[in] obj The object handle + * \param[in] instId The object instance ID + * \param[in] dataIn The object's data structure + * \return 0 if success or -1 if failure + */ +int32_t UAVObjSetInstanceData(UAVObjHandle obj_handle, uint16_t instId, + const void *dataIn) +{ + PIOS_Assert(obj_handle); // Lock xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Cast to object info - objEntry = (ObjectList*)obj; + int32_t rc = -1; - // Get instance information - instEntry = getInstance(objEntry, instId); - if ( instEntry == NULL ) - { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; + if (UAVObjIsMetaobject(obj_handle)) { + if (instId != 0) { + goto unlock_exit; + } + memcpy(MetaDataPtr((struct UAVOMeta *)obj_handle), dataIn, MetaNumBytes); + } else { + struct UAVOData *obj; + InstanceHandle instEntry; + + // Cast to object info + obj = (struct UAVOData *) obj_handle; + + // Check access level + if (UAVObjReadOnly(obj_handle)) { + goto unlock_exit; + } + // Get instance information + instEntry = getInstance(obj, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + // Set data + memcpy(InstanceData(instEntry), dataIn, obj->instance_size); } - // return if we request too much of what we can give - if ( (size + offset) > objEntry->numBytes) - { - // Error, unlock and return - xSemaphoreGiveRecursive(mutex); - return -1; - } - - // Set data - memcpy(dataOut, instEntry->data + offset, size); + // Fire event + sendEvent((struct UAVOBase *)obj_handle, instId, EV_UPDATED); + rc = 0; - // Unlock +unlock_exit: xSemaphoreGiveRecursive(mutex); - return 0; + return rc; +} + +/** + * Set the data of a specific object instance + * \param[in] obj The object handle + * \param[in] instId The object instance ID + * \param[in] dataIn The object's data structure + * \return 0 if success or -1 if failure + */ +int32_t UAVObjSetInstanceDataField(UAVObjHandle obj_handle, uint16_t instId, const void* dataIn, uint32_t offset, uint32_t size) +{ + PIOS_Assert(obj_handle); + + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + + int32_t rc = -1; + + if (UAVObjIsMetaobject(obj_handle)) { + // Get instance information + if (instId != 0) { + goto unlock_exit; + } + + // Check for overrun + if ((size + offset) > MetaNumBytes) { + goto unlock_exit; + } + + // Set data + memcpy(MetaDataPtr((struct UAVOMeta *)obj_handle) + offset, dataIn, size); + } else { + struct UAVOData * obj; + InstanceHandle instEntry; + + // Cast to object info + obj = (struct UAVOData *)obj_handle; + + // Check access level + if (UAVObjReadOnly(obj_handle)) { + goto unlock_exit; + } + + // Get instance information + instEntry = getInstance(obj, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + + // Check for overrun + if ((size + offset) > obj->instance_size) { + goto unlock_exit; + } + + // Set data + memcpy(InstanceData(instEntry) + offset, dataIn, size); + } + + + // Fire event + sendEvent((struct UAVOBase *)obj_handle, instId, EV_UPDATED); + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; +} + +/** + * Get the data of a specific object instance + * \param[in] obj The object handle + * \param[in] instId The object instance ID + * \param[out] dataOut The object's data structure + * \return 0 if success or -1 if failure + */ +int32_t UAVObjGetInstanceData(UAVObjHandle obj_handle, uint16_t instId, + void *dataOut) +{ + PIOS_Assert(obj_handle); + + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + + int32_t rc = -1; + + if (UAVObjIsMetaobject(obj_handle)) { + // Get instance information + if (instId != 0) { + goto unlock_exit; + } + // Set data + memcpy(dataOut, MetaDataPtr((struct UAVOMeta *)obj_handle), MetaNumBytes); + } else { + struct UAVOData *obj; + InstanceHandle instEntry; + + // Cast to object info + obj = (struct UAVOData *) obj_handle; + + // Get instance information + instEntry = getInstance(obj, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + // Set data + memcpy(dataOut, InstanceData(instEntry), obj->instance_size); + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; +} + +/** + * Get the data of a specific object instance + * \param[in] obj The object handle + * \param[in] instId The object instance ID + * \param[out] dataOut The object's data structure + * \return 0 if success or -1 if failure + */ +int32_t UAVObjGetInstanceDataField(UAVObjHandle obj_handle, uint16_t instId, void* dataOut, uint32_t offset, uint32_t size) +{ + PIOS_Assert(obj_handle); + + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + + int32_t rc = -1; + + if (UAVObjIsMetaobject(obj_handle)) { + // Get instance information + if (instId != 0) { + goto unlock_exit; + } + + // Check for overrun + if ((size + offset) > MetaNumBytes) { + goto unlock_exit; + } + + // Set data + memcpy(dataOut, MetaDataPtr((struct UAVOMeta *)obj_handle) + offset, size); + } else { + struct UAVOData * obj; + InstanceHandle instEntry; + + // Cast to object info + obj = (struct UAVOData *)obj_handle; + + // Get instance information + instEntry = getInstance(obj, instId); + if (instEntry == NULL) { + goto unlock_exit; + } + + // Check for overrun + if ((size + offset) > obj->instance_size) { + goto unlock_exit; + } + + // Set data + memcpy(dataOut, InstanceData(instEntry) + offset, size); + } + + rc = 0; + +unlock_exit: + xSemaphoreGiveRecursive(mutex); + return rc; } /** @@ -1217,25 +1470,21 @@ int32_t UAVObjGetInstanceDataField(UAVObjHandle obj, uint16_t instId, void* data * \param[in] dataIn The object's metadata structure * \return 0 if success or -1 if failure */ -int32_t UAVObjSetMetadata(UAVObjHandle obj, const UAVObjMetadata * dataIn) +int32_t UAVObjSetMetadata(UAVObjHandle obj_handle, const UAVObjMetadata * dataIn) { - ObjectList *objEntry; + PIOS_Assert(obj_handle); - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Set metadata (metadata of metaobjects can not be modified) + if (UAVObjIsMetaobject(obj_handle)) { + return -1; + } - // Set metadata (metadata of metaobjects can not be modified) - objEntry = (ObjectList *) obj; - if (!OLGetIsMetaobject(objEntry)) { - UAVObjSetData((UAVObjHandle) objEntry->linkedObj, - dataIn); - } else { - return -1; - } + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Unlock - xSemaphoreGiveRecursive(mutex); - return 0; + UAVObjSetData((UAVObjHandle) MetaObjectPtr((struct UAVOData *)obj_handle), dataIn); + + xSemaphoreGiveRecursive(mutex); + return 0; } /** @@ -1244,44 +1493,29 @@ int32_t UAVObjSetMetadata(UAVObjHandle obj, const UAVObjMetadata * dataIn) * \param[out] dataOut The object's metadata structure * \return 0 if success or -1 if failure */ -int32_t UAVObjGetMetadata(UAVObjHandle obj, UAVObjMetadata * dataOut) +int32_t UAVObjGetMetadata(UAVObjHandle obj_handle, UAVObjMetadata * dataOut) { - ObjectList *objEntry; + PIOS_Assert(obj_handle); - // Lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Get metadata - objEntry = (ObjectList *) obj; - if (OLGetIsMetaobject(objEntry)) { - memcpy(dataOut, &defMetadata, sizeof(UAVObjMetadata)); - } else { - UAVObjGetData((UAVObjHandle) objEntry->linkedObj, - dataOut); - } + // Get metadata + if (UAVObjIsMetaobject(obj_handle)) { + memcpy(dataOut, &defMetadata, sizeof(UAVObjMetadata)); + } else { + UAVObjGetData((UAVObjHandle) MetaObjectPtr( (struct UAVOData *)obj_handle ), + dataOut); + } - // Unlock - xSemaphoreGiveRecursive(mutex); - return 0; + // Unlock + xSemaphoreGiveRecursive(mutex); + return 0; } -/** - * Initialize a UAVObjMetadata object. - * \param[in] metadata The metadata object - */ -void UAVObjMetadataInitialize(UAVObjMetadata* metadata) -{ - metadata->flags = - ACCESS_READWRITE << UAVOBJ_ACCESS_SHIFT | - ACCESS_READWRITE << UAVOBJ_GCS_ACCESS_SHIFT | - 1 << UAVOBJ_TELEMETRY_ACKED_SHIFT | - 1 << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | - UPDATEMODE_ONCHANGE << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | - UPDATEMODE_ONCHANGE << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; - metadata->telemetryUpdatePeriod = 0; - metadata->gcsTelemetryUpdatePeriod = 0; - metadata->loggingUpdatePeriod = 0; -} +/******************************* + * Object Metadata Manipulation + ******************************/ /** * Get the UAVObject metadata access member @@ -1290,6 +1524,7 @@ void UAVObjMetadataInitialize(UAVObjMetadata* metadata) */ UAVObjAccessType UAVObjGetAccess(const UAVObjMetadata* metadata) { + PIOS_Assert(metadata); return (metadata->flags >> UAVOBJ_ACCESS_SHIFT) & 1; } @@ -1300,6 +1535,7 @@ UAVObjAccessType UAVObjGetAccess(const UAVObjMetadata* metadata) */ void UAVObjSetAccess(UAVObjMetadata* metadata, UAVObjAccessType mode) { + PIOS_Assert(metadata); SET_BITS(metadata->flags, UAVOBJ_ACCESS_SHIFT, mode, 1); } @@ -1310,6 +1546,7 @@ void UAVObjSetAccess(UAVObjMetadata* metadata, UAVObjAccessType mode) */ UAVObjAccessType UAVObjGetGcsAccess(const UAVObjMetadata* metadata) { + PIOS_Assert(metadata); return (metadata->flags >> UAVOBJ_GCS_ACCESS_SHIFT) & 1; } @@ -1319,6 +1556,7 @@ UAVObjAccessType UAVObjGetGcsAccess(const UAVObjMetadata* metadata) * \param[in] mode The access mode */ void UAVObjSetGcsAccess(UAVObjMetadata* metadata, UAVObjAccessType mode) { + PIOS_Assert(metadata); SET_BITS(metadata->flags, UAVOBJ_GCS_ACCESS_SHIFT, mode, 1); } @@ -1328,6 +1566,7 @@ void UAVObjSetGcsAccess(UAVObjMetadata* metadata, UAVObjAccessType mode) { * \return the telemetry acked boolean */ uint8_t UAVObjGetTelemetryAcked(const UAVObjMetadata* metadata) { + PIOS_Assert(metadata); return (metadata->flags >> UAVOBJ_TELEMETRY_ACKED_SHIFT) & 1; } @@ -1337,6 +1576,7 @@ uint8_t UAVObjGetTelemetryAcked(const UAVObjMetadata* metadata) { * \param[in] val The telemetry acked boolean */ void UAVObjSetTelemetryAcked(UAVObjMetadata* metadata, uint8_t val) { + PIOS_Assert(metadata); SET_BITS(metadata->flags, UAVOBJ_TELEMETRY_ACKED_SHIFT, val, 1); } @@ -1346,6 +1586,7 @@ void UAVObjSetTelemetryAcked(UAVObjMetadata* metadata, uint8_t val) { * \return the telemetry acked boolean */ uint8_t UAVObjGetGcsTelemetryAcked(const UAVObjMetadata* metadata) { + PIOS_Assert(metadata); return (metadata->flags >> UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT) & 1; } @@ -1355,6 +1596,7 @@ uint8_t UAVObjGetGcsTelemetryAcked(const UAVObjMetadata* metadata) { * \param[in] val The GCS telemetry acked boolean */ void UAVObjSetGcsTelemetryAcked(UAVObjMetadata* metadata, uint8_t val) { + PIOS_Assert(metadata); SET_BITS(metadata->flags, UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT, val, 1); } @@ -1364,6 +1606,7 @@ void UAVObjSetGcsTelemetryAcked(UAVObjMetadata* metadata, uint8_t val) { * \return the telemetry update mode */ UAVObjUpdateMode UAVObjGetTelemetryUpdateMode(const UAVObjMetadata* metadata) { + PIOS_Assert(metadata); return (metadata->flags >> UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT) & UAVOBJ_UPDATE_MODE_MASK; } @@ -1373,6 +1616,7 @@ UAVObjUpdateMode UAVObjGetTelemetryUpdateMode(const UAVObjMetadata* metadata) { * \param[in] val The telemetry update mode */ void UAVObjSetTelemetryUpdateMode(UAVObjMetadata* metadata, UAVObjUpdateMode val) { + PIOS_Assert(metadata); SET_BITS(metadata->flags, UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT, val, UAVOBJ_UPDATE_MODE_MASK); } @@ -1382,6 +1626,7 @@ void UAVObjSetTelemetryUpdateMode(UAVObjMetadata* metadata, UAVObjUpdateMode val * \return the GCS telemetry update mode */ UAVObjUpdateMode UAVObjGetGcsTelemetryUpdateMode(const UAVObjMetadata* metadata) { + PIOS_Assert(metadata); return (metadata->flags >> UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT) & UAVOBJ_UPDATE_MODE_MASK; } @@ -1391,6 +1636,7 @@ UAVObjUpdateMode UAVObjGetGcsTelemetryUpdateMode(const UAVObjMetadata* metadata) * \param[in] val The GCS telemetry update mode */ void UAVObjSetGcsTelemetryUpdateMode(UAVObjMetadata* metadata, UAVObjUpdateMode val) { + PIOS_Assert(metadata); SET_BITS(metadata->flags, UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT, val, UAVOBJ_UPDATE_MODE_MASK); } @@ -1403,22 +1649,13 @@ void UAVObjSetGcsTelemetryUpdateMode(UAVObjMetadata* metadata, UAVObjUpdateMode * \arg 1 if read only * \arg -1 if unable to get meta data */ -int8_t UAVObjReadOnly(UAVObjHandle obj) +int8_t UAVObjReadOnly(UAVObjHandle obj_handle) { - ObjectList *objEntry; - UAVObjMetadata *mdata; - - // Cast to object info - objEntry = (ObjectList *) obj; - - // Check access level - if (!OLGetIsMetaobject(objEntry)) { - mdata = - (UAVObjMetadata *) (objEntry->linkedObj->instances. - data); - return UAVObjGetAccess(mdata) == ACCESS_READONLY; - } - return -1; + PIOS_Assert(obj_handle); + if (!UAVObjIsMetaobject(obj_handle)) { + return UAVObjGetAccess(LinkedMetaDataPtr( (struct UAVOData *)obj_handle)) == ACCESS_READONLY; + } + return -1; } /** @@ -1429,14 +1666,16 @@ int8_t UAVObjReadOnly(UAVObjHandle obj) * \param[in] eventMask The event mask, if EV_MASK_ALL then all events are enabled (e.g. EV_UPDATED | EV_UPDATED_MANUAL) * \return 0 if success or -1 if failure */ -int32_t UAVObjConnectQueue(UAVObjHandle obj, xQueueHandle queue, - uint8_t eventMask) +int32_t UAVObjConnectQueue(UAVObjHandle obj_handle, xQueueHandle queue, + uint8_t eventMask) { - int32_t res; - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - res = connectObj(obj, queue, 0, eventMask); - xSemaphoreGiveRecursive(mutex); - return res; + PIOS_Assert(obj_handle); + PIOS_Assert(queue); + int32_t res; + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + res = connectObj(obj_handle, queue, 0, eventMask); + xSemaphoreGiveRecursive(mutex); + return res; } /** @@ -1445,13 +1684,15 @@ int32_t UAVObjConnectQueue(UAVObjHandle obj, xQueueHandle queue, * \param[in] queue The event queue * \return 0 if success or -1 if failure */ -int32_t UAVObjDisconnectQueue(UAVObjHandle obj, xQueueHandle queue) +int32_t UAVObjDisconnectQueue(UAVObjHandle obj_handle, xQueueHandle queue) { - int32_t res; - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - res = disconnectObj(obj, queue, 0); - xSemaphoreGiveRecursive(mutex); - return res; + PIOS_Assert(obj_handle); + PIOS_Assert(queue); + int32_t res; + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + res = disconnectObj(obj_handle, queue, 0); + xSemaphoreGiveRecursive(mutex); + return res; } /** @@ -1462,14 +1703,15 @@ int32_t UAVObjDisconnectQueue(UAVObjHandle obj, xQueueHandle queue) * \param[in] eventMask The event mask, if EV_MASK_ALL then all events are enabled (e.g. EV_UPDATED | EV_UPDATED_MANUAL) * \return 0 if success or -1 if failure */ -int32_t UAVObjConnectCallback(UAVObjHandle obj, UAVObjEventCallback cb, - uint8_t eventMask) +int32_t UAVObjConnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb, + uint8_t eventMask) { - int32_t res; - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - res = connectObj(obj, 0, cb, eventMask); - xSemaphoreGiveRecursive(mutex); - return res; + PIOS_Assert(obj_handle); + int32_t res; + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + res = connectObj(obj_handle, 0, cb, eventMask); + xSemaphoreGiveRecursive(mutex); + return res; } /** @@ -1478,13 +1720,14 @@ int32_t UAVObjConnectCallback(UAVObjHandle obj, UAVObjEventCallback cb, * \param[in] cb The event callback * \return 0 if success or -1 if failure */ -int32_t UAVObjDisconnectCallback(UAVObjHandle obj, UAVObjEventCallback cb) +int32_t UAVObjDisconnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb) { - int32_t res; - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - res = disconnectObj(obj, 0, cb); - xSemaphoreGiveRecursive(mutex); - return res; + PIOS_Assert(obj_handle); + int32_t res; + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + res = disconnectObj(obj_handle, 0, cb); + xSemaphoreGiveRecursive(mutex); + return res; } /** @@ -1492,9 +1735,9 @@ int32_t UAVObjDisconnectCallback(UAVObjHandle obj, UAVObjEventCallback cb) * will be generated as soon as the object is updated. * \param[in] obj The object handle */ -void UAVObjRequestUpdate(UAVObjHandle obj) +void UAVObjRequestUpdate(UAVObjHandle obj_handle) { - UAVObjRequestInstanceUpdate(obj, UAVOBJ_ALL_INSTANCES); + UAVObjRequestInstanceUpdate(obj_handle, UAVOBJ_ALL_INSTANCES); } /** @@ -1503,20 +1746,21 @@ void UAVObjRequestUpdate(UAVObjHandle obj) * \param[in] obj The object handle * \param[in] instId Object instance ID to update */ -void UAVObjRequestInstanceUpdate(UAVObjHandle obj, uint16_t instId) +void UAVObjRequestInstanceUpdate(UAVObjHandle obj_handle, uint16_t instId) { - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - sendEvent((ObjectList *) obj, instId, EV_UPDATE_REQ); - xSemaphoreGiveRecursive(mutex); + PIOS_Assert(obj_handle); + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + sendEvent((struct UAVOBase *) obj_handle, instId, EV_UPDATE_REQ); + xSemaphoreGiveRecursive(mutex); } /** * Send the object's data to the GCS (triggers a EV_UPDATED_MANUAL event on this object). * \param[in] obj The object handle */ -void UAVObjUpdated(UAVObjHandle obj) +void UAVObjUpdated(UAVObjHandle obj_handle) { - UAVObjInstanceUpdated(obj, UAVOBJ_ALL_INSTANCES); + UAVObjInstanceUpdated(obj_handle, UAVOBJ_ALL_INSTANCES); } /** @@ -1524,11 +1768,12 @@ void UAVObjUpdated(UAVObjHandle obj) * \param[in] obj The object handle * \param[in] instId The object instance ID */ -void UAVObjInstanceUpdated(UAVObjHandle obj, uint16_t instId) +void UAVObjInstanceUpdated(UAVObjHandle obj_handle, uint16_t instId) { - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - sendEvent((ObjectList *) obj, instId, EV_UPDATED_MANUAL); - xSemaphoreGiveRecursive(mutex); + PIOS_Assert(obj_handle); + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + sendEvent((struct UAVOBase *) obj_handle, instId, EV_UPDATED_MANUAL); + xSemaphoreGiveRecursive(mutex); } /** @@ -1538,133 +1783,152 @@ void UAVObjInstanceUpdated(UAVObjHandle obj, uint16_t instId) */ void UAVObjIterate(void (*iterator) (UAVObjHandle obj)) { - ObjectList *objEntry; + PIOS_Assert(iterator); - // Get lock - xSemaphoreTakeRecursive(mutex, portMAX_DELAY); + // Get lock + xSemaphoreTakeRecursive(mutex, portMAX_DELAY); - // Iterate through the list and invoke iterator for each object - LL_FOREACH(objList, objEntry) { - (*iterator) ((UAVObjHandle) objEntry); - } + // Iterate through the list and invoke iterator for each object + struct UAVOData *obj; + LL_FOREACH(uavo_list, obj) { + (*iterator) ((UAVObjHandle) obj); + (*iterator) ((UAVObjHandle) &obj->metaObj); + } - // Release lock - xSemaphoreGiveRecursive(mutex); + // Release lock + xSemaphoreGiveRecursive(mutex); } /** - * Send an event to all event queues registered on the object. + * Send a triggered event to all event queues registered on the object. */ -static int32_t sendEvent(ObjectList * obj, uint16_t instId, - UAVObjEventType event) +static int32_t sendEvent(struct UAVOBase * obj, uint16_t instId, + UAVObjEventType triggered_event) { - ObjectEventList *eventEntry; - UAVObjEvent msg; + /* Set up the message that will be sent to all registered listeners */ + UAVObjEvent msg = { + .obj = (UAVObjHandle) obj, + .event = triggered_event, + .instId = instId, + }; - // Setup event - msg.obj = (UAVObjHandle) obj; - msg.event = event; - msg.instId = instId; + // Go through each object and push the event message in the queue (if event is activated for the queue) + struct ObjectEventEntry *event; + LL_FOREACH(obj->next_event, event) { + if (event->eventMask == 0 + || (event->eventMask & triggered_event) != 0) { + // Send to queue if a valid queue is registered + if (event->queue) { + // will not block + if (xQueueSend(event->queue, &msg, 0) != pdTRUE) { + stats.lastQueueErrorID = UAVObjGetID(obj); + ++stats.eventQueueErrors; + } + } - // Go through each object and push the event message in the queue (if event is activated for the queue) - LL_FOREACH(obj->events, eventEntry) { - if (eventEntry->eventMask == 0 - || (eventEntry->eventMask & event) != 0) { - // Send to queue if a valid queue is registered - if (eventEntry->queue != 0) { - if (xQueueSend(eventEntry->queue, &msg, 0) != pdTRUE) // will not block - { - stats.lastQueueErrorID = UAVObjGetID(obj); - ++stats.eventQueueErrors; - } - } - // Invoke callback (from event task) if a valid one is registered - if (eventEntry->cb != 0) { - if (EventCallbackDispatch(&msg, eventEntry->cb) != pdTRUE) // invoke callback from the event task, will not block - { - ++stats.eventCallbackErrors; - stats.lastCallbackErrorID = UAVObjGetID(obj); - } - } - } - } + // Invoke callback (from event task) if a valid one is registered + if (event->cb) { + // invoke callback from the event task, will not block + if (EventCallbackDispatch(&msg, event->cb) != pdTRUE) { + ++stats.eventCallbackErrors; + stats.lastCallbackErrorID = UAVObjGetID(obj); + } + } + } + } - // Done - return 0; + return 0; } /** * Create a new object instance, return the instance info or NULL if failure. */ -static ObjectInstList *createInstance(ObjectList * obj, uint16_t instId) +static InstanceHandle createInstance(struct UAVOData * obj, uint16_t instId) { - ObjectInstList *instEntry; - int32_t n; + struct UAVOMultiInst *instEntry; - // For single instance objects, only instance zero is allowed - if (OLGetIsSingleInstance(obj) && instId != 0) { - return NULL; - } - // Make sure that the instance ID is within limits - if (instId >= UAVOBJ_MAX_INSTANCES) { - return NULL; - } - // Check if the instance already exists - if (getInstance(obj, instId) != NULL) { - return NULL; - } - // Create any missing instances (all instance IDs must be sequential) - for (n = obj->numInstances; n < instId; ++n) { - if (createInstance(obj, n) == NULL) { - return NULL; - } - } + /* Don't allow more than one instance for single instance objects */ + if (UAVObjIsSingleInstance(&(obj->base))) { + PIOS_Assert(0); + return NULL; + } - if (instId == 0) { /* Instance 0 ObjectInstList allocated with ObjectList element */ - instEntry = &obj->instances; - instEntry->data = pvPortMalloc(obj->numBytes); - if (instEntry->data == NULL) - return NULL; - memset(instEntry->data, 0, obj->numBytes); - instEntry->instId = instId; - } else { - // Create the actual instance - instEntry = - (ObjectInstList *) - pvPortMalloc(sizeof(ObjectInstList)); - if (instEntry == NULL) - return NULL; - instEntry->data = pvPortMalloc(obj->numBytes); - if (instEntry->data == NULL) - return NULL; - memset(instEntry->data, 0, obj->numBytes); - instEntry->instId = instId; - LL_APPEND(obj->instances.next, instEntry); - } - ++obj->numInstances; + /* Don't create more than the allowed number of instances */ + if (instId >= UAVOBJ_MAX_INSTANCES) { + return NULL; + } - // Fire event - UAVObjInstanceUpdated((UAVObjHandle) obj, instId); + /* Don't allow duplicate instances */ + if (instId < UAVObjGetNumInstances(&(obj->base))) { + return NULL; + } - // Done - return instEntry; + // Create any missing instances (all instance IDs must be sequential) + for (uint16_t n = UAVObjGetNumInstances(&(obj->base)); n < instId; ++n) { + if (createInstance(obj, n) == NULL) { + return NULL; + } + } + + /* Create the actual instance */ + instEntry = (struct UAVOMultiInst *) pvPortMalloc(sizeof(struct UAVOMultiInst)+obj->instance_size); + if (!instEntry) + return NULL; + memset(InstanceDataOffset(instEntry), 0, obj->instance_size); + LL_APPEND(( (struct UAVOMulti*)obj )->instance0.next, instEntry); + + ( (struct UAVOMulti*)obj )->num_instances++; + + // Fire event + UAVObjInstanceUpdated((UAVObjHandle) obj, instId); + + // Done + return InstanceDataOffset(instEntry); } /** * Get the instance information or NULL if the instance does not exist */ -static ObjectInstList *getInstance(ObjectList * obj, uint16_t instId) +static InstanceHandle getInstance(struct UAVOData * obj, uint16_t instId) { - ObjectInstList *instEntry; + if (UAVObjIsMetaobject(&obj->base)) { + /* Metadata Instance */ - // Look for specified instance ID - LL_FOREACH(&(obj->instances), instEntry) { - if (instEntry->instId == instId) { - return instEntry; - } - } - // If this point is reached then instance id was not found - return NULL; + if (instId != 0) + return NULL; + + /* Augment our pointer to reflect the proper type */ + struct UAVOMeta * uavo_meta = (struct UAVOMeta *) obj; + return (&(uavo_meta->instance0)); + + } else if (UAVObjIsSingleInstance(&(obj->base))) { + /* Single Instance */ + + if (instId != 0) + return NULL; + + /* Augment our pointer to reflect the proper type */ + struct UAVOSingle * uavo_single = (struct UAVOSingle *) obj; + return (&(uavo_single->instance0)); + } else { + /* Multi Instance */ + /* Augment our pointer to reflect the proper type */ + struct UAVOMulti * uavo_multi = (struct UAVOMulti *) obj; + if (instId >= uavo_multi->num_instances) + return NULL; + + // Look for specified instance ID + uint16_t instance = 0; + struct UAVOMultiInst *instEntry; + LL_FOREACH(&(uavo_multi->instance0), instEntry) { + if (instance++ == instId) { + /* Found it */ + return &(instEntry->instance); + } + } + /* Instance was not found */ + return NULL; + } } /** @@ -1675,35 +1939,34 @@ static ObjectInstList *getInstance(ObjectList * obj, uint16_t instId) * \param[in] eventMask The event mask, if EV_MASK_ALL then all events are enabled (e.g. EV_UPDATED | EV_UPDATED_MANUAL) * \return 0 if success or -1 if failure */ -static int32_t connectObj(UAVObjHandle obj, xQueueHandle queue, - UAVObjEventCallback cb, uint8_t eventMask) +static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue, + UAVObjEventCallback cb, uint8_t eventMask) { - ObjectEventList *eventEntry; - ObjectList *objEntry; + struct ObjectEventEntry *event; + struct UAVOBase *obj; - // Check that the queue is not already connected, if it is simply update event mask - objEntry = (ObjectList *) obj; - LL_FOREACH(objEntry->events, eventEntry) { - if (eventEntry->queue == queue && eventEntry->cb == cb) { - // Already connected, update event mask and return - eventEntry->eventMask = eventMask; - return 0; - } - } + // Check that the queue is not already connected, if it is simply update event mask + obj = (struct UAVOBase *) obj_handle; + LL_FOREACH(obj->next_event, event) { + if (event->queue == queue && event->cb == cb) { + // Already connected, update event mask and return + event->eventMask = eventMask; + return 0; + } + } - // Add queue to list - eventEntry = - (ObjectEventList *) pvPortMalloc(sizeof(ObjectEventList)); - if (eventEntry == NULL) { - return -1; - } - eventEntry->queue = queue; - eventEntry->cb = cb; - eventEntry->eventMask = eventMask; - LL_APPEND(objEntry->events, eventEntry); + // Add queue to list + event = (struct ObjectEventEntry *) pvPortMalloc(sizeof(struct ObjectEventEntry)); + if (event == NULL) { + return -1; + } + event->queue = queue; + event->cb = cb; + event->eventMask = eventMask; + LL_APPEND(obj->next_event, event); - // Done - return 0; + // Done + return 0; } /** @@ -1713,25 +1976,25 @@ static int32_t connectObj(UAVObjHandle obj, xQueueHandle queue, * \param[in] cb The event callback * \return 0 if success or -1 if failure */ -static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, - UAVObjEventCallback cb) +static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue, + UAVObjEventCallback cb) { - ObjectEventList *eventEntry; - ObjectList *objEntry; + struct ObjectEventEntry *event; + struct UAVOBase *obj; - // Find queue and remove it - objEntry = (ObjectList *) obj; - LL_FOREACH(objEntry->events, eventEntry) { - if ((eventEntry->queue == queue - && eventEntry->cb == cb)) { - LL_DELETE(objEntry->events, eventEntry); - vPortFree(eventEntry); - return 0; - } - } + // Find queue and remove it + obj = (struct UAVOBase *) obj_handle; + LL_FOREACH(obj->next_event, event) { + if ((event->queue == queue + && event->cb == cb)) { + LL_DELETE(obj->next_event, event); + vPortFree(event); + return 0; + } + } - // If this point is reached the queue was not found - return -1; + // If this point is reached the queue was not found + return -1; } #if defined(PIOS_INCLUDE_SDCARD) @@ -1740,16 +2003,16 @@ static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, */ static void customSPrintf(uint8_t * buffer, uint8_t * format, ...) { - va_list args; - va_start(args, format); - vsprintf((char *)buffer, (char *)format, args); + va_list args; + va_start(args, format); + vsprintf((char *)buffer, (char *)format, args); } /** * Get an 8 character (plus extension) filename for the object. */ -static void objectFilename(ObjectList * obj, uint8_t * filename) +static void objectFilename(UAVObjHandle obj_handle, uint8_t * filename) { - customSPrintf(filename, (uint8_t *) "%X.obj", obj->id); + customSPrintf(filename, (uint8_t *) "%X.obj", UAVObjGetID(obj_handle)); } #endif /* PIOS_INCLUDE_SDCARD */ diff --git a/flight/UAVObjects/uavobjecttemplate.c b/flight/UAVObjects/uavobjecttemplate.c index ad37eef83..f8db8a024 100644 --- a/flight/UAVObjects/uavobjecttemplate.c +++ b/flight/UAVObjects/uavobjecttemplate.c @@ -54,7 +54,7 @@ int32_t $(NAME)Initialize(void) return -2; // Register object with the object manager - handle = UAVObjRegister($(NAMEUC)_OBJID, $(NAMEUC)_NAME, $(NAMEUC)_METANAME, 0, + handle = UAVObjRegister($(NAMEUC)_OBJID, $(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_NUMBYTES, &$(NAME)SetDefaults); // Done diff --git a/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg b/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg index 7667ecbb9..2ec58bd37 100644 --- a/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg +++ b/ground/openpilotgcs/share/openpilotgcs/diagrams/default/system-health.svg @@ -14,579 +14,12 @@ height="79.57505" id="svg3604" version="1.1" - inkscape:version="0.47pre4 r22446" - sodipodi:docname="system-health1.svg" + inkscape:version="0.48.2 r9819" + sodipodi:docname="system-health.svg" inkscape:export-filename="C:\NoBackup\OpenPilot\mainboard-health.png" inkscape:export-xdpi="269.53" inkscape:export-ydpi="269.53" style="display:inline"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + orientation="0,1" /> + orientation="0,1" /> + orientation="0,1" /> + orientation="0,1" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -637,756 +637,715 @@ + id="background" + inkscape:groupmode="layer" + inkscape:label="Background"> + x="497.92136" + height="79.063599" + width="93.746948" + id="Background" + style="fill:#453e3e;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.99921262;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + id="MainBoard" + style="font-size:13.40719509px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"> + d="m 524.3844,367.59399 1.32275,0 1.67432,4.46485 1.68311,-4.46485 1.32275,0 0,6.56104 -0.86572,0 0,-5.76123 -1.6919,4.5 -0.89209,0 -1.69189,-4.5 0,5.76123 -0.86133,0 0,-6.56104" /> + d="m 534.35559,371.68091 c -0.65332,0 -1.10596,0.0747 -1.35791,0.22412 -0.25195,0.14942 -0.37793,0.4043 -0.37793,0.76465 0,0.28711 0.0937,0.51562 0.28125,0.68554 0.19043,0.167 0.44824,0.25049 0.77344,0.25049 0.44824,0 0.80712,-0.1582 1.07666,-0.47461 0.27246,-0.31933 0.40869,-0.74267 0.40869,-1.27002 l 0,-0.18017 -0.8042,0 m 1.61279,-0.33399 0,2.80811 -0.80859,0 0,-0.74707 c -0.18457,0.29883 -0.41455,0.52002 -0.68994,0.66357 -0.27539,0.14063 -0.61231,0.21094 -1.01074,0.21094 -0.50391,0 -0.90528,-0.14062 -1.20411,-0.42187 -0.29589,-0.28418 -0.44384,-0.66358 -0.44384,-1.13819 0,-0.55371 0.18457,-0.97119 0.55371,-1.25244 0.37207,-0.28125 0.92578,-0.42187 1.66113,-0.42187 l 1.13379,0 0,-0.0791 c 0,-0.37206 -0.12305,-0.65917 -0.36914,-0.86132 -0.24317,-0.20508 -0.58594,-0.30762 -1.02832,-0.30762 -0.28125,0 -0.55518,0.0337 -0.82178,0.10107 -0.2666,0.0674 -0.52295,0.16846 -0.76904,0.30323 l 0,-0.74707 c 0.2959,-0.11426 0.58301,-0.19922 0.86133,-0.25489 0.27832,-0.0586 0.54931,-0.0879 0.81299,-0.0879 0.71191,10e-6 1.24364,0.18458 1.59521,0.55371 0.35156,0.36915 0.52734,0.92872 0.52734,1.67871" /> + d="m 537.63831,369.23315 0.80859,0 0,4.92188 -0.80859,0 0,-4.92188 m 0,-1.91601 0.80859,0 0,1.02392 -0.80859,0 0,-1.02392" /> + d="m 544.22571,371.18433 0,2.9707 -0.8086,0 0,-2.94434 c 0,-0.46581 -0.0908,-0.81445 -0.27246,-1.0459 -0.18164,-0.23144 -0.4541,-0.34716 -0.81738,-0.34716 -0.43653,0 -0.78076,0.13916 -1.03271,0.41748 -0.25196,0.27832 -0.37794,0.65772 -0.37793,1.13818 l 0,2.78174 -0.81299,0 0,-4.92188 0.81299,0 0,0.76465 c 0.19335,-0.29589 0.4204,-0.51708 0.68115,-0.66357 0.26367,-0.14648 0.56689,-0.21972 0.90967,-0.21973 0.56542,10e-6 0.99316,0.17579 1.2832,0.52735 0.29003,0.34863 0.43505,0.86279 0.43506,1.54248" /> + d="m 549.38049,371.69849 c 0,-0.59473 -0.12305,-1.06055 -0.36914,-1.39746 -0.24317,-0.33984 -0.57861,-0.50977 -1.00635,-0.50977 -0.42773,0 -0.76465,0.16993 -1.01074,0.50977 -0.24316,0.33691 -0.36475,0.80273 -0.36474,1.39746 -10e-6,0.59472 0.12158,1.06201 0.36474,1.40185 0.24609,0.33692 0.58301,0.50537 1.01074,0.50537 0.42774,0 0.76318,-0.16845 1.00635,-0.50537 0.24609,-0.33984 0.36914,-0.80713 0.36914,-1.40185 m -2.75097,-1.71827 c 0.16992,-0.29296 0.38378,-0.50976 0.6416,-0.65039 0.26074,-0.14355 0.57128,-0.21532 0.93164,-0.21533 0.59765,10e-6 1.08251,0.23731 1.45459,0.71192 0.37499,0.47461 0.56249,1.09863 0.5625,1.87207 -10e-6,0.77344 -0.18751,1.39746 -0.5625,1.87207 -0.37208,0.47461 -0.85694,0.71191 -1.45459,0.71191 -0.36036,0 -0.6709,-0.0703 -0.93164,-0.21094 -0.25782,-0.14355 -0.47168,-0.36181 -0.6416,-0.65478 l 0,0.73828 -0.81299,0 0,-6.83789 0.81299,0 0,2.66308" /> + d="m 553.46741,369.80005 c -0.4336,0 -0.77637,0.16992 -1.02832,0.50976 -0.25196,0.33692 -0.37793,0.79981 -0.37793,1.38868 0,0.58887 0.12451,1.05322 0.37353,1.39306 0.25195,0.33692 0.59619,0.50537 1.03272,0.50537 0.43066,0 0.77197,-0.16992 1.02392,-0.50976 0.25195,-0.33984 0.37793,-0.80273 0.37793,-1.38867 0,-0.58301 -0.12598,-1.04443 -0.37793,-1.38428 -0.25195,-0.34277 -0.59326,-0.51416 -1.02392,-0.51416 m 0,-0.68555 c 0.70312,10e-6 1.25536,0.22852 1.65674,0.68555 0.40136,0.45703 0.60204,1.08985 0.60205,1.89844 -10e-6,0.80566 -0.20069,1.43847 -0.60205,1.89843 -0.40138,0.45704 -0.95362,0.68555 -1.65674,0.68555 -0.70606,0 -1.25977,-0.22851 -1.66114,-0.68555 -0.39843,-0.45996 -0.59765,-1.09277 -0.59765,-1.89843 0,-0.80859 0.19922,-1.44141 0.59765,-1.89844 0.40137,-0.45703 0.95508,-0.68554 1.66114,-0.68555" /> + d="m 559.29895,371.68091 c -0.65332,0 -1.10596,0.0747 -1.35791,0.22412 -0.25195,0.14942 -0.37793,0.4043 -0.37793,0.76465 0,0.28711 0.0937,0.51562 0.28125,0.68554 0.19043,0.167 0.44824,0.25049 0.77344,0.25049 0.44824,0 0.80712,-0.1582 1.07666,-0.47461 0.27246,-0.31933 0.40869,-0.74267 0.40869,-1.27002 l 0,-0.18017 -0.8042,0 m 1.61279,-0.33399 0,2.80811 -0.80859,0 0,-0.74707 c -0.18457,0.29883 -0.41455,0.52002 -0.68994,0.66357 -0.2754,0.14063 -0.61231,0.21094 -1.01074,0.21094 -0.50391,0 -0.90528,-0.14062 -1.20411,-0.42187 -0.29589,-0.28418 -0.44384,-0.66358 -0.44384,-1.13819 0,-0.55371 0.18457,-0.97119 0.55371,-1.25244 0.37207,-0.28125 0.92578,-0.42187 1.66113,-0.42187 l 1.13379,0 0,-0.0791 c 0,-0.37206 -0.12305,-0.65917 -0.36914,-0.86132 -0.24317,-0.20508 -0.58594,-0.30762 -1.02832,-0.30762 -0.28125,0 -0.55518,0.0337 -0.82178,0.10107 -0.2666,0.0674 -0.52295,0.16846 -0.76904,0.30323 l 0,-0.74707 c 0.2959,-0.11426 0.583,-0.19922 0.86133,-0.25489 0.27831,-0.0586 0.54931,-0.0879 0.81298,-0.0879 0.71192,10e-6 1.24365,0.18458 1.59522,0.55371 0.35156,0.36915 0.52734,0.92872 0.52734,1.67871" /> + d="m 565.43372,369.98901 c -0.0908,-0.0527 -0.19044,-0.0908 -0.29883,-0.11425 -0.10547,-0.0264 -0.22266,-0.0395 -0.35156,-0.0395 -0.45704,0 -0.8086,0.14941 -1.05469,0.44824 -0.24317,0.2959 -0.36475,0.72217 -0.36475,1.27881 l 0,2.59277 -0.81299,0 0,-4.92188 0.81299,0 0,0.76465 c 0.16992,-0.29882 0.39111,-0.52001 0.66358,-0.66357 0.27245,-0.14648 0.60351,-0.21972 0.99316,-0.21973 0.0557,10e-6 0.11718,0.004 0.18457,0.0132 0.0674,0.006 0.14209,0.0161 0.22412,0.0308 l 0.004,0.83056" /> + d="m 569.37122,369.98022 0,-2.66308 0.80859,0 0,6.83789 -0.80859,0 0,-0.73828 c -0.16993,0.29297 -0.38526,0.51123 -0.646,0.65478 -0.25782,0.14063 -0.56836,0.21094 -0.93164,0.21094 -0.59473,0 -1.07959,-0.2373 -1.45459,-0.71191 -0.37207,-0.47461 -0.55811,-1.09863 -0.55811,-1.87207 0,-0.77344 0.18604,-1.39746 0.55811,-1.87207 0.375,-0.47461 0.85986,-0.71191 1.45459,-0.71192 0.36328,10e-6 0.67382,0.0718 0.93164,0.21533 0.26074,0.14063 0.47607,0.35743 0.646,0.65039 m -2.75538,1.71827 c 0,0.59472 0.12159,1.06201 0.36475,1.40185 0.24609,0.33692 0.58301,0.50537 1.01074,0.50537 0.42773,0 0.76465,-0.16845 1.01075,-0.50537 0.24608,-0.33984 0.36913,-0.80713 0.36914,-1.40185 -10e-6,-0.59473 -0.12306,-1.06055 -0.36914,-1.39746 -0.2461,-0.33984 -0.58302,-0.50977 -1.01075,-0.50977 -0.42773,0 -0.76465,0.16993 -1.01074,0.50977 -0.24316,0.33691 -0.36475,0.80273 -0.36475,1.39746" /> - + + width="13.893178" + height="56.637238" + x="576.71594" + y="365.44907" /> - + - - - - + height="8.2846708" + x="501.69357" + y="355.57822" /> + + + + + width="9.9426785" + height="14.938984" + x="514.80487" + y="407.0524" /> - - - + width="16.179909" + height="15.034504" + x="526.39636" + y="406.95688" /> - - + y="385.55762" /> - - - + y="385.55762" /> - - - - - - + + + + - - - - - + + + + - + - - - + + + + - - + id="layer20" + inkscape:groupmode="layer" /> - - + + + id="layer8" + inkscape:groupmode="layer"> + width="18.153212" + height="8.1216154" + x="38.05257" + y="41.277248" /> - - + + + + + + Flight Mode Switch Settings - - - - 310 - 30 - 201 - 17 - - - - - 75 - true - - - - for multirotors! - - 30 - 160 - 451 + 260 + 541 161 @@ -384,19 +365,6 @@ margin:1px; - - - - Qt::Vertical - - - - 20 - 20 - - - - @@ -414,25 +382,177 @@ margin:1px; + + + + Qt::Vertical + + + + 20 + 20 + + + + 30 - 30 - 451 - 121 + 20 + 541 + 211 FlightMode Switch Positions + + + false + + + + 100 + 140 + 151 + 26 + + + + Qt::StrongFocus + + + + + false + + + + 100 + 110 + 151 + 26 + + + + Qt::StrongFocus + + + Select the stabilization mode on this position (manual/stabilized/auto) + + + + + + 10 + 115 + 62 + 17 + + + + Pos. 4 + + + + + false + + + + 100 + 170 + 151 + 26 + + + + Qt::StrongFocus + + + + + + 10 + 145 + 62 + 17 + + + + Pos. 5 + + + + + + 10 + 175 + 62 + 17 + + + + Pos. 6 + + + + + false + + + + 70 + 28 + 20 + 160 + + + + Qt::StrongFocus + + + This slider moves when you move the flight mode switch +on your remote. It shows currently active flight mode. + +Setup the flight mode channel on the RC Input tab if you have not done so already. + + + 0 + + + 5 + + + 10 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBelow + + + 1 + + 100 - 55 + 50 151 26 @@ -445,7 +565,20 @@ margin:1px; 100 - 25 + 80 + 151 + 26 + + + + Qt::StrongFocus + + + + + + 100 + 20 151 26 @@ -457,37 +590,11 @@ margin:1px; Select the stabilization mode on this position (manual/stabilized/auto) - + - 10 - 30 - 62 - 17 - - - - Pos. 3 - - - - - - 100 - 85 - 151 - 26 - - - - Qt::StrongFocus - - - - - - 10 - 60 + 11 + 55 62 17 @@ -496,11 +603,11 @@ margin:1px; Pos. 2 - + - 10 - 90 + 11 + 25 62 17 @@ -509,55 +616,68 @@ margin:1px; Pos. 1 - - - false - + - 70 - 30 - 20 - 81 + 11 + 85 + 62 + 17 - - Qt::StrongFocus + + Pos. 3 + + + + + + 458 + 20 + 61 + 20 + - This slider moves when you move the flight mode switch -on your remote. Setup the flightmode channel on the RC Input tab -if you have not done so already. + Number of positions your FlightMode switch has. + +Default is 3. + +It will be 2 or 3 for most of setups, but it also can be up to 6. +In that case you have to configure your radio mixers so the whole range +from min to max is split into N equal intervals, and you may set arbitrary +channel value for each flight mode. - -100 + 1 - 100 + 6 - - 10 + + 3 - - -100 + + + + + 277 + 22 + 171 + 16 + - - Qt::Vertical - - - QSlider::TicksBelow - - - 100 + + Number of flight modes: - 270 - 30 - 141 - 31 + 310 + 120 + 191 + 30 @@ -567,13 +687,15 @@ if you have not done so already. - Warning: avoid "Manual" + Avoid "Manual" for multirotors! true + groupBox_2 + groupBox @@ -763,9 +885,6 @@ Applies and Saves all settings to SD fmsSlider - fmsModePos3 - fmsModePos2 - fmsModePos1 fmsSsPos1Roll fmsSsPos1Pitch fmsSsPos1Yaw diff --git a/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml b/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml index 64c653f23..d61dba982 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml +++ b/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml @@ -1,8 +1,22 @@ - en_AU + true + true + LineardialGadget + Mainboard CPU true + 476 + 697 + + + + 1 + 0 + + 1 + + 0 @@ -11,37 +25,17 @@ false true - - - - false - 1.0.0 - - - - - - - 0 - - - - - - - - - 0 - - 1 - - false - - 0 - - - - + + 91 + 90 + 89 + 88 + 87 + 100 + + + 57600 + @@ -65,7 +59,7 @@ needle needle needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 AttitudeActual -1 360 @@ -100,7 +94,7 @@ needle needle2 needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 1 10 @@ -131,11 +125,8 @@ false background %%DATAPATH%%dials/default/barometer.svg - needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 10 1120 @@ -166,11 +157,8 @@ false background %%DATAPATH%%dials/default/vsi.svg - needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 VelocityActual 0.01 12 @@ -203,9 +191,7 @@ %%DATAPATH%%dials/default/compass.svg foreground needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 AttitudeActual -1 360 @@ -240,7 +226,7 @@ needle needle needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 AttitudeActual -1 360 @@ -275,7 +261,7 @@ needle needle2 needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 1 10 @@ -308,9 +294,7 @@ %%DATAPATH%%dials/deluxe/barometer.svg foreground needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 10 1120 @@ -343,9 +327,7 @@ %%DATAPATH%%dials/deluxe/vsi.svg foreground needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 VelocityActual 0.01 11.2 @@ -378,9 +360,7 @@ %%DATAPATH%%dials/deluxe/compass.svg foreground needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 AttitudeActual -1 360 @@ -413,9 +393,7 @@ %%DATAPATH%%dials/deluxe/speed.svg foreground needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 GPSPosition 3.6 120 @@ -450,7 +428,7 @@ needle needle2 needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 1 120 @@ -485,7 +463,7 @@ needle needle2 needle2 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 AttitudeActual -1 360 @@ -516,11 +494,8 @@ false background %%DATAPATH%%dials/default/speed.svg - needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 GPSPosition 3.6 120 @@ -555,7 +530,7 @@ needle needle needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 AttitudeActual -1 360 @@ -590,7 +565,7 @@ needle needle2 needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 1 10 @@ -621,11 +596,8 @@ false background %%DATAPATH%%dials/hi-contrast/barometer.svg - needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 10 1120 @@ -656,11 +628,8 @@ false background %%DATAPATH%%dials/hi-contrast/vsi.svg - needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 VelocityActual 0.01 12 @@ -693,9 +662,7 @@ %%DATAPATH%%dials/hi-contrast/compass.svg foreground needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 AttitudeActual -1 360 @@ -726,11 +693,8 @@ false background %%DATAPATH%%dials/hi-contrast/speed.svg - needle - - - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 GPSPosition 3.6 120 @@ -761,11 +725,10 @@ false background %%DATAPATH%%dials/hi-contrast/thermometer.svg - needle needle2 needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 1 120 @@ -796,11 +759,10 @@ false background %%DATAPATH%%dials/default/thermometer.svg - needle needle2 needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 ManualControlCommand 1 2000 @@ -831,11 +793,10 @@ false background %%DATAPATH%%dials/default/thermometer.svg - needle needle2 needle3 - Ubuntu,11,-1,5,50,0,0,0,0,0 + MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0 BaroAltitude 1 120 @@ -916,7 +877,7 @@ 3 0 0 - Serial port 0 + Communications Port (COM1) 11 0 @@ -931,7 +892,7 @@ 3 0 0 - Serial port 0 + Communications Port (COM1) 17 0 @@ -948,8 +909,6 @@ \usr\share\games\FlightGear 127.0.0.1 9009 - - false 9010 127.0.0.1 @@ -967,8 +926,6 @@ \usr\share\games\FlightGear 127.0.0.3 6756 - - false 49000 127.0.0.1 @@ -977,17 +934,39 @@ - + false - 1.0.1 + 0.0.0 - gcs.ini + false + false + true + true + true + 20 + true + 200 + true + 0 + true + 127.0.0.1 + 40100 + true + false + false + 40200 + 20 + 127.0.0.1 + ASimRC + 50 + false + @Variant(AAAAh0CgAAA=) - + @@ -1183,17 +1162,17 @@ 0 1 Andale Mono,12,-1,5,75,0,0,0,0,0 - 50 + 90 0 100 0 100 - 80 + 95 SystemStats CPULoad false - 80 - 50 + 95 + 90 @@ -1439,6 +1418,17 @@ false + + + false + 0.0.0 + + + %%DATAPATH%%models/boards/CopterControl/CopterControl.3ds + %%DATAPATH%%models/backgrounds/default_background.png + false + + false @@ -1571,6 +1561,17 @@ false + + + false + 0.0.0 + + + %%DATAPATH%%models/multi/ricoo/ricoo.3DS + %%DATAPATH%%models/backgrounds/default_background.png + false + + false @@ -1604,28 +1605,6 @@ false - - - false - 0.0.0 - - - %%DATAPATH%%models/multi/ricoo/ricoo.3DS - %%DATAPATH%%models/backgrounds/default_background.png - false - - - - - false - 0.0.0 - - - %%DATAPATH%%models/boards/CopterControl/CopterControl.3ds - %%DATAPATH%%models/backgrounds/default_background.png - false - - @@ -1712,14 +1691,18 @@ - + false 0.0.0 + + Unknown + true + - + @@ -1738,6 +1721,7 @@ x Accels 0 + 1 0 0 @@ -1747,6 +1731,7 @@ y Accels 0 + 1 0 0 @@ -1756,6 +1741,7 @@ z Accels 0 + 1 0 0 @@ -1781,6 +1767,7 @@ Channel-4 ActuatorCommand 0 + 1 0 0 @@ -1790,6 +1777,7 @@ Channel-5 ActuatorCommand 0 + 1 0 0 @@ -1799,6 +1787,7 @@ Channel-6 ActuatorCommand 0 + 1 0 0 @@ -1808,6 +1797,7 @@ Channel-7 ActuatorCommand 0 + 1 0 0 @@ -1833,6 +1823,7 @@ Roll AttitudeActual 0 + 1 0 0 @@ -1842,6 +1833,7 @@ Yaw AttitudeActual 0 + 1 0 0 @@ -1851,6 +1843,7 @@ Pitch AttitudeActual 0 + 1 0 0 @@ -1876,6 +1869,7 @@ Pressure BaroAltitude 0 + 1 0 0 @@ -1901,6 +1895,7 @@ Channel-1 ManualControlCommand 0 + 1 0 0 @@ -1910,6 +1905,7 @@ Channel-4 ManualControlCommand 0 + 1 0 0 @@ -1919,6 +1915,7 @@ Channel-5 ManualControlCommand 0 + 1 0 0 @@ -1928,6 +1925,7 @@ Channel-6 ManualControlCommand 0 + 1 0 0 @@ -1937,6 +1935,7 @@ Channel-7 ManualControlCommand 0 + 1 0 0 @@ -1946,6 +1945,7 @@ Channel-2 ManualControlCommand 0 + 1 0 0 @@ -1955,6 +1955,7 @@ Channel-3 ManualControlCommand 0 + 1 0 0 @@ -1964,6 +1965,7 @@ Channel-0 ManualControlCommand 0 + 1 0 0 @@ -1989,6 +1991,7 @@ x Accels 0 + 1 0 0 @@ -1998,6 +2001,7 @@ y Accels 0 + 1 0 0 @@ -2007,6 +2011,7 @@ z Accels 0 + 1 0 0 @@ -2032,6 +2037,7 @@ z Gyros 0 + 1 0 0 @@ -2041,6 +2047,7 @@ y Gyros 0 + 1 0 0 @@ -2050,6 +2057,7 @@ x Gyros 0 + 1 0 0 @@ -2075,6 +2083,7 @@ X Magnetometer 0 + 1 0 0 @@ -2084,6 +2093,7 @@ Y Magnetometer 0 + 1 0 0 @@ -2093,6 +2103,7 @@ Z Magnetometer 0 + 1 0 0 @@ -2118,6 +2129,7 @@ StackRemaining-System TaskInfo 0 + 1 0 0 @@ -2127,6 +2139,7 @@ StackRemaining-Actuator TaskInfo 0 + 1 0 0 @@ -2136,6 +2149,7 @@ StackRemaining-Guidance TaskInfo 0 + 1 0 0 @@ -2145,6 +2159,7 @@ StackRemaining-Watchdog TaskInfo 0 + 1 0 0 @@ -2154,6 +2169,7 @@ StackRemaining-TelemetryTx TaskInfo 0 + 1 0 0 @@ -2163,6 +2179,7 @@ StackRemaining-TelemetryTxPri TaskInfo 0 + 1 0 0 @@ -2172,6 +2189,7 @@ StackRemaining-TelemetryRx TaskInfo 0 + 1 0 0 @@ -2181,6 +2199,7 @@ StackRemaining-GPS TaskInfo 0 + 1 0 0 @@ -2190,6 +2209,7 @@ StackRemaining-ManualControl TaskInfo 0 + 1 0 0 @@ -2199,6 +2219,7 @@ StackRemaining-Altitude TaskInfo 0 + 1 0 0 @@ -2208,6 +2229,7 @@ StackRemaining-AHRSComms TaskInfo 0 + 1 0 0 @@ -2217,6 +2239,7 @@ StackRemaining-Stabilization TaskInfo 0 + 1 0 0 @@ -2242,6 +2265,7 @@ TxFailures GCSTelemetryStats 0 + 1 0 0 @@ -2251,6 +2275,7 @@ RxFailures GCSTelemetryStats 0 + 1 0 0 @@ -2260,6 +2285,7 @@ TxRetries GCSTelemetryStats 0 + 1 0 0 @@ -2285,9 +2311,20 @@ FlightTime SystemStats 0 + 1 0 0 + + 0 + + + + 0 + 1 + 0 + 0 + 2 1 800 @@ -2417,26 +2454,14 @@ uavGadget - - LineardialGadget - - Mainboard CPU - - uavGadget - - - LineardialGadget - - AHRS CPU - - uavGadget - - 1 - @Variant(AAAACQAAAAIAAAACAAAAQAAAAAIAAABA) - splitter + LineardialGadget + + Mainboard CPU + + uavGadget 1 - @Variant(AAAACQAAAAIAAAACAAABIwAAAAIAAACN) + @Variant(AAAACQAAAAIAAAACAAABLwAAAAIAAACB) splitter @@ -2837,9 +2862,10 @@ UAVGadgetManagerV1 - @ByteArray(AAAA/wAAAAD9AAAAAAAABQAAAALCAAAABAAAAAQAAAABAAAACPwAAAAA) - :/core/images/ah.png + false + :\core\images\ah.png + :/core/images/openpilot_logo_64.png :/core/images/config.png :/core/images/scopes.png :/core/images/joystick.png @@ -2848,9 +2874,10 @@ :/core/images/openpilot_logo_64.png :/core/images/openpilot_logo_64.png :/core/images/openpilot_logo_64.png - :/core/images/openpilot_logo_64.png 5 + 1 Flight data + Workspace10 Configuration Scopes HITL @@ -2859,6 +2886,5 @@ Workspace7 Workspace8 Workspace9 - Workspace10 diff --git a/ground/openpilotgcs/src/plugins/rawhid/rawhid.cpp b/ground/openpilotgcs/src/plugins/rawhid/rawhid.cpp index ce9c0c125..4649d6162 100644 --- a/ground/openpilotgcs/src/plugins/rawhid/rawhid.cpp +++ b/ground/openpilotgcs/src/plugins/rawhid/rawhid.cpp @@ -41,7 +41,7 @@ class IConnection; static const int READ_TIMEOUT = 200; static const int READ_SIZE = 64; -static const int WRITE_TIMEOUT = 200; +static const int WRITE_TIMEOUT = 1000; static const int WRITE_SIZE = 64; diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Actuator-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Actuator-Critical.html new file mode 100644 index 000000000..ae7a4a3f5 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Actuator-Critical.html @@ -0,0 +1,17 @@ + + + + + + + +

Servo Output: Critical

+

+ One of the following conditions may be present: +

    +
  • System is in failsafe mode.
  • +
  • One or more servos outputs failed to update.
  • +
+

+ + diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/AlarmOK.html b/ground/openpilotgcs/src/plugins/systemhealth/html/AlarmOK.html new file mode 100644 index 000000000..fee48402f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/AlarmOK.html @@ -0,0 +1,13 @@ + + + + + + + +

Alarm: OK

+

+ There are no problems with this alarm. +

+ + diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Attitude-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Attitude-Critical.html new file mode 100644 index 000000000..76a3d5799 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Attitude-Critical.html @@ -0,0 +1,13 @@ +html> + + + + + + +

Attitude: Critical

+

+ This alarm will remain set until data is received from the accelerometer. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Attitude-Error.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Attitude-Error.html new file mode 100644 index 000000000..826e29d7c --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Attitude-Error.html @@ -0,0 +1,13 @@ + + + + + + + +

Attitude: Error

+

+ Failed to get an update from the accelerometer or gyros. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Critical.html new file mode 100644 index 000000000..53e33520a --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Critical.html @@ -0,0 +1,13 @@ + + + + + + + +

Battery: Critical

+

+ Battery voltage has fallen below the alarm threshold. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Error.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Error.html new file mode 100644 index 000000000..109e79cf9 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Error.html @@ -0,0 +1,13 @@ + + + + + + + +

Battery: Error

+

+ Both battery current and voltage are at or below zero. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Warning.html new file mode 100644 index 000000000..503b35a03 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Battery-Warning.html @@ -0,0 +1,13 @@ + + + + + + + +

Battery: Warning

+

+ Battery voltage has fallen below the warning threshold. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/BootFault-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/BootFault-Critical.html new file mode 100644 index 000000000..c7af2464f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/BootFault-Critical.html @@ -0,0 +1,13 @@ + + + + + + + +

Boot Fault: Critical

+

+ System has failed to boot more than three times: system defaults have been set. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/CPU-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/CPU-Critical.html new file mode 100644 index 000000000..273423124 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/CPU-Critical.html @@ -0,0 +1,13 @@ + + + + + + + +

CPU: Critical

+

+ CPU load has exceeded 95% +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/CPU-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/CPU-Warning.html new file mode 100644 index 000000000..a6c15546d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/CPU-Warning.html @@ -0,0 +1,13 @@ + + + + + + + +

CPU: Warning

+

+ CPU load has exceeded 80% +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/EventSystem-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/EventSystem-Warning.html new file mode 100644 index 000000000..95e05f798 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/EventSystem-Warning.html @@ -0,0 +1,13 @@ + + + + + + + +

Event System: Warning

+

+ There were problems with UAVObject events or callbacks +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Critical.html new file mode 100644 index 000000000..685b021b9 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Critical.html @@ -0,0 +1,13 @@ + + + + + + + +

Flight Time: Critical

+

+ Estimated flight time based on battery usage is less than 30s. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Error.html b/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Error.html new file mode 100644 index 000000000..2f6578978 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Error.html @@ -0,0 +1,13 @@ + + + + + + + +

Flight Time: Error

+

+ Estimated flight time cannot be determined as battery voltage and current are at or below 0. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Warning.html new file mode 100644 index 000000000..9b1464f25 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/FlightTime-Warning.html @@ -0,0 +1,13 @@ + + + + + + + +

Flight Time: Warning

+

+ Estimated flight time based on battery usage is less than 60s. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Critical.html new file mode 100644 index 000000000..1bd07afb4 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Critical.html @@ -0,0 +1,13 @@ + + + + + + + +

GPS: Critical

+

+ The GPS is receiving data but there is no position fix. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Error.html b/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Error.html new file mode 100644 index 000000000..ab713bb08 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Error.html @@ -0,0 +1,13 @@ + + + + + + + +

GPS: Error

+

+ The GPS has timed out; either there is no GPS plugged in, the GPS has locked up or there is some other hardware fault. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Warning.html new file mode 100644 index 000000000..d610cecc6 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/GPS-Warning.html @@ -0,0 +1,13 @@ + + + + + + + +

GPS: Warning

+

+ The GPS has a fix and navigation can be used. However, the position quality is very low (the indication is <7 satellites) +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Guidance-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Guidance-Warning.html new file mode 100644 index 000000000..6d4d4524f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Guidance-Warning.html @@ -0,0 +1,13 @@ + + + + + + + +

Guidance: Warning

+

+ Timed out waiting for an attitude update. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/ManualControl-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/ManualControl-Critical.html new file mode 100644 index 000000000..0b374ab19 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/ManualControl-Critical.html @@ -0,0 +1,24 @@ + + + + + + + +

RC Input: Critical

+

+ One of the following conditions may be present: +

    +
  • +

    One or more of the r/c input channel types is not set.

    +

    On the GCS configuration page, make sure all inputs have a Type set.

    +
  • +
  • One or more of the r/c input channel mappings are invalid.
  • +
  • The driver is uninitialized for one or more of the r/c input channels.
  • +
  • Current flight mode is undefined: this indicates a bug in the code.
  • +
  • Current flight mode set to guidance but flight status flight mode is reported as something other than altitude hold.
  • +
  • During update of desired stabilization mode, flight status is reported as something other than stabilized 1, 2 or 3.
  • +
+

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/ManualControl-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/ManualControl-Warning.html new file mode 100644 index 000000000..9f472e13a --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/ManualControl-Warning.html @@ -0,0 +1,17 @@ + + + + + + + +

RC Input: Warning

+

+ One of the following conditions may be present: +

    +
  • System is in failsafe mode.
  • +
  • Failed to update one or more of the accessory channels.
  • +
+

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Memory-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Memory-Critical.html new file mode 100644 index 000000000..b1fa75164 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Memory-Critical.html @@ -0,0 +1,13 @@ + + + + + + + +

Memory: Critical

+

+ Either the remaining heap space or the IRQ stack has fallen below the critical limit (1000 bytes heap, 80 entries IRQ stack). +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Memory-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Memory-Warning.html new file mode 100644 index 000000000..e4ebf94a6 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Memory-Warning.html @@ -0,0 +1,16 @@ + + + + + + + +

Memory: Warning

+

+ Either the remaining heap space or the IRQ stack has fallen below the warning limit (4000 bytes heap, 150 entries IRQ stack). +

+

+ Note: if this is an original CC board (not CC3D or Revo), this condition is normal. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Sensors-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Sensors-Critical.html new file mode 100644 index 000000000..9c0fb41cb --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Sensors-Critical.html @@ -0,0 +1,18 @@ + + + + + + + +

Sensors: Critical

+

+ One of the following conditions may be present: +

    +
  • Either the accelerometer, gyro or magnetometer tests failed.
  • +
  • Timed out waiting for data from the accelerometer or gyro.
  • +
+ +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Stabilization-Warning.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Stabilization-Warning.html new file mode 100644 index 000000000..8120f7503 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Stabilization-Warning.html @@ -0,0 +1,13 @@ + + + + + + + +

Stabilization: Warning

+

+ Timed out waiting for an attitude update. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Stack-Critical.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Stack-Critical.html new file mode 100644 index 000000000..ad5e8c7ef --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Stack-Critical.html @@ -0,0 +1,13 @@ + + + + + + + +

Stack: Critical

+

+ Stack overflow +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/html/Telemetry-Error.html b/ground/openpilotgcs/src/plugins/systemhealth/html/Telemetry-Error.html new file mode 100644 index 000000000..5c6e0260f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/html/Telemetry-Error.html @@ -0,0 +1,13 @@ + + + + + + + +

Telemetry: Error

+

+ Telemetry system is disconnected. +

+ + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/systemhealth/systemhealth.pro b/ground/openpilotgcs/src/plugins/systemhealth/systemhealth.pro index b053a7430..e61a12e16 100644 --- a/ground/openpilotgcs/src/plugins/systemhealth/systemhealth.pro +++ b/ground/openpilotgcs/src/plugins/systemhealth/systemhealth.pro @@ -1,20 +1,23 @@ -TEMPLATE = lib -TARGET = SystemHealthGadget -QT += svg -include(../../openpilotgcsplugin.pri) -include(../../plugins/coreplugin/coreplugin.pri) -include(systemhealth_dependencies.pri) -HEADERS += systemhealthplugin.h -HEADERS += systemhealthgadget.h -HEADERS += systemhealthgadgetwidget.h -HEADERS += systemhealthgadgetfactory.h -HEADERS += systemhealthgadgetconfiguration.h -HEADERS += systemhealthgadgetoptionspage.h -SOURCES += systemhealthplugin.cpp -SOURCES += systemhealthgadget.cpp -SOURCES += systemhealthgadgetfactory.cpp -SOURCES += systemhealthgadgetwidget.cpp -SOURCES += systemhealthgadgetconfiguration.cpp -SOURCES += systemhealthgadgetoptionspage.cpp -OTHER_FILES += SystemHealthGadget.pluginspec -FORMS += systemhealthgadgetoptionspage.ui +TEMPLATE = lib +TARGET = SystemHealthGadget +QT += svg +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(systemhealth_dependencies.pri) +HEADERS += systemhealthplugin.h +HEADERS += systemhealthgadget.h +HEADERS += systemhealthgadgetwidget.h +HEADERS += systemhealthgadgetfactory.h +HEADERS += systemhealthgadgetconfiguration.h +HEADERS += systemhealthgadgetoptionspage.h +SOURCES += systemhealthplugin.cpp +SOURCES += systemhealthgadget.cpp +SOURCES += systemhealthgadgetfactory.cpp +SOURCES += systemhealthgadgetwidget.cpp +SOURCES += systemhealthgadgetconfiguration.cpp +SOURCES += systemhealthgadgetoptionspage.cpp +OTHER_FILES += SystemHealthGadget.pluginspec +FORMS += systemhealthgadgetoptionspage.ui + +RESOURCES += \ + systemhealth.qrc diff --git a/ground/openpilotgcs/src/plugins/systemhealth/systemhealth.qrc b/ground/openpilotgcs/src/plugins/systemhealth/systemhealth.qrc new file mode 100644 index 000000000..7ef754ecc --- /dev/null +++ b/ground/openpilotgcs/src/plugins/systemhealth/systemhealth.qrc @@ -0,0 +1,30 @@ + + + html/Actuator-Critical.html + html/ManualControl-Critical.html + html/ManualControl-Warning.html + html/CPU-Critical.html + html/CPU-Warning.html + html/FlightTime-Error.html + html/Battery-Warning.html + html/BootFault-Critical.html + html/EventSystem-Warning.html + html/FlightTime-Critical.html + html/AlarmOK.html + html/Attitude-Critical.html + html/Attitude-Error.html + html/Battery-Critical.html + html/Battery-Error.html + html/FlightTime-Warning.html + html/GPS-Critical.html + html/GPS-Error.html + html/GPS-Warning.html + html/Guidance-Warning.html + html/Memory-Critical.html + html/Memory-Warning.html + html/Sensors-Critical.html + html/Stabilization-Warning.html + html/Stack-Critical.html + html/Telemetry-Error.html + + diff --git a/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp index 440ff58df..68d19c532 100644 --- a/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file systemhealthgadgetwidget.cpp - * @author Edouard Lafargue Copyright (C) 2010. + * @author OpenPilot Team & Edouard Lafargue Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup SystemHealthPlugin System Health Plugin @@ -32,6 +32,7 @@ #include "systemalarms.h" #include +#include /* * Initialize the widget @@ -62,6 +63,7 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); + setToolTip(tr("Displays flight system errors. Click on an alarm for more information.")); } /** @@ -195,3 +197,73 @@ void SystemHealthGadgetWidget::resizeEvent(QResizeEvent *event) Q_UNUSED(event); fitInView(background, Qt::KeepAspectRatio ); } + +void SystemHealthGadgetWidget::mousePressEvent ( QMouseEvent * event ) +{ + QGraphicsScene *graphicsScene = scene(); + if(graphicsScene){ + QPoint point = event->pos(); + bool haveAlarmItem = false; + foreach(QGraphicsItem* sceneItem, items(point)){ + QGraphicsSvgItem *clickedItem = dynamic_cast(sceneItem); + + if(clickedItem){ + if((clickedItem != foreground) && (clickedItem != background)){ + // Clicked an actual alarm. We need to set haveAlarmItem to true + // as two of the items in this loop will always be foreground and + // background. Without this flag, at some point in the loop we + // would always call showAllAlarmDescriptions... + haveAlarmItem = true; + QString itemId = clickedItem->elementId(); + if(itemId.contains("OK")){ + // No alarm set for this item + showAlarmDescriptionForItemId("AlarmOK", event->globalPos()); + }else{ + // Warning, error or critical alarm + showAlarmDescriptionForItemId(itemId, event->globalPos()); + } + }else if(!haveAlarmItem){ + // Clicked foreground or background + showAllAlarmDescriptions(event->globalPos()); + } + } + } + } +} + +void SystemHealthGadgetWidget::showAlarmDescriptionForItemId(const QString itemId, const QPoint& location){ + QFile alarmDescription(":/systemhealth/html/" + itemId + ".html"); + if(alarmDescription.open(QIODevice::ReadOnly | QIODevice::Text)){ + QTextStream textStream(&alarmDescription); + QWhatsThis::showText(location, textStream.readAll()); + } +} + +void SystemHealthGadgetWidget::showAllAlarmDescriptions(const QPoint& location){ + QGraphicsScene *graphicsScene = scene(); + if(graphicsScene){ + QString alarmsText; + + // Loop through all items in the scene looking for svg items that represent alarms + foreach(QGraphicsItem* curItem, graphicsScene->items()){ + QGraphicsSvgItem* curSvgItem = dynamic_cast(curItem); + if(curSvgItem && (curSvgItem != foreground) && (curSvgItem != background)){ + QString elementId = curSvgItem->elementId(); + if(!elementId.contains("OK")){ + // Found an alarm, get its corresponding alarm html file contents + // and append to the cumulative string for all alarms. + QFile alarmDescription(":/systemhealth/html/" + elementId + ".html"); + if(alarmDescription.open(QIODevice::ReadOnly | QIODevice::Text)){ + QTextStream textStream(&alarmDescription); + alarmsText.append(textStream.readAll()); + } + } + } + } + + // Show alarms text if we have any + if(alarmsText.length() > 0){ + QWhatsThis::showText(location, alarmsText); + } + } +} diff --git a/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.h b/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.h index 7f3034059..15ab31952 100644 --- a/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file systemhealthgadgetwidget.h - * @author Edouard Lafargue Copyright (C) 2010. + * @author OpenPilot Team & Edouard Lafargue Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup SystemHealthPlugin System Health Plugin @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,7 @@ public: protected: void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); + void mousePressEvent ( QMouseEvent * event ); private slots: void updateAlarms(UAVObject *systemAlarm); // Called by the systemalarms UAVObject @@ -67,5 +69,8 @@ private: // Simple flag to skip rendering if the bool fgenabled; // layer does not exist. + void showAlarmDescriptionForItemId(const QString itemId, const QPoint& location); + void showAllAlarmDescriptions(const QPoint &location); + }; #endif /* SYSTEMHEALTHGADGETWIDGET_H_ */ diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.cpp index a6924e71d..debe3f81d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.cpp @@ -129,21 +129,23 @@ void TreeItem::appendChild(TreeItem *child) child->setParentTree(this); } -void TreeItem::insert(int index, TreeItem *child) +void TreeItem::insertChild(TreeItem *child) { + int index = nameIndex(child->data(0).toString()); m_children.insert(index, child); child->setParentTree(this); } -TreeItem *TreeItem::child(int row) +TreeItem *TreeItem::getChild(int index) { - return m_children.value(row); + return m_children.value(index); } int TreeItem::childCount() const { return m_children.count(); } + int TreeItem::row() const { if (m_parent) @@ -224,3 +226,8 @@ QTime TreeItem::getHiglightExpires() { return m_highlightExpires; } + +QList TopTreeItem::getMetaObjectItems() +{ + return m_metaObjectTreeItemsPerObjectIds.values(); +} diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.h index 708513d91..f30368e25 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/treeitem.h @@ -33,6 +33,7 @@ #include "uavobjectfield.h" #include #include +#include #include #include #include @@ -94,9 +95,9 @@ public: virtual ~TreeItem(); void appendChild(TreeItem *child); - void insert(int index, TreeItem *child); + void insertChild(TreeItem *child); - TreeItem *child(int row); + TreeItem *getChild(int index); inline QList treeChildren() const { return m_children; } int childCount() const; int columnCount() const; @@ -131,6 +132,24 @@ public: virtual void removeHighlight(); + int nameIndex(QString name) { + for (int i = 0; i < childCount(); ++i) { + if (name < getChild(i)->data(0).toString()) + return i; + } + return childCount(); + } + + TreeItem* findChildByName(QString name) + { + foreach (TreeItem* child, m_children) { + if (name == child->data(0).toString()) { + return child; + } + } + return 0; + } + signals: void updateHighlight(TreeItem*); @@ -152,6 +171,9 @@ private: static int m_highlightTimeMs; }; +class DataObjectTreeItem; +class MetaObjectTreeItem; + class TopTreeItem : public TreeItem { Q_OBJECT @@ -159,19 +181,27 @@ public: TopTreeItem(const QList &data, TreeItem *parent = 0) : TreeItem(data, parent) { } TopTreeItem(const QVariant &data, TreeItem *parent = 0) : TreeItem(data, parent) { } - QList objIds() { return m_objIds; } - void addObjId(quint32 objId) { m_objIds.append(objId); } - void insertObjId(int index, quint32 objId) { m_objIds.insert(index, objId); } - int nameIndex(QString name) { - for (int i = 0; i < childCount(); ++i) { - if (name < child(i)->data(0).toString()) - return i; - } - return childCount(); + void addObjectTreeItem(quint32 objectId, DataObjectTreeItem* oti) { + m_objectTreeItemsPerObjectIds[objectId] = oti; } + DataObjectTreeItem* findDataObjectTreeItemByObjectId(quint32 objectId) { + return m_objectTreeItemsPerObjectIds.contains(objectId) ? m_objectTreeItemsPerObjectIds[objectId] : 0; + } + + void addMetaObjectTreeItem(quint32 objectId, MetaObjectTreeItem* oti) { + m_metaObjectTreeItemsPerObjectIds[objectId] = oti; + } + + MetaObjectTreeItem* findMetaObjectTreeItemByObjectId(quint32 objectId) { + return m_metaObjectTreeItemsPerObjectIds.contains(objectId) ? m_metaObjectTreeItemsPerObjectIds[objectId] : 0; + } + + QList getMetaObjectItems(); + private: - QList m_objIds; + QMap m_objectTreeItemsPerObjectIds; + QMap m_metaObjectTreeItemsPerObjectIds; }; class ObjectTreeItem : public TreeItem diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp index cf343ec5c..46142340c 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp @@ -45,5 +45,6 @@ void UAVObjectBrowser::loadConfiguration(IUAVGadgetConfiguration* config) m_widget->setRecentlyUpdatedColor(m->recentlyUpdatedColor()); m_widget->setManuallyChangedColor(m->manuallyChangedColor()); m_widget->setRecentlyUpdatedTimeout(m->recentlyUpdatedTimeout()); + m_widget->setOnlyHilightChangedValues(m->onlyHighlightChangedValues()); } diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.ui b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.ui index 091c0c5eb..0d36859fd 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.ui +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.ui @@ -202,6 +202,19 @@
+ + + + Select to sort objects in to categories. + + + Categorize Objects + + + true + + + diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp index e534542c6..cce3bee89 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp @@ -31,17 +31,20 @@ UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QS IUAVGadgetConfiguration(classId, parent), m_recentlyUpdatedColor(QColor(255, 230, 230)), m_manuallyChangedColor(QColor(230, 230, 255)), - m_recentlyUpdatedTimeout(500) + m_recentlyUpdatedTimeout(500), + m_onlyHilightChangedValues(false) { //if a saved configuration exists load it if(qSettings != 0) { QColor recent = qSettings->value("recentlyUpdatedColor").value(); QColor manual = qSettings->value("manuallyChangedColor").value(); int timeout = qSettings->value("recentlyUpdatedTimeout").toInt(); + bool hilight = qSettings->value("onlyHilightChangedValues").toBool(); m_recentlyUpdatedColor = recent; m_manuallyChangedColor = manual; m_recentlyUpdatedTimeout = timeout; + m_onlyHilightChangedValues = hilight; } } @@ -51,6 +54,7 @@ IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone() m->m_recentlyUpdatedColor = m_recentlyUpdatedColor; m->m_manuallyChangedColor = m_manuallyChangedColor; m->m_recentlyUpdatedTimeout = m_recentlyUpdatedTimeout; + m->m_onlyHilightChangedValues = m_onlyHilightChangedValues; return m; } @@ -62,4 +66,5 @@ void UAVObjectBrowserConfiguration::saveConfig(QSettings* qSettings) const { qSettings->setValue("recentlyUpdatedColor", m_recentlyUpdatedColor); qSettings->setValue("manuallyChangedColor", m_manuallyChangedColor); qSettings->setValue("recentlyUpdatedTimeout", m_recentlyUpdatedTimeout); + qSettings->setValue("onlyHilightChangedValues", m_onlyHilightChangedValues); } diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h index 941428f83..8e31c18dc 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h @@ -39,6 +39,7 @@ Q_OBJECT Q_PROPERTY(QColor m_recentlyUpdatedColor READ recentlyUpdatedColor WRITE setRecentlyUpdatedColor) Q_PROPERTY(QColor m_manuallyChangedColor READ manuallyChangedColor WRITE setManuallyChangedColor) Q_PROPERTY(int m_recentlyUpdatedTimeout READ recentlyUpdatedTimeout WRITE setRecentlyUpdatedTimeout) +Q_PROPERTY(bool m_onlyHilightChangedValues READ onlyHighlightChangedValues WRITE setOnlyHighlightChangedValues) public: explicit UAVObjectBrowserConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0); @@ -48,6 +49,7 @@ public: QColor recentlyUpdatedColor() const { return m_recentlyUpdatedColor; } QColor manuallyChangedColor() const { return m_manuallyChangedColor; } int recentlyUpdatedTimeout() const { return m_recentlyUpdatedTimeout; } + bool onlyHighlightChangedValues() const {return m_onlyHilightChangedValues;} signals: @@ -55,11 +57,13 @@ public slots: void setRecentlyUpdatedColor(QColor color) { m_recentlyUpdatedColor = color; } void setManuallyChangedColor(QColor color) { m_manuallyChangedColor = color; } void setRecentlyUpdatedTimeout(int timeout) { m_recentlyUpdatedTimeout = timeout; } + void setOnlyHighlightChangedValues(bool hilight) { m_onlyHilightChangedValues = hilight; } private: QColor m_recentlyUpdatedColor; QColor m_manuallyChangedColor; int m_recentlyUpdatedTimeout; + bool m_onlyHilightChangedValues; }; #endif // UAVOBJECTBROWSERCONFIGURATION_H diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp index fe0a13290..b9561e471 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp @@ -52,6 +52,7 @@ QWidget *UAVObjectBrowserOptionsPage::createPage(QWidget *parent) m_page->recentlyUpdatedButton->setColor(m_config->recentlyUpdatedColor()); m_page->manuallyChangedButton->setColor(m_config->manuallyChangedColor()); m_page->recentlyUpdatedTimeoutSpinBox->setValue(m_config->recentlyUpdatedTimeout()); + m_page->hilightBox->setChecked(m_config->onlyHighlightChangedValues()); return w; @@ -62,6 +63,7 @@ void UAVObjectBrowserOptionsPage::apply() m_config->setRecentlyUpdatedColor(m_page->recentlyUpdatedButton->color()); m_config->setManuallyChangedColor(m_page->manuallyChangedButton->color()); m_config->setRecentlyUpdatedTimeout(m_page->recentlyUpdatedTimeoutSpinBox->value()); + m_config->setOnlyHighlightChangedValues(m_page->hilightBox->isChecked()); } void UAVObjectBrowserOptionsPage::finish() diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui index 474e26dc6..350fc440b 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui @@ -48,7 +48,7 @@ - + Qt::Vertical @@ -115,6 +115,13 @@
+ + + + Only hilight nodes when value actually changes + + + diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.cpp index 31c395ccc..2ce386799 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.cpp @@ -54,6 +54,7 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent showMetaData(m_browser->metaCheckBox->isChecked()); connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex))); connect(m_browser->metaCheckBox, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool))); + connect(m_browser->categorizeCheckbox, SIGNAL(toggled(bool)), this, SLOT(categorize(bool))); connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject())); connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject())); connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject())); @@ -69,16 +70,32 @@ UAVObjectBrowserWidget::~UAVObjectBrowserWidget() void UAVObjectBrowserWidget::showMetaData(bool show) { - int topRowCount = m_model->rowCount(QModelIndex()); - for (int i = 0; i < topRowCount; ++i) { - QModelIndex index = m_model->index(i, 0, QModelIndex()); - int subRowCount = m_model->rowCount(index); - for (int j = 0; j < subRowCount; ++j) { - m_browser->treeView->setRowHidden(0, index.child(j,0), !show); - } + QList metaIndexes = m_model->getMetaDataIndexes(); + foreach(QModelIndex index , metaIndexes) + { + m_browser->treeView->setRowHidden(index.row(), index.parent(), !show); } } +void UAVObjectBrowserWidget::categorize(bool categorize) +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pm); + UAVObjectManager *objManager = pm->getObject(); + Q_ASSERT(objManager); + + UAVObjectTreeModel* tmpModel = m_model; + m_model = new UAVObjectTreeModel(0, categorize); + m_model->setRecentlyUpdatedColor(m_recentlyUpdatedColor); + m_model->setManuallyChangedColor(m_manuallyChangedColor); + m_model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout); + m_model->setOnlyHilightChangedValues(m_onlyHilightChangedValues); + m_browser->treeView->setModel(m_model); + showMetaData(m_browser->metaCheckBox->isChecked()); + + delete tmpModel; +} + void UAVObjectBrowserWidget::sendUpdate() { ObjectTreeItem *objItem = findCurrentObjectTreeItem(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h index b047d37f0..d0c3b7700 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h @@ -45,12 +45,15 @@ class UAVObjectBrowserWidget : public QWidget public: UAVObjectBrowserWidget(QWidget *parent = 0); ~UAVObjectBrowserWidget(); - void setRecentlyUpdatedColor(QColor color) { m_model->setRecentlyUpdatedColor(color); } - void setManuallyChangedColor(QColor color) { m_model->setManuallyChangedColor(color); } - void setRecentlyUpdatedTimeout(int timeout) { m_model->setRecentlyUpdatedTimeout(timeout); } + void setRecentlyUpdatedColor(QColor color) { m_recentlyUpdatedColor = color; m_model->setRecentlyUpdatedColor(color); } + void setManuallyChangedColor(QColor color) { m_manuallyChangedColor = color; m_model->setManuallyChangedColor(color); } + void setRecentlyUpdatedTimeout(int timeout) { m_recentlyUpdatedTimeout = timeout; m_model->setRecentlyUpdatedTimeout(timeout); } + void setOnlyHilightChangedValues(bool hilight) { m_onlyHilightChangedValues = hilight; m_model->setOnlyHilightChangedValues(hilight); } + public slots: void showMetaData(bool show); + void categorize(bool categorize); private slots: void sendUpdate(); @@ -66,6 +69,11 @@ private: Ui_UAVObjectBrowser *m_browser; UAVObjectTreeModel *m_model; + int m_recentlyUpdatedTimeout; + QColor m_recentlyUpdatedColor; + QColor m_manuallyChangedColor; + bool m_onlyHilightChangedValues; + void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj); void enableSendRequest(bool enable); ObjectTreeItem *findCurrentObjectTreeItem(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp index 120d9d0d8..3025e8dc4 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp @@ -38,7 +38,7 @@ #include #include -UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent) : +UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent, bool categorize) : QAbstractItemModel(parent), m_recentlyUpdatedTimeout(500), // ms m_recentlyUpdatedColor(QColor(255, 230, 230)), @@ -53,7 +53,7 @@ UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent) : connect(objManager, SIGNAL(newInstance(UAVObject*)), this, SLOT(newObject(UAVObject*))); TreeItem::setHighlightTime(m_recentlyUpdatedTimeout); - setupModelData(objManager); + setupModelData(objManager, categorize); } UAVObjectTreeModel::~UAVObjectTreeModel() @@ -62,7 +62,7 @@ UAVObjectTreeModel::~UAVObjectTreeModel() delete m_rootItem; } -void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager) +void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager, bool categorize) { // root QList rootData; @@ -82,7 +82,7 @@ void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager) QList< QList > objList = objManager->getDataObjects(); foreach (QList list, objList) { foreach (UAVDataObject* obj, list) { - addDataObject(obj); + addDataObject(obj, categorize); } } } @@ -90,33 +90,62 @@ void UAVObjectTreeModel::setupModelData(UAVObjectManager *objManager) void UAVObjectTreeModel::newObject(UAVObject *obj) { UAVDataObject *dobj = qobject_cast(obj); - if (dobj) + if (dobj) { addDataObject(dobj); -} - -void UAVObjectTreeModel::addDataObject(UAVDataObject *obj) -{ - TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree; - if (root->objIds().contains(obj->getObjID())) { - int index = root->objIds().indexOf(obj->getObjID()); - addInstance(obj, root->child(index)); - } else { - DataObjectTreeItem *data = new DataObjectTreeItem(obj->getName() + " (" + QString::number(obj->getNumBytes()) + " bytes)"); - data->setHighlightManager(m_highlightManager); - connect(data, SIGNAL(updateHighlight(TreeItem*)), this, SLOT(updateHighlight(TreeItem*))); - int index = root->nameIndex(obj->getName()); - root->insert(index, data); - root->insertObjId(index, obj->getObjID()); - UAVMetaObject *meta = obj->getMetaObject(); - addMetaObject(meta, data); - addInstance(obj, data); } } -void UAVObjectTreeModel::addMetaObject(UAVMetaObject *obj, TreeItem *parent) +void UAVObjectTreeModel::addDataObject(UAVDataObject *obj, bool categorize) +{ + TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree; + + TreeItem* parent = root; + + if(categorize && obj->getCategory() != 0 && !obj->getCategory().isEmpty()) { + QStringList categoryPath = obj->getCategory().split('/'); + parent = createCategoryItems(categoryPath, root); + } + + ObjectTreeItem* existing = root->findDataObjectTreeItemByObjectId(obj->getObjID()); + if (existing) { + addInstance(obj, existing); + } else { + DataObjectTreeItem *dataTreeItem = new DataObjectTreeItem(obj->getName() + " (" + QString::number(obj->getNumBytes()) + " bytes)"); + dataTreeItem->setHighlightManager(m_highlightManager); + connect(dataTreeItem, SIGNAL(updateHighlight(TreeItem*)), this, SLOT(updateHighlight(TreeItem*))); + parent->insertChild(dataTreeItem); + root->addObjectTreeItem(obj->getObjID(), dataTreeItem); + UAVMetaObject *meta = obj->getMetaObject(); + MetaObjectTreeItem* metaTreeItem = addMetaObject(meta, dataTreeItem); + root->addMetaObjectTreeItem(meta->getObjID(), metaTreeItem); + addInstance(obj, dataTreeItem); + } +} + +TreeItem* UAVObjectTreeModel::createCategoryItems(QStringList categoryPath, TreeItem* root) +{ + TreeItem* parent = root; + foreach(QString category, categoryPath) { + TreeItem* existing = parent->findChildByName(category); + if(!existing) { + TreeItem* categoryItem = new TreeItem(category); + connect(categoryItem, SIGNAL(updateHighlight(TreeItem*)), this, SLOT(updateHighlight(TreeItem*))); + categoryItem->setHighlightManager(m_highlightManager); + parent->insertChild(categoryItem); + parent = categoryItem; + } + else { + parent = existing; + } + } + return parent; +} + +MetaObjectTreeItem* UAVObjectTreeModel::addMetaObject(UAVMetaObject *obj, TreeItem *parent) { connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(highlightUpdatedObject(UAVObject*))); MetaObjectTreeItem *meta = new MetaObjectTreeItem(obj, tr("Meta Data")); + meta->setHighlightManager(m_highlightManager); connect(meta, SIGNAL(updateHighlight(TreeItem*)), this, SLOT(updateHighlight(TreeItem*))); foreach (UAVObjectField *field, obj->getFields()) { @@ -127,6 +156,7 @@ void UAVObjectTreeModel::addMetaObject(UAVMetaObject *obj, TreeItem *parent) } } parent->appendChild(meta); + return meta; } void UAVObjectTreeModel::addInstance(UAVObject *obj, TreeItem *parent) @@ -153,7 +183,6 @@ void UAVObjectTreeModel::addInstance(UAVObject *obj, TreeItem *parent) } } - void UAVObjectTreeModel::addArrayField(UAVObjectField *field, TreeItem *parent) { TreeItem *item = new ArrayFieldTreeItem(field->getName()); @@ -221,7 +250,7 @@ QModelIndex UAVObjectTreeModel::index(int row, int column, const QModelIndex &pa else parentItem = static_cast(parent.internalPointer()); - TreeItem *childItem = parentItem->child(row); + TreeItem *childItem = parentItem->getChild(row); if (childItem) return createIndex(row, column, childItem); else @@ -281,15 +310,31 @@ int UAVObjectTreeModel::columnCount(const QModelIndex &parent) const return m_rootItem->columnCount(); } +QList UAVObjectTreeModel::getMetaDataIndexes() +{ + QList metaIndexes; + foreach(MetaObjectTreeItem *metaItem , m_settingsTree->getMetaObjectItems()) + { + metaIndexes.append(index(metaItem)); + } + + foreach(MetaObjectTreeItem *metaItem , m_nonSettingsTree->getMetaObjectItems()) + { + metaIndexes.append(index(metaItem)); + } + return metaIndexes; +} + QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) - return QVariant(); + return QVariant(); if (index.column() == TreeItem::dataColumn && role == Qt::EditRole) { TreeItem *item = static_cast(index.internalPointer()); return item->data(index.column()); } + // if (role == Qt::DecorationRole) // return QIcon(":/core/images/openpilot_logo_128.png"); @@ -301,16 +346,17 @@ QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const TreeItem *item = static_cast(index.internalPointer()); if (index.column() == 0 && role == Qt::BackgroundRole) { - ObjectTreeItem *objItem = dynamic_cast(item); - if (objItem && objItem->highlighted()) + if (!dynamic_cast(item) && item->highlighted()) return QVariant(m_recentlyUpdatedColor); } + if (index.column() == TreeItem::dataColumn && role == Qt::BackgroundRole) { FieldTreeItem *fieldItem = dynamic_cast(item); if (fieldItem && fieldItem->highlighted()) return QVariant(m_recentlyUpdatedColor); + if (fieldItem && fieldItem->changed()) - return QVariant(m_manuallyChangedColor); + return QVariant(m_manuallyChangedColor); } if (role != Qt::DisplayRole) @@ -364,58 +410,42 @@ void UAVObjectTreeModel::highlightUpdatedObject(UAVObject *obj) Q_ASSERT(obj); ObjectTreeItem *item = findObjectTreeItem(obj); Q_ASSERT(item); + if(!m_onlyHilightChangedValues){ + item->setHighlight(true); + } item->update(); - QModelIndex itemIndex = index(item); - Q_ASSERT(itemIndex != QModelIndex()); - emit dataChanged(itemIndex, itemIndex); + if(!m_onlyHilightChangedValues){ + QModelIndex itemIndex = index(item); + Q_ASSERT(itemIndex != QModelIndex()); + emit dataChanged(itemIndex, itemIndex); + } } ObjectTreeItem *UAVObjectTreeModel::findObjectTreeItem(UAVObject *object) { - UAVDataObject *dobj = qobject_cast(object); - UAVMetaObject *mobj = qobject_cast(object); - Q_ASSERT(dobj || mobj); - if (dobj) { - return findDataObjectTreeItem(dobj); + UAVDataObject *dataObject = qobject_cast(object); + UAVMetaObject *metaObject = qobject_cast(object); + Q_ASSERT(dataObject || metaObject); + if (dataObject) { + return findDataObjectTreeItem(dataObject); } else { - dobj = qobject_cast(mobj->getParentObject()); - Q_ASSERT(dobj); - ObjectTreeItem *dItem = findDataObjectTreeItem(dobj); - Q_ASSERT(dItem); - Q_ASSERT(dItem->object()); - if (!dItem->object()->isSingleInstance()) - dItem = dynamic_cast(dItem->parent()); - foreach (TreeItem *child, dItem->treeChildren()) { - MetaObjectTreeItem *mItem = dynamic_cast(child); - if (mItem && mItem->object()) { - Q_ASSERT(mItem->object() == mobj); - return mItem; - } - } + return findMetaObjectTreeItem(metaObject); } - return 0; } -DataObjectTreeItem *UAVObjectTreeModel::findDataObjectTreeItem(UAVDataObject *object) +DataObjectTreeItem* UAVObjectTreeModel::findDataObjectTreeItem(UAVDataObject *obj) { - Q_ASSERT(object); - TopTreeItem *root = object->isSettings() ? m_settingsTree : m_nonSettingsTree; - foreach (TreeItem *child, root->treeChildren()) { - DataObjectTreeItem *dItem = dynamic_cast(child); - if (dItem && dItem->object() && dItem->object()->isSingleInstance()) { - if(dItem->object() == object) { - return dItem; - } - } else { - foreach (TreeItem *c, dItem->treeChildren()) { - DataObjectTreeItem *d = dynamic_cast(c); - if (d && d->object() == object) - return d; - } - } - } - return 0; + TopTreeItem *root = obj->isSettings() ? m_settingsTree : m_nonSettingsTree; + return root->findDataObjectTreeItemByObjectId(obj->getObjID()); +} + +MetaObjectTreeItem* UAVObjectTreeModel::findMetaObjectTreeItem(UAVMetaObject *obj) +{ + UAVDataObject *dataObject = qobject_cast(obj->getParentObject()); + Q_ASSERT(dataObject); + TopTreeItem *root = dataObject->isSettings() ? m_settingsTree : m_nonSettingsTree; + return root->findMetaObjectTreeItemByObjectId(obj->getObjID()); } void UAVObjectTreeModel::updateHighlight(TreeItem *item) diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h index d9787e3a7..8d1d5a7d7 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h @@ -31,6 +31,7 @@ #include "treeitem.h" #include #include +#include #include class TopTreeItem; @@ -48,7 +49,7 @@ class UAVObjectTreeModel : public QAbstractItemModel { Q_OBJECT public: - explicit UAVObjectTreeModel(QObject *parent = 0); + explicit UAVObjectTreeModel(QObject *parent = 0, bool categorize=true); ~UAVObjectTreeModel(); QVariant data(const QModelIndex &index, int role) const; @@ -68,6 +69,9 @@ public: m_recentlyUpdatedTimeout = timeout; TreeItem::setHighlightTime(timeout); } + void setOnlyHilightChangedValues(bool hilight) {m_onlyHilightChangedValues = hilight; } + + QList getMetaDataIndexes(); signals: @@ -79,17 +83,20 @@ private slots: void updateHighlight(TreeItem*); private: + void setupModelData(UAVObjectManager *objManager, bool categorize = true); QModelIndex index(TreeItem *item); - void addDataObject(UAVDataObject *obj); - void addMetaObject(UAVMetaObject *obj, TreeItem *parent); + void addDataObject(UAVDataObject *obj, bool categorize = true); + MetaObjectTreeItem *addMetaObject(UAVMetaObject *obj, TreeItem *parent); void addArrayField(UAVObjectField *field, TreeItem *parent); - void addSingleField(int index, UAVObjectField *field, TreeItem *parent); void addInstance(UAVObject *obj, TreeItem *parent); + + TreeItem *createCategoryItems(QStringList categoryPath, TreeItem *root); + QString updateMode(quint8 updateMode); - void setupModelData(UAVObjectManager *objManager); ObjectTreeItem *findObjectTreeItem(UAVObject *obj); DataObjectTreeItem *findDataObjectTreeItem(UAVDataObject *obj); + MetaObjectTreeItem *findMetaObjectTreeItem(UAVMetaObject *obj); TreeItem *m_rootItem; TopTreeItem *m_settingsTree; @@ -97,6 +104,7 @@ private: int m_recentlyUpdatedTimeout; QColor m_recentlyUpdatedColor; QColor m_manuallyChangedColor; + bool m_onlyHilightChangedValues; // Highlight manager to handle highlighting of tree items. HighLightManager *m_highlightManager; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp index e190b4f27..2805c9a1f 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -UAVMetaObject::UAVMetaObject(quint32 objID, const QString& name, UAVObject* parent): +UAVMetaObject::UAVMetaObject(quint32 objID, const QString& name, UAVObject *parent): UAVObject(objID, true, name) { this->parent = parent; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp index 47960b060..d01caba21 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp @@ -145,6 +145,22 @@ void UAVObject::setDescription(const QString& description) this->description = description; } +/** + * Get the category of the object + */ +QString UAVObject::getCategory() +{ + return category; +} + +/** + * Set the category of the object + */ +void UAVObject::setCategory(const QString& category) +{ + this->category = category; +} + /** * Get the total number of bytes of the object's data diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h index 0962ea73d..d092c6731 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h @@ -103,6 +103,7 @@ public: quint32 getInstID(); bool isSingleInstance(); QString getName(); + QString getCategory(); QString getDescription(); quint32 getNumBytes(); qint32 pack(quint8* dataOut); @@ -163,6 +164,7 @@ protected: bool isSingleInst; QString name; QString description; + QString category; quint32 numBytes; QMutex* mutex; quint8* data; @@ -170,6 +172,7 @@ protected: void initializeFields(QList& fields, quint8* data, quint32 numBytes); void setDescription(const QString& description); + void setCategory(const QString& category); }; #endif // UAVOBJECT_H diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp index 58aa84ead..f08f5e434 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp @@ -8,26 +8,26 @@ * @{ * @addtogroup UAVObjectsPlugin UAVObjects Plugin * @{ - * - * @note Object definition file: $(XMLFILE). + * + * @note Object definition file: $(XMLFILE). * This is an automatically generated file. * DO NOT modify manually. * * @brief The UAVUObjects GCS plugin *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "$(NAMELC).h" @@ -35,6 +35,7 @@ const QString $(NAME)::NAME = QString("$(NAME)"); const QString $(NAME)::DESCRIPTION = QString("$(DESCRIPTION)"); +const QString $(NAME)::CATEGORY = QString("$(CATEGORY)"); /** * Constructor @@ -51,6 +52,9 @@ $(FIELDSINIT) // Set the object description setDescription(DESCRIPTION); + // Set the Category of this object type + setCategory(CATEGORY); + connect(this, SIGNAL(objectUpdated(UAVObject*)), SLOT(emitNotifications())); } diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h index 9b5a766ee..f68eebe49 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h @@ -54,6 +54,7 @@ $(DATAFIELDINFO) static const quint32 OBJID = $(OBJIDHEX); static const QString NAME; static const QString DESCRIPTION; + static const QString CATEGORY; static const bool ISSINGLEINST = $(ISSINGLEINST); static const bool ISSETTINGS = $(ISSETTINGS); static const quint32 NUMBYTES = sizeof(DataFields); diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.m4 b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.m4 new file mode 100644 index 000000000..05b926517 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.m4 @@ -0,0 +1 @@ +define(_CUSTOM_AC_OUTPUT_, plugins/op-uavtalk/Makefile plugins/op-uavobjects/Makefile) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.make b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.make new file mode 100644 index 000000000..25b3001e5 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.make @@ -0,0 +1,3 @@ +_CUSTOM_SUBDIRS_ = \ + op-uavtalk \ + op-uavobjects diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.nmake b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.nmake new file mode 100644 index 000000000..38d334076 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/Custom.nmake @@ -0,0 +1,63 @@ +# +# $Id$ +# + +include ..\config.nmake + +# +# Custom plugin build template. +# +# If you need to develop a custom plugin (a plugin not yet released to the +# public) this file is for you. +# +# To generate a custom plugin: +# +# 1. Create the new plugin directory and implement the plugin (at least to be +# ready for a first build try). The easiest way to do this is to copy an +# existing plugin and modify the contents. +# 2. Rename this file to Custom.nmake +# 3. Replace every appearance of foo in this file with your plugin dir name +# 4. Build Wireshark as usual +# + +all: op-uavtalk op-uavobjects + +op-uavtalk:: + cd op-uavtalk + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake + cd .. + +op-uavobjects:: + cd op-uavobjects + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake + cd .. + +clean: + cd op-uavtalk + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean + cd .. + cd op-uavobjects + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean + cd .. + +distclean: clean + cd op-uavtalk + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean + cd .. + cd op-uavobjects + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean + cd .. + +maintainer-clean: distclean + cd op-uavtalk + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean + cd .. + cd op-uavobjects + $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean + cd .. + +install-plugins: +!IFDEF ENABLE_LIBWIRESHARK + xcopy op-uavtalk\*.dll ..\$(INSTALL_DIR)\plugins\$(VERSION) /d + xcopy op-uavobjects\*.dll ..\$(INSTALL_DIR)\plugins\$(VERSION) /d +!ENDIF diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/AUTHORS b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/AUTHORS new file mode 100644 index 000000000..43ab011a3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/AUTHORS @@ -0,0 +1,3 @@ +Author: +Stacey Sheldon + diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/CMakeLists.txt b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/CMakeLists.txt new file mode 100644 index 000000000..d5f880936 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/CMakeLists.txt @@ -0,0 +1,65 @@ +# CMakeLists.txt +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +set(DISSECTOR_SRC + packet-op-uavobjects.c +) + +set(PLUGIN_FILES + plugin.c + ${DISSECTOR_SRC} +) + +set(CLEAN_FILES + ${PLUGIN_FILES} +) + +if (WERROR) + set_source_files_properties( + ${CLEAN_FILES} + PROPERTIES + COMPILE_FLAGS -Werror + ) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +register_dissector_files(plugin.c + plugin + ${DISSECTOR_SRC} +) + +add_library(op_uavobjects ${LINK_MODE_MODULE} + ${PLUGIN_FILES} +) +set_target_properties(op_uavobjects PROPERTIES PREFIX "") +set_target_properties(op_uavobjects PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") + +target_link_libraries(op-uavobjects) + +install(TARGETS op-uavobjects + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} NAMELINK_SKIP + RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} +) + diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/COPYING b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/COPYING new file mode 100644 index 000000000..d60c31a97 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/ChangeLog b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/ChangeLog new file mode 100644 index 000000000..fe8e0fc38 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/ChangeLog @@ -0,0 +1,3 @@ +2012-06-16 Stacey Sheldon + + * initial version diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.am b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.am new file mode 100644 index 000000000..f82bc2160 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.am @@ -0,0 +1,131 @@ +# Makefile.am +# Automake file for OpenPilot UAVObject Dissector +# Copyright 2012, Stacey Sheldon +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +INCLUDES = -I$(top_srcdir) -I$(includedir) + +include Makefile.common + +if HAVE_WARNINGS_AS_ERRORS +AM_CFLAGS = -Werror +endif + +plugindir = @plugindir@ + +plugin_LTLIBRARIES = op_uavobjects.la +op_uavobjects_la_SOURCES = \ + plugin.c \ + moduleinfo.h \ + $(DISSECTOR_SRC) \ + $(DISSECTOR_SUPPORT_SRC) \ + $(DISSECTOR_INCLUDES) +op_uavobjects_la_LDFLAGS = -module -avoid-version +op_uavobjects_la_LIBADD = @PLUGIN_LIBS@ + +# Libs must be cleared, or else libtool won't create a shared module. +# If your module needs to be linked against any particular libraries, +# add them here. +LIBS = + +# +# Build plugin.c, which contains the plugin version[] string, a +# function plugin_register() that calls the register routines for all +# protocols, and a function plugin_reg_handoff() that calls the handoff +# registration routines for all protocols. +# +# We do this by scanning sources. If that turns out to be too slow, +# maybe we could just require every .o file to have an register routine +# of a given name (packet-aarp.o -> proto_register_aarp, etc.). +# +# Formatting conventions: The name of the proto_register_* routines an +# proto_reg_handoff_* routines must start in column zero, or must be +# preceded only by "void " starting in column zero, and must not be +# inside #if. +# +# DISSECTOR_SRC is assumed to have all the files that need to be scanned. +# +# For some unknown reason, having a big "for" loop in the Makefile +# to scan all the files doesn't work with some "make"s; they seem to +# pass only the first few names in the list to the shell, for some +# reason. +# +# Therefore, we have a script to generate the plugin.c file. +# The shell script runs slowly, as multiple greps and seds are run +# for each input file; this is especially slow on Windows. Therefore, +# if Python is present (as indicated by PYTHON being defined), we run +# a faster Python script to do that work instead. +# +# The first argument is the directory in which the source files live. +# The second argument is "plugin", to indicate that we should build +# a plugin.c file for a plugin. +# All subsequent arguments are the files to scan. +# +plugin.c: $(DISSECTOR_SRC) Makefile.common $(top_srcdir)/tools/make-dissector-reg \ + $(top_srcdir)/tools/make-dissector-reg.py + @if test -n "$(PYTHON)"; then \ + echo Making plugin.c with python ; \ + $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \ + plugin $(DISSECTOR_SRC) ; \ + else \ + echo Making plugin.c with shell script ; \ + $(top_srcdir)/tools/make-dissector-reg $(srcdir) \ + $(plugin_src) plugin $(DISSECTOR_SRC) ; \ + fi + +# +# Currently plugin.c can be included in the distribution because +# we always build all protocol dissectors. We used to have to check +# whether or not to build the snmp dissector. If we again need to +# variably build something, making plugin.c non-portable, uncomment +# the dist-hook line below. +# +# Oh, yuk. We don't want to include "plugin.c" in the distribution, as +# its contents depend on the configuration, and therefore we want it +# to be built when the first "make" is done; however, Automake insists +# on putting *all* source into the distribution. +# +# We work around this by having a "dist-hook" rule that deletes +# "plugin.c", so that "dist" won't pick it up. +# +#dist-hook: +# @rm -f $(distdir)/plugin.c + +CLEANFILES = \ + op-uavobjects \ + *~ + +MAINTAINERCLEANFILES = \ + Makefile.in \ + plugin.c + +EXTRA_DIST = \ + Makefile.common \ + Makefile.nmake \ + moduleinfo.nmake \ + plugin.rc.in \ + CMakeLists.txt + + +checkapi: + $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g abort -g termoutput -build $(DISSECTOR_SRC) $(DISSECTOR_INCLUDES) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.common-template b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.common-template new file mode 100644 index 000000000..8de04abdc --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.common-template @@ -0,0 +1,33 @@ +# Makefile.common for OpenPilot UAVObject Dissector plugin +# Contains the stuff from Makefile.am and Makefile.nmake that is +# a) common to both files and +# b) portable between both files +# Copyright 2012 Stacey Sheldon +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# the name of the plugin +PLUGIN_NAME = op-uavobjects + +# the dissector sources (without any helpers) +DISSECTOR_SRC = $(UAVOBJFILENAMES) + +DISSECTOR_INCLUDES = diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.nmake b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.nmake new file mode 100644 index 000000000..fecc441c1 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.nmake @@ -0,0 +1,104 @@ +# Makefile.nmake +# nmake file for Wireshark plugin +# +# $Id$ +# + +include ..\..\config.nmake +include moduleinfo.nmake + +include Makefile.common + +CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \ + /I../.. $(GLIB_CFLAGS) \ + /I$(PCAP_DIR)\include + +.c.obj:: + $(CC) $(CFLAGS) -Fd.\ -c $< + +LDFLAGS = $(PLUGIN_LDFLAGS) + +!IFDEF ENABLE_LIBWIRESHARK +LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib +CFLAGS=/D_NEED_VAR_IMPORT_ $(CFLAGS) + +DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj) + +DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj) + +OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) plugin.obj + +RESOURCE=$(PLUGIN_NAME).res + +all: $(PLUGIN_NAME).dll + +$(PLUGIN_NAME).rc : moduleinfo.nmake + sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \ + -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \ + -e s/@RC_VERSION@/$(RC_VERSION)/ \ + -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \ + -e s/@PACKAGE@/$(PACKAGE)/ \ + -e s/@VERSION@/$(VERSION)/ \ + -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \ + < plugin.rc.in > $@ + +$(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE) + link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \ + $(GLIB_LIBS) $(RESOURCE) + +# +# Build plugin.c, which contains the plugin version[] string, a +# function plugin_register() that calls the register routines for all +# protocols, and a function plugin_reg_handoff() that calls the handoff +# registration routines for all protocols. +# +# We do this by scanning sources. If that turns out to be too slow, +# maybe we could just require every .o file to have an register routine +# of a given name (packet-aarp.o -> proto_register_aarp, etc.). +# +# Formatting conventions: The name of the proto_register_* routines an +# proto_reg_handoff_* routines must start in column zero, or must be +# preceded only by "void " starting in column zero, and must not be +# inside #if. +# +# DISSECTOR_SRC is assumed to have all the files that need to be scanned. +# +# For some unknown reason, having a big "for" loop in the Makefile +# to scan all the files doesn't work with some "make"s; they seem to +# pass only the first few names in the list to the shell, for some +# reason. +# +# Therefore, we have a script to generate the plugin.c file. +# The shell script runs slowly, as multiple greps and seds are run +# for each input file; this is especially slow on Windows. Therefore, +# if Python is present (as indicated by PYTHON being defined), we run +# a faster Python script to do that work instead. +# +# The first argument is the directory in which the source files live. +# The second argument is "plugin", to indicate that we should build +# a plugin.c file for a plugin. +# All subsequent arguments are the files to scan. +# +!IFDEF PYTHON +plugin.c: $(DISSECTOR_SRC) moduleinfo.h Makefile.common ../../tools/make-dissector-reg.py + @echo Making plugin.c (using python) + @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(DISSECTOR_SRC) +!ELSE +plugin.c: $(DISSECTOR_SRC) moduleinfo.h Makefile.common ../../tools/make-dissector-reg + @echo Making plugin.c (using sh) + @$(SH) ../../tools/make-dissector-reg . plugin $(DISSECTOR_SRC) +!ENDIF + +!ENDIF + +clean: + rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb *.sbr \ + $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \ + $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc + +distclean: clean + +maintainer-clean: distclean + +checkapi: + $(PERL) ../../tools/checkAPIs.pl -g abort -g termoutput -build $(DISSECTOR_SRC) $(DISSECTOR_INCLUDES) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/moduleinfo.h b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/moduleinfo.h new file mode 100644 index 000000000..401807f15 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/moduleinfo.h @@ -0,0 +1,16 @@ +/* Included *after* config.h, in order to re-define these macros */ + +#ifdef PACKAGE +#undef PACKAGE +#endif + +/* Name of package */ +#define PACKAGE "op-uavobjects" + + +#ifdef VERSION +#undef VERSION +#endif + +/* Version number of package */ +#define VERSION "0.0.1" diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/moduleinfo.nmake b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/moduleinfo.nmake new file mode 100644 index 000000000..f85a406cd --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/moduleinfo.nmake @@ -0,0 +1,28 @@ +# +# $Id$ +# + +# The name +PACKAGE=op-uavobjects + +# The version +MODULE_VERSION_MAJOR=0 +MODULE_VERSION_MINOR=0 +MODULE_VERSION_MICRO=1 +MODULE_VERSION_EXTRA=0 + +# +# The RC_VERSION should be comma-separated, not dot-separated, +# as per Graham Bloice's message in +# +# http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html +# +# "The RC_VERSION variable in config.nmake should be comma separated. +# This allows the resources to be built correctly and the version +# number to be correctly displayed in the explorer properties dialog +# for the executables, and XP's tooltip, rather than 0.0.0.0." +# + +MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA) +RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA) + diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/packet-op-uavobjects-template.c b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/packet-op-uavobjects-template.c new file mode 100644 index 000000000..f444fd595 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/packet-op-uavobjects-template.c @@ -0,0 +1,112 @@ +/* + * !!! Autogenerated from $(XMLFILE) Do NOT Edit !!! + * + * Routines for OpenPilot UAVObject dissection + * Copyright 2012 Stacey Sheldon + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include /* ptvcursor_* */ + +#include +#include + +static int proto_uavo = -1; + +/* Subtree expansion tracking */ +$(SUBTREESTATICS) + +/* Field handles */ +$(FIELDHANDLES) + +/* Enum string mappings */ +$(ENUMFIELDNAMES) + +void proto_reg_handoff_op_uavobjects_$(NAMELC)(void); + +static int dissect_uavo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + int offset = 0; + + col_append_str(pinfo->cinfo, COL_INFO, "($(NAME))"); + + if (tree) { /* we are being asked for details */ + proto_tree *uavo_tree = NULL; + ptvcursor_t * cursor; + proto_item *ti = NULL; + + /* Add a top-level entry to the dissector tree for this protocol */ + ti = proto_tree_add_item(tree, proto_uavo, tvb, 0, -1, ENC_NA); + + /* Create a subtree to contain the dissection of this protocol */ + uavo_tree = proto_item_add_subtree(ti, ett_uavo); + + /* Dissect the packet and populate the subtree */ + cursor = ptvcursor_new(uavo_tree, tvb, 0); + + /* Populate the fields in this protocol */ +$(POPULATETREE) + + offset += ptvcursor_current_offset(cursor); + + ptvcursor_free(cursor); + } else { + offset = 0; + } + + return offset; +} + +void proto_register_op_objects_$(NAMELC)(void) +{ +$(HEADERFIELDS) + + /* Setup protocol subtree array */ + + static gint *ett[] = { + $(SUBTREES) + }; + + /* Register this protocol */ + proto_uavo = proto_register_protocol("UAVO $(NAME)", + "UAVO $(NAME)", + "uavo-$(NAMELC)"); + + /* Register the field definitions for this protocol */ + proto_register_subtree_array(ett, array_length(ett)); + proto_register_field_array(proto_uavo, hf, array_length(hf)); +} + +void proto_reg_handoff_op_uavobjects_$(NAMELC)(void) +{ + dissector_handle_t uavo_handle; + uavo_handle = new_create_dissector_handle(dissect_uavo, proto_uavo); + + /* Bind this protocol to its UAV ObjID in UAVTalk */ + dissector_add("uavtalk.objid", $(OBJIDHEX), uavo_handle); +} diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/plugin.rc.in b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/plugin.rc.in new file mode 100644 index 000000000..568dc07b4 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/plugin.rc.in @@ -0,0 +1,34 @@ +#include "winver.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @RC_MODULE_VERSION@ + PRODUCTVERSION @RC_VERSION@ + FILEFLAGSMASK 0x0L +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0 +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "The Wireshark developer community, http://www.wireshark.org/\0" + VALUE "FileDescription", "@PACKAGE@ dissector\0" + VALUE "FileVersion", "@MODULE_VERSION@\0" + VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0" + VALUE "LegalCopyright", "Copyright 1998 Gerald Combs , Gilbert Ramirez and others\0" + VALUE "OriginalFilename", "@PLUGIN_NAME@.dll\0" + VALUE "ProductName", "Wireshark\0" + VALUE "ProductVersion", "@VERSION@\0" + VALUE "Comments", "Build with @MSVC_VARIANT@\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/AUTHORS b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/AUTHORS new file mode 100644 index 000000000..43ab011a3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/AUTHORS @@ -0,0 +1,3 @@ +Author: +Stacey Sheldon + diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/CMakeLists.txt b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/CMakeLists.txt new file mode 100644 index 000000000..59830ea71 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/CMakeLists.txt @@ -0,0 +1,65 @@ +# CMakeLists.txt +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +set(DISSECTOR_SRC + packet-op-uavtalk.c +) + +set(PLUGIN_FILES + plugin.c + ${DISSECTOR_SRC} +) + +set(CLEAN_FILES + ${PLUGIN_FILES} +) + +if (WERROR) + set_source_files_properties( + ${CLEAN_FILES} + PROPERTIES + COMPILE_FLAGS -Werror + ) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +register_dissector_files(plugin.c + plugin + ${DISSECTOR_SRC} +) + +add_library(unistim ${LINK_MODE_MODULE} + ${PLUGIN_FILES} +) +set_target_properties(unistim PROPERTIES PREFIX "") +set_target_properties(unistim PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") + +target_link_libraries(op-uavtalk) + +install(TARGETS op-uavtalk + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} NAMELINK_SKIP + RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} +) + diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/COPYING b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/COPYING new file mode 100644 index 000000000..d60c31a97 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/ChangeLog b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/ChangeLog new file mode 100644 index 000000000..fe8e0fc38 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/ChangeLog @@ -0,0 +1,3 @@ +2012-06-16 Stacey Sheldon + + * initial version diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.am b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.am new file mode 100644 index 000000000..6df4814a2 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.am @@ -0,0 +1,131 @@ +# Makefile.am +# Automake file for OpenPilot UAVTalk protocol +# Copyright 2012, Stacey Sheldon +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +INCLUDES = -I$(top_srcdir) -I$(includedir) + +include Makefile.common + +if HAVE_WARNINGS_AS_ERRORS +AM_CFLAGS = -Werror +endif + +plugindir = @plugindir@ + +plugin_LTLIBRARIES = op_uavtalk.la +op_uavtalk_la_SOURCES = \ + plugin.c \ + moduleinfo.h \ + $(DISSECTOR_SRC) \ + $(DISSECTOR_SUPPORT_SRC) \ + $(DISSECTOR_INCLUDES) +op_uavtalk_la_LDFLAGS = -module -avoid-version +op_uavtalk_la_LIBADD = @PLUGIN_LIBS@ + +# Libs must be cleared, or else libtool won't create a shared module. +# If your module needs to be linked against any particular libraries, +# add them here. +LIBS = + +# +# Build plugin.c, which contains the plugin version[] string, a +# function plugin_register() that calls the register routines for all +# protocols, and a function plugin_reg_handoff() that calls the handoff +# registration routines for all protocols. +# +# We do this by scanning sources. If that turns out to be too slow, +# maybe we could just require every .o file to have an register routine +# of a given name (packet-aarp.o -> proto_register_aarp, etc.). +# +# Formatting conventions: The name of the proto_register_* routines an +# proto_reg_handoff_* routines must start in column zero, or must be +# preceded only by "void " starting in column zero, and must not be +# inside #if. +# +# DISSECTOR_SRC is assumed to have all the files that need to be scanned. +# +# For some unknown reason, having a big "for" loop in the Makefile +# to scan all the files doesn't work with some "make"s; they seem to +# pass only the first few names in the list to the shell, for some +# reason. +# +# Therefore, we have a script to generate the plugin.c file. +# The shell script runs slowly, as multiple greps and seds are run +# for each input file; this is especially slow on Windows. Therefore, +# if Python is present (as indicated by PYTHON being defined), we run +# a faster Python script to do that work instead. +# +# The first argument is the directory in which the source files live. +# The second argument is "plugin", to indicate that we should build +# a plugin.c file for a plugin. +# All subsequent arguments are the files to scan. +# +plugin.c: $(DISSECTOR_SRC) Makefile.common $(top_srcdir)/tools/make-dissector-reg \ + $(top_srcdir)/tools/make-dissector-reg.py + @if test -n "$(PYTHON)"; then \ + echo Making plugin.c with python ; \ + $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \ + plugin $(DISSECTOR_SRC) ; \ + else \ + echo Making plugin.c with shell script ; \ + $(top_srcdir)/tools/make-dissector-reg $(srcdir) \ + $(plugin_src) plugin $(DISSECTOR_SRC) ; \ + fi + +# +# Currently plugin.c can be included in the distribution because +# we always build all protocol dissectors. We used to have to check +# whether or not to build the snmp dissector. If we again need to +# variably build something, making plugin.c non-portable, uncomment +# the dist-hook line below. +# +# Oh, yuk. We don't want to include "plugin.c" in the distribution, as +# its contents depend on the configuration, and therefore we want it +# to be built when the first "make" is done; however, Automake insists +# on putting *all* source into the distribution. +# +# We work around this by having a "dist-hook" rule that deletes +# "plugin.c", so that "dist" won't pick it up. +# +#dist-hook: +# @rm -f $(distdir)/plugin.c + +CLEANFILES = \ + op-uavtalk \ + *~ + +MAINTAINERCLEANFILES = \ + Makefile.in \ + plugin.c + +EXTRA_DIST = \ + Makefile.common \ + Makefile.nmake \ + moduleinfo.nmake \ + plugin.rc.in \ + CMakeLists.txt + + +checkapi: + $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g abort -g termoutput -build $(DISSECTOR_SRC) $(DISSECTOR_INCLUDES) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.common b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.common new file mode 100644 index 000000000..89bea93b6 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.common @@ -0,0 +1,34 @@ +# Makefile.common for OpenPilot UAVTalk plugin +# Contains the stuff from Makefile.am and Makefile.nmake that is +# a) common to both files and +# b) portable between both files +# Copyright 2012 Stacey Sheldon +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# the name of the plugin +PLUGIN_NAME = op-uavtalk + +# the dissector sources (without any helpers) +DISSECTOR_SRC = \ + packet-op-uavtalk.c + +DISSECTOR_INCLUDES = diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.nmake b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.nmake new file mode 100644 index 000000000..fecc441c1 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/Makefile.nmake @@ -0,0 +1,104 @@ +# Makefile.nmake +# nmake file for Wireshark plugin +# +# $Id$ +# + +include ..\..\config.nmake +include moduleinfo.nmake + +include Makefile.common + +CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \ + /I../.. $(GLIB_CFLAGS) \ + /I$(PCAP_DIR)\include + +.c.obj:: + $(CC) $(CFLAGS) -Fd.\ -c $< + +LDFLAGS = $(PLUGIN_LDFLAGS) + +!IFDEF ENABLE_LIBWIRESHARK +LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib +CFLAGS=/D_NEED_VAR_IMPORT_ $(CFLAGS) + +DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj) + +DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj) + +OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) plugin.obj + +RESOURCE=$(PLUGIN_NAME).res + +all: $(PLUGIN_NAME).dll + +$(PLUGIN_NAME).rc : moduleinfo.nmake + sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \ + -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \ + -e s/@RC_VERSION@/$(RC_VERSION)/ \ + -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \ + -e s/@PACKAGE@/$(PACKAGE)/ \ + -e s/@VERSION@/$(VERSION)/ \ + -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \ + < plugin.rc.in > $@ + +$(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE) + link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \ + $(GLIB_LIBS) $(RESOURCE) + +# +# Build plugin.c, which contains the plugin version[] string, a +# function plugin_register() that calls the register routines for all +# protocols, and a function plugin_reg_handoff() that calls the handoff +# registration routines for all protocols. +# +# We do this by scanning sources. If that turns out to be too slow, +# maybe we could just require every .o file to have an register routine +# of a given name (packet-aarp.o -> proto_register_aarp, etc.). +# +# Formatting conventions: The name of the proto_register_* routines an +# proto_reg_handoff_* routines must start in column zero, or must be +# preceded only by "void " starting in column zero, and must not be +# inside #if. +# +# DISSECTOR_SRC is assumed to have all the files that need to be scanned. +# +# For some unknown reason, having a big "for" loop in the Makefile +# to scan all the files doesn't work with some "make"s; they seem to +# pass only the first few names in the list to the shell, for some +# reason. +# +# Therefore, we have a script to generate the plugin.c file. +# The shell script runs slowly, as multiple greps and seds are run +# for each input file; this is especially slow on Windows. Therefore, +# if Python is present (as indicated by PYTHON being defined), we run +# a faster Python script to do that work instead. +# +# The first argument is the directory in which the source files live. +# The second argument is "plugin", to indicate that we should build +# a plugin.c file for a plugin. +# All subsequent arguments are the files to scan. +# +!IFDEF PYTHON +plugin.c: $(DISSECTOR_SRC) moduleinfo.h Makefile.common ../../tools/make-dissector-reg.py + @echo Making plugin.c (using python) + @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(DISSECTOR_SRC) +!ELSE +plugin.c: $(DISSECTOR_SRC) moduleinfo.h Makefile.common ../../tools/make-dissector-reg + @echo Making plugin.c (using sh) + @$(SH) ../../tools/make-dissector-reg . plugin $(DISSECTOR_SRC) +!ENDIF + +!ENDIF + +clean: + rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb *.sbr \ + $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \ + $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc + +distclean: clean + +maintainer-clean: distclean + +checkapi: + $(PERL) ../../tools/checkAPIs.pl -g abort -g termoutput -build $(DISSECTOR_SRC) $(DISSECTOR_INCLUDES) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/moduleinfo.h b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/moduleinfo.h new file mode 100644 index 000000000..06f48ae1e --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/moduleinfo.h @@ -0,0 +1,16 @@ +/* Included *after* config.h, in order to re-define these macros */ + +#ifdef PACKAGE +#undef PACKAGE +#endif + +/* Name of package */ +#define PACKAGE "op-uavtalk" + + +#ifdef VERSION +#undef VERSION +#endif + +/* Version number of package */ +#define VERSION "0.0.1" diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/moduleinfo.nmake b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/moduleinfo.nmake new file mode 100644 index 000000000..abc8c9cb3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/moduleinfo.nmake @@ -0,0 +1,28 @@ +# +# $Id$ +# + +# The name +PACKAGE=op-uavtalk + +# The version +MODULE_VERSION_MAJOR=0 +MODULE_VERSION_MINOR=0 +MODULE_VERSION_MICRO=1 +MODULE_VERSION_EXTRA=0 + +# +# The RC_VERSION should be comma-separated, not dot-separated, +# as per Graham Bloice's message in +# +# http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html +# +# "The RC_VERSION variable in config.nmake should be comma separated. +# This allows the resources to be built correctly and the version +# number to be correctly displayed in the explorer properties dialog +# for the executables, and XP's tooltip, rather than 0.0.0.0." +# + +MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA) +RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA) + diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/packet-op-uavtalk.c b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/packet-op-uavtalk.c new file mode 100644 index 000000000..df8134df8 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/packet-op-uavtalk.c @@ -0,0 +1,205 @@ +/* packet-op-uavtalk.c + * Routines for OpenPilot UAVTalk packet dissection + * Copyright 2012 Stacey Sheldon + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include /* ptvcursor_* */ + +#include +#include + +static guint global_op_uavtalk_port = 9000; + +static int proto_op_uavtalk = -1; + +static gint ett_op_uavtalk = -1; + +static dissector_handle_t data_handle; +static dissector_table_t uavtalk_subdissector_table; + +static int hf_op_uavtalk_sync = -1; +static int hf_op_uavtalk_version = -1; +static int hf_op_uavtalk_type = -1; +static int hf_op_uavtalk_len = -1; +static int hf_op_uavtalk_objid = -1; +static int hf_op_uavtalk_crc8 = -1; + +#define UAVTALK_SYNC_VAL 0x3C + +static const value_string uavtalk_packet_types[]={ + { 0, "TxObj" }, + { 1, "GetObj" }, + { 2, "SetObjAckd" }, + { 3, "Ack" }, + { 4, "Nack" }, + { 0, NULL } +}; + +void proto_reg_handoff_op_uavtalk(void); + +#define UAVTALK_HEADER_SIZE 8 +#define UAVTALK_TRAILER_SIZE 1 +static int dissect_op_uavtalk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + gint offset = 0; + + guint8 packet_type = tvb_get_guint8(tvb, 1) & 0x7; + guint32 objid = tvb_get_letohl(tvb, 4); + guint32 payload_length = tvb_get_letohs(tvb, 2) - UAVTALK_HEADER_SIZE - UAVTALK_TRAILER_SIZE; + guint32 reported_length = tvb_reported_length(tvb); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "UAVTALK"); + /* Clear out stuff in the info column */ + col_clear(pinfo->cinfo, COL_INFO); + + col_append_fstr(pinfo->cinfo, COL_INFO, "%s: 0x%08x", val_to_str_const(packet_type, uavtalk_packet_types, ""), objid); + if (objid & 0x1) { + col_append_str(pinfo->cinfo, COL_INFO, "(META)"); + } + + + if (tree) { /* we are being asked for details */ + proto_tree *op_uavtalk_tree = NULL; + ptvcursor_t * cursor; + proto_item *ti = NULL; + + /* Add a top-level entry to the dissector tree for this protocol */ + ti = proto_tree_add_item(tree, proto_op_uavtalk, tvb, 0, -1, ENC_NA); + + /* Create a subtree to contain the dissection of this protocol */ + op_uavtalk_tree = proto_item_add_subtree(ti, ett_op_uavtalk); + + /* Dissect the packet and populate the subtree */ + cursor = ptvcursor_new(op_uavtalk_tree, tvb, 0); + + /* Populate the fields in this protocol */ + ptvcursor_add(cursor, hf_op_uavtalk_sync, 1, ENC_LITTLE_ENDIAN); + ptvcursor_add_no_advance(cursor, hf_op_uavtalk_version, 1, ENC_LITTLE_ENDIAN); + ptvcursor_add(cursor, hf_op_uavtalk_type, 1, ENC_LITTLE_ENDIAN); + ptvcursor_add(cursor, hf_op_uavtalk_len, 2, ENC_LITTLE_ENDIAN); + ptvcursor_add(cursor, hf_op_uavtalk_objid, 4, ENC_LITTLE_ENDIAN); + + offset = ptvcursor_current_offset(cursor); + + ptvcursor_free(cursor); + + proto_tree_add_item(op_uavtalk_tree, hf_op_uavtalk_crc8, tvb, reported_length - UAVTALK_TRAILER_SIZE, UAVTALK_TRAILER_SIZE, ENC_LITTLE_ENDIAN); + } else { + offset = UAVTALK_HEADER_SIZE; + } + + { + tvbuff_t * next_tvb = tvb_new_subset(tvb, offset, + reported_length - UAVTALK_HEADER_SIZE - UAVTALK_TRAILER_SIZE, + payload_length); + + /* Check if we have an embedded objid to decode */ + if ((packet_type == 0) || (packet_type == 2)) { + /* Call any registered subdissector for this objid */ + if (!dissector_try_uint(uavtalk_subdissector_table, objid, next_tvb, pinfo, tree)) { + /* No subdissector registered, use the default data dissector */ + call_dissector(data_handle, next_tvb, pinfo, tree); + } + } else { + /* Render any remaining data as raw bytes */ + call_dissector(data_handle, next_tvb, pinfo, tree); + } + } + + return UAVTALK_HEADER_SIZE + UAVTALK_TRAILER_SIZE; +} + +void proto_register_op_uavtalk(void) +{ + module_t * op_uavtalk_module; + + static hf_register_info hf[] = { + { &hf_op_uavtalk_sync, + { "Sync Byte", "uavtalk.sync", FT_UINT8, + BASE_HEX, NULL, 0x0, NULL, HFILL } + }, + { &hf_op_uavtalk_version, + { "Version", "uavtalk.ver", FT_UINT8, + BASE_DEC, NULL, 0xf8, NULL, HFILL } + }, + { &hf_op_uavtalk_type, + { "Type", "uavtalk.type", FT_UINT8, + BASE_HEX, VALS(uavtalk_packet_types), 0x07, NULL, HFILL } + }, + { &hf_op_uavtalk_len, + { "Length", "uavtalk.len", FT_UINT16, + BASE_DEC, NULL, 0x0, NULL, HFILL } + }, + { &hf_op_uavtalk_objid, + { "ObjID", "uavtalk.objid", FT_UINT32, + BASE_HEX, NULL, 0x0, NULL, HFILL } + }, + { &hf_op_uavtalk_crc8, + { "Crc8", "uavtalk.crc8", FT_UINT8, + BASE_HEX, NULL, 0x0, NULL, HFILL } + }, + }; + +/* Setup protocol subtree array */ + + static gint *ett[] = { + &ett_op_uavtalk + }; + + proto_op_uavtalk = proto_register_protocol("OpenPilot UAVTalk Protocol", + "UAVTALK", + "uavtalk"); + + /* Allow subdissectors for each objid to bind for decoding */ + uavtalk_subdissector_table = register_dissector_table("uavtalk.objid", "UAVObject ID", FT_UINT32, BASE_HEX); + + proto_register_subtree_array(ett, array_length(ett)); + proto_register_field_array(proto_op_uavtalk, hf, array_length(hf)); + + op_uavtalk_module = prefs_register_protocol(proto_op_uavtalk, proto_reg_handoff_op_uavtalk); + + prefs_register_uint_preference(op_uavtalk_module, "udp.port", "UAVTALK UDP port", + "UAVTALK port (default 9000)", 10, &global_op_uavtalk_port); +} + +void proto_reg_handoff_op_uavtalk(void) +{ + static dissector_handle_t op_uavtalk_handle; + + op_uavtalk_handle = new_create_dissector_handle(dissect_op_uavtalk, proto_op_uavtalk); + dissector_add_handle("udp.port", op_uavtalk_handle); /* for "decode as" */ + + if (global_op_uavtalk_port != 0) { + dissector_add_uint("udp.port", global_op_uavtalk_port, op_uavtalk_handle); + } + + /* Lookup the default dissector for raw data */ + data_handle = find_dissector("data"); +} diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/plugin.rc.in b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/plugin.rc.in new file mode 100644 index 000000000..568dc07b4 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavtalk/plugin.rc.in @@ -0,0 +1,34 @@ +#include "winver.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @RC_MODULE_VERSION@ + PRODUCTVERSION @RC_VERSION@ + FILEFLAGSMASK 0x0L +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0 +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "The Wireshark developer community, http://www.wireshark.org/\0" + VALUE "FileDescription", "@PACKAGE@ dissector\0" + VALUE "FileVersion", "@MODULE_VERSION@\0" + VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0" + VALUE "LegalCopyright", "Copyright 1998 Gerald Combs , Gilbert Ramirez and others\0" + VALUE "OriginalFilename", "@PLUGIN_NAME@.dll\0" + VALUE "ProductName", "Wireshark\0" + VALUE "ProductVersion", "@VERSION@\0" + VALUE "Comments", "Build with @MSVC_VARIANT@\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.cpp index 64b9912b1..5996eb7d3 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.cpp @@ -43,7 +43,6 @@ Node::Node(MixerCurveWidget *graphWidget) setCacheMode(DeviceCoordinateCache); setZValue(-1); vertical = false; - value = 0; } void Node::addEdge(Edge *edge) @@ -61,14 +60,14 @@ QList Node::edges() const QRectF Node::boundingRect() const { qreal adjust = 2; - return QRectF(-10 - adjust, -10 - adjust, - 23 + adjust, 23 + adjust); + return QRectF(-12 - adjust, -12 - adjust, + 28 + adjust, 28 + adjust); } QPainterPath Node::shape() const { QPainterPath path; - path.addEllipse(-10, -10, 20, 20); + path.addEllipse(-12, -12, 25, 25); return path; } @@ -92,59 +91,60 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid } painter->setBrush(gradient); painter->setPen(QPen(Qt::black, 0)); - painter->drawEllipse(-10, -10, 20, 20); + painter->drawEllipse(-12, -12, 25, 25); + + painter->setPen(QPen(Qt::white, 0)); + painter->drawText(-10, 3, QString().sprintf("%.2f", value())); } void Node::verticalMove(bool flag){ vertical = flag; } -double Node::getValue() { - return value; -} - -void Node::setValue(double val) { - value = val; -} - - -QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) -{ - - QPointF newPos = value.toPointF(); +double Node::value() { double h = graph->sceneRect().height(); + double ratio = (h - pos().y()) / h; + return ((graph->getMax() - graph->getMin()) * ratio ) + graph->getMin(); +} + + +QVariant Node::itemChange(GraphicsItemChange change, const QVariant &val) +{ + QPointF newPos = val.toPointF(); + double h = graph->sceneRect().height(); + switch (change) { case ItemPositionChange: { - if (!vertical) - break; - // Force node to move vertically - newPos.setX(pos().x()); - // Stay inside graph - if (newPos.y() < 0) - newPos.setY(0); - //qDebug() << h << " - " << newPos.y(); - if (newPos.y() > h) - newPos.setY(h); - return newPos; + + if (!vertical) + break; + + // Force node to move vertically + newPos.setX(pos().x()); + + // Stay inside graph + if (newPos.y() < 0) + newPos.setY(0); + //qDebug() << h << " - " << newPos.y(); + if (newPos.y() > h) + newPos.setY(h); + + return newPos; } case ItemPositionHasChanged: { foreach (Edge *edge, edgeList) edge->adjust(); - double min = graph->getMin(); - double range = graph->getMax() - min; - double ratio = (h - newPos.y()) / h; - double val = (range * ratio ) + min; - setValue(val); + update(); - graph->itemMoved(val); + graph->itemMoved(value()); break; } default: break; }; - return QGraphicsItem::itemChange(change, value); + return QGraphicsItem::itemChange(change, val); } void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h index 19b940625..eca445d32 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h @@ -55,22 +55,21 @@ public: QPainterPath shape() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void setValue(double val); - double getValue(); + double value(); protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); + QVariant itemChange(GraphicsItemChange change, const QVariant &val); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); private: - double value; QList edgeList; QPointF newPos; MixerCurveWidget *graph; bool vertical; + }; #endif // MIXERCURVEPOINT_H diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp index 56ed8bee9..a19692ff9 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp @@ -69,6 +69,7 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent) //plot->setElementId("map"); scene->addItem(plot); plot->setZValue(-1); + scene->setSceneRect(plot->boundingRect()); setScene(scene); @@ -77,11 +78,11 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent) MixerCurveWidget::~MixerCurveWidget() { - for (int i=0; i points) +void MixerCurveWidget::initCurve(const QList* points) { - if (points.length() < 2) + if (points->length() < 2) return; // We need at least 2 points on a curve! - if (nodeList.count() != points.count()) - initNodes(points.count()); - // finally, set node positions setCurve(points); } @@ -139,12 +137,8 @@ void MixerCurveWidget::initNodes(int numPoints) // First of all, clear any existing list if (nodeList.count()) { foreach (Node *node, nodeList ) { - QList edges = node->edges(); - foreach(Edge *edge, edges) { - if (edge->destNode() == node) { - delete edge; - } - else { + foreach(Edge *edge, node->edges()) { + if (edge->sourceNode() == node) { scene()->removeItem(edge); } } @@ -163,6 +157,8 @@ void MixerCurveWidget::initNodes(int numPoints) nodeList.append(node); scene()->addItem(node); + node->setPos(0,0); + if (prevNode) { scene()->addItem(getEdge(i, prevNode, node)); } @@ -179,7 +175,7 @@ QList MixerCurveWidget::getCurve() { QList list; foreach(Node *node, nodeList) { - list.append(node->getValue()); + list.append(node->value()); } return list; @@ -187,51 +183,48 @@ QList MixerCurveWidget::getCurve() { /** Sets a linear graph */ -void MixerCurveWidget::initLinearCurve(quint32 numPoints, double maxValue, double minValue) +void MixerCurveWidget::initLinearCurve(int numPoints, double maxValue, double minValue) { - Q_UNUSED(maxValue); - Q_UNUSED(minValue); + double range = setRange(minValue, maxValue); QList points; - for (double i=0; i points) +void MixerCurveWidget::setCurve(const QList* points) { curveUpdating = true; - if (nodeList.count() != points.count()) - initNodes(points.count()); + int ptCnt = points->count(); + if (nodeList.count() != ptCnt) + initNodes(ptCnt); - double min = curveMin + 10; - double max = curveMax + 10; + double range = curveMax - curveMin; - qreal w = plot->boundingRect().width()/(points.count()-1); + qreal w = plot->boundingRect().width()/(ptCnt-1); qreal h = plot->boundingRect().height(); - for (int i=0; i curveMax) - val = curveMax; + double val = (points->at(i) < curveMin) ? curveMin : (points->at(i) > curveMax) ? curveMax : points->at(i); - val += 10; - val -= min; - val /= (max - min); + val += range; + val -= (curveMin + range); + val /= range; - nodeList.at(i)->setPos(w*i, h - (val*h)); - nodeList.at(i)->verticalMove(true); + Node* node = nodeList.at(i); + node->setPos(w*i, h - (val*h)); + node->verticalMove(true); } - curveUpdating = false; + update(); + emit curveUpdated(points, (double)0); } @@ -252,13 +245,11 @@ void MixerCurveWidget::resizeEvent(QResizeEvent* event) fitInView(plot, Qt::KeepAspectRatio); } - - void MixerCurveWidget::itemMoved(double itemValue) { if (!curveUpdating) { - QList list = getCurve(); - emit curveUpdated(list, itemValue); + QList curve = getCurve(); + emit curveUpdated(&curve, itemValue); } } @@ -278,8 +269,9 @@ double MixerCurveWidget::getMax() { return curveMax; } -void MixerCurveWidget::setRange(double min, double max) +double MixerCurveWidget::setRange(double min, double max) { curveMin = min; curveMax = max; + return curveMax - curveMin; } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.h index 92c9c3a8c..031a70733 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.h @@ -44,20 +44,20 @@ public: MixerCurveWidget(QWidget *parent = 0); ~MixerCurveWidget(); void itemMoved(double itemValue); // Callback when a point is moved, to be updated - void initCurve (QList points); + void initCurve (const QList* points); QList getCurve(); - void initLinearCurve(quint32 numPoints, double maxValue = 1, double minValue = 0); - void setCurve(QList); + void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0); + void setCurve(const QList* points); void setMin(double value); double getMin(); void setMax(double value); double getMax(); - void setRange(double min, double max); + double setRange(double min, double max); static const int NODE_NUMELEM = 5; signals: - void curveUpdated(QList, double ); + void curveUpdated(const QList* points, const double value); private slots: diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp index c1463013a..ba65e84e5 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.cpp @@ -55,11 +55,6 @@ Telemetry::Telemetry(UAVTalk* utalk, UAVObjectManager* objMngr) connect(utalk, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(transactionCompleted(UAVObject*,bool))); // Get GCS stats object gcsStatsObj = GCSTelemetryStats::GetInstance(objMngr); - // Setup transaction timer - transPending = false; - transTimer = new QTimer(this); - transTimer->stop(); - connect(transTimer, SIGNAL(timeout()), this, SLOT(transactionTimeout())); // Setup and start the periodic timer timeToNextUpdateMs = 0; updateTimer = new QTimer(this); @@ -70,6 +65,12 @@ Telemetry::Telemetry(UAVTalk* utalk, UAVObjectManager* objMngr) txRetries = 0; } +Telemetry::~Telemetry() +{ + for (QMap::iterator itr = transMap.begin(); itr != transMap.end(); ++itr) + delete itr.value(); +} + /** * Register a new object for periodic updates (if enabled) */ @@ -231,84 +232,81 @@ void Telemetry::updateObject(UAVObject* obj, quint32 eventType) */ void Telemetry::transactionCompleted(UAVObject* obj, bool success) { - // Check if there is a pending transaction and the objects match - if ( transPending && transInfo.obj->getObjID() == obj->getObjID() ) + // Lookup the transaction in the transaction map. + quint32 objId = obj->getObjID(); + QMap::iterator itr = transMap.find(objId); + if ( itr != transMap.end() ) { - // qDebug() << QString("Telemetry: transaction completed for %1").arg(obj->getName()); - // Complete transaction - transTimer->stop(); - transPending = false; + ObjectTransactionInfo *transInfo = itr.value(); + // Remove this transaction as it's complete. + transInfo->timer->stop(); + transMap.remove(objId); + delete transInfo; // Send signal obj->emitTransactionCompleted(success); // Process new object updates from queue processObjectQueue(); } else { - // qDebug() << "Error: received a transaction completed when did not expect it."; + qDebug() << "Error: received a transaction completed when did not expect it."; } } /** * Called when a transaction is not completed within the timeout period (timer event) */ -void Telemetry::transactionTimeout() +void Telemetry::transactionTimeout(ObjectTransactionInfo *transInfo) { -// qDebug() << "Telemetry: transaction timeout."; - transTimer->stop(); - // Proceed only if there is a pending transaction - if ( transPending ) + transInfo->timer->stop(); + // Check if more retries are pending + if (transInfo->retriesRemaining > 0) { - // Check if more retries are pending - if (transInfo.retriesRemaining > 0) - { - --transInfo.retriesRemaining; - processObjectTransaction(); - ++txRetries; - } - else - { - // Terminate transaction - utalk->cancelTransaction(); - transPending = false; - // Send signal - transInfo.obj->emitTransactionCompleted(false); - // Process new object updates from queue - processObjectQueue(); - ++txErrors; - } + --transInfo->retriesRemaining; + processObjectTransaction(transInfo); + ++txRetries; + } + else + { + // Stop the timer. + transInfo->timer->stop(); + // Terminate transaction + utalk->cancelTransaction(transInfo->obj); + // Send signal + transInfo->obj->emitTransactionCompleted(false); + // Remove this transaction as it's complete. + transMap.remove(transInfo->obj->getObjID()); + delete transInfo; + // Process new object updates from queue + processObjectQueue(); + ++txErrors; } } /** * Start an object transaction with UAVTalk, all information is stored in transInfo */ -void Telemetry::processObjectTransaction() +void Telemetry::processObjectTransaction(ObjectTransactionInfo *transInfo) { - if (transPending) + + // Initiate transaction + if (transInfo->objRequest) { - // qDebug() << tr("Process Object transaction for %1").arg(transInfo.obj->getName()); - // Initiate transaction - if (transInfo.objRequest) - { - utalk->sendObjectRequest(transInfo.obj, transInfo.allInstances); - } - else - { - utalk->sendObject(transInfo.obj, transInfo.acked, transInfo.allInstances); - } - // Start timer if a response is expected - if ( transInfo.objRequest || transInfo.acked ) - { - transTimer->start(REQ_TIMEOUT_MS); - } - else - { - transTimer->stop(); - transPending = false; - } - } else + utalk->sendObjectRequest(transInfo->obj, transInfo->allInstances); + } + else { - // qDebug() << "Error: inside of processObjectTransaction with no transPending"; + utalk->sendObject(transInfo->obj, transInfo->acked, transInfo->allInstances); + } + // Start timer if a response is expected + if ( transInfo->objRequest || transInfo->acked ) + { + transInfo->timer->start(REQ_TIMEOUT_MS); + } + else + { + // Otherwise, remove this transaction as it's complete. + transMap.remove(transInfo->obj->getObjID()); + delete transInfo; } } @@ -318,7 +316,6 @@ void Telemetry::processObjectTransaction() void Telemetry::processObjectUpdates(UAVObject* obj, EventMask event, bool allInstances, bool priority) { // Push event into queue -// qDebug() << "Push event into queue for obj " << QString("%1 event %2").arg(obj->getName()).arg(event); ObjectQueueInfo objInfo; objInfo.obj = obj; objInfo.event = event; @@ -349,15 +346,8 @@ void Telemetry::processObjectUpdates(UAVObject* obj, EventMask event, bool allIn } } - // If there is no transaction in progress then process event - if (!transPending) - { - // qDebug() << "No transaction pending, process object queue..."; - processObjectQueue(); - } else - { - // qDebug() << "Transaction pending, DO NOT process object queue..."; - } + // Process the transaction + processObjectQueue(); } /** @@ -365,15 +355,6 @@ void Telemetry::processObjectUpdates(UAVObject* obj, EventMask event, bool allIn */ void Telemetry::processObjectQueue() { - // qDebug() << "Process object queue " << tr("- Depth (%1 %2)").arg(objQueue.length()).arg(objPriorityQueue.length()); - - // Don nothing if a transaction is already in progress (should not happen) - if (transPending) - { - qxtLog->error("Telemetry: Dequeue while a transaction pending!"); - return; - } - // Get object information from queue (first the priority and then the regular queue) ObjectQueueInfo objInfo; if ( !objPriorityQueue.isEmpty() ) @@ -408,24 +389,23 @@ void Telemetry::processObjectQueue() if ( ( objInfo.event != EV_UNPACKED ) && ( ( objInfo.event != EV_UPDATED_PERIODIC ) || ( updateMode != UAVObject::UPDATEMODE_THROTTLED ) ) ) { UAVObject::Metadata metadata = objInfo.obj->getMetadata(); - transInfo.obj = objInfo.obj; - transInfo.allInstances = objInfo.allInstances; - transInfo.retriesRemaining = MAX_RETRIES; - transInfo.acked = UAVObject::GetGcsTelemetryAcked(metadata); + ObjectTransactionInfo *transInfo = new ObjectTransactionInfo(this); + transInfo->obj = objInfo.obj; + transInfo->allInstances = objInfo.allInstances; + transInfo->retriesRemaining = MAX_RETRIES; + transInfo->acked = UAVObject::GetGcsTelemetryAcked(metadata); if ( objInfo.event == EV_UPDATED || objInfo.event == EV_UPDATED_MANUAL || objInfo.event == EV_UPDATED_PERIODIC ) { - transInfo.objRequest = false; + transInfo->objRequest = false; } else if ( objInfo.event == EV_UPDATE_REQ ) { - transInfo.objRequest = true; + transInfo->objRequest = true; } - // Start transaction - transPending = true; - processObjectTransaction(); - } else - { -// qDebug() << QString("Process object queue: this is an unpack event for %1").arg(objInfo.obj->getName()); + transInfo->telem = this; + // Insert the transaction into the transaction map. + transMap.insert(objInfo.obj->getObjID(), transInfo); + processObjectTransaction(transInfo); } // If this is a metaobject then make necessary telemetry updates @@ -579,6 +559,29 @@ void Telemetry::newInstance(UAVObject* obj) registerObject(obj); } +ObjectTransactionInfo::ObjectTransactionInfo(QObject* parent):QObject(parent) +{ + obj = 0; + allInstances = false; + objRequest = false; + retriesRemaining = 0; + acked = false; + telem = 0; + // Setup transaction timer + timer = new QTimer(this); + timer->stop(); + connect(timer, SIGNAL(timeout()), this, SLOT(timeout())); +} +ObjectTransactionInfo::~ObjectTransactionInfo() +{ + telem = 0; + timer->stop(); + delete timer; +} - +void ObjectTransactionInfo::timeout() +{ + if (!telem.isNull()) + telem->transactionTimeout(this); +} diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h index f703f636b..aaa9bc171 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetry.h @@ -35,6 +35,24 @@ #include #include #include +#include + +class ObjectTransactionInfo: public QObject { + Q_OBJECT + +public: + ObjectTransactionInfo(QObject * parent); + ~ObjectTransactionInfo(); + UAVObject* obj; + bool allInstances; + bool objRequest; + qint32 retriesRemaining; + bool acked; + QPointertelem; + QTimer* timer; +private slots: + void timeout(); +}; class Telemetry: public QObject { @@ -54,24 +72,13 @@ public: } TelemetryStats; Telemetry(UAVTalk* utalk, UAVObjectManager* objMngr); + ~Telemetry(); TelemetryStats getStats(); void resetStats(); - + void transactionTimeout(ObjectTransactionInfo *info); signals: -private slots: - void objectUpdatedAuto(UAVObject* obj); - void objectUpdatedManual(UAVObject* obj); - void objectUpdatedPeriodic(UAVObject* obj); - void objectUnpacked(UAVObject* obj); - void updateRequested(UAVObject* obj); - void newObject(UAVObject* obj); - void newInstance(UAVObject* obj); - void processPeriodicUpdates(); - void transactionCompleted(UAVObject* obj, bool success); - void transactionTimeout(); - private: // Constants static const int REQ_TIMEOUT_MS = 250; @@ -105,14 +112,6 @@ private: bool allInstances; } ObjectQueueInfo; - typedef struct { - UAVObject* obj; - bool allInstances; - bool objRequest; - qint32 retriesRemaining; - bool acked; - } ObjectTransactionInfo; - // Variables UAVObjectManager* objMngr; UAVTalk* utalk; @@ -120,11 +119,9 @@ private: QList objList; QQueue objQueue; QQueue objPriorityQueue; - ObjectTransactionInfo transInfo; - bool transPending; + QMaptransMap; QMutex* mutex; QTimer* updateTimer; - QTimer* transTimer; QTimer* statsTimer; qint32 timeToNextUpdateMs; quint32 txErrors; @@ -137,9 +134,19 @@ private: void connectToObjectInstances(UAVObject* obj, quint32 eventMask); void updateObject(UAVObject* obj, quint32 eventMask); void processObjectUpdates(UAVObject* obj, EventMask event, bool allInstances, bool priority); - void processObjectTransaction(); + void processObjectTransaction(ObjectTransactionInfo *transInfo); void processObjectQueue(); +private slots: + void objectUpdatedAuto(UAVObject* obj); + void objectUpdatedManual(UAVObject* obj); + void objectUpdatedPeriodic(UAVObject* obj); + void objectUnpacked(UAVObject* obj); + void updateRequested(UAVObject* obj); + void newObject(UAVObject* obj); + void newInstance(UAVObject* obj); + void processPeriodicUpdates(); + void transactionCompleted(UAVObject* obj, bool success); }; diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp index 03da96a6f..e1aa5ecf6 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp @@ -72,8 +72,6 @@ UAVTalk::UAVTalk(QIODevice* iodev, UAVObjectManager* objMngr) mutex = new QMutex(QMutex::Recursive); - respObj = NULL; - memset(&stats, 0, sizeof(ComStats)); connect(io, SIGNAL(readyRead()), this, SLOT(processInputStream())); @@ -157,10 +155,18 @@ bool UAVTalk::sendObject(UAVObject* obj, bool acked, bool allInstances) /** * Cancel a pending transaction */ -void UAVTalk::cancelTransaction() +void UAVTalk::cancelTransaction(UAVObject* obj) { QMutexLocker locker(mutex); - respObj = NULL; + quint32 objId = obj->getObjID(); + if(io.isNull()) + return; + QMap::iterator itr = transMap.find(objId); + if ( itr != transMap.end() ) + { + transMap.remove(objId); + delete itr.value(); + } } /** @@ -180,8 +186,10 @@ bool UAVTalk::objectTransaction(UAVObject* obj, quint8 type, bool allInstances) { if ( transmitObject(obj, type, allInstances) ) { - respObj = obj; - respAllInstances = allInstances; + Transaction *trans = new Transaction(); + trans->obj = obj; + trans->allInstances = allInstances; + transMap.insert(obj->getObjID(), trans); return true; } else @@ -627,9 +635,15 @@ UAVObject* UAVTalk::updateObject(quint32 objId, quint16 instId, quint8* data) */ void UAVTalk::updateNack(UAVObject* obj) { - if (respObj != NULL && respObj->getObjID() == obj->getObjID() && (respObj->getInstID() == obj->getInstID() || respAllInstances)) + Q_ASSERT(obj); + if ( ! obj ) + return; + quint32 objId = obj->getObjID(); + QMap::iterator itr = transMap.find(objId); + if ( itr != transMap.end() && (itr.value()->obj->getInstID() == obj->getInstID() || itr.value()->allInstances)) { - respObj = NULL; + transMap.remove(objId); + delete itr.value(); emit transactionCompleted(obj, false); } } @@ -640,9 +654,12 @@ void UAVTalk::updateNack(UAVObject* obj) */ void UAVTalk::updateAck(UAVObject* obj) { - if (respObj != NULL && respObj->getObjID() == obj->getObjID() && (respObj->getInstID() == obj->getInstID() || respAllInstances)) + quint32 objId = obj->getObjID(); + QMap::iterator itr = transMap.find(objId); + if ( itr != transMap.end() && (itr.value()->obj->getInstID() == obj->getInstID() || itr.value()->allInstances)) { - respObj = NULL; + transMap.remove(objId); + delete itr.value(); emit transactionCompleted(obj, true); } } @@ -812,7 +829,7 @@ bool UAVTalk::transmitSingleObject(UAVObject* obj, quint8 type, bool allInstance txBuffer[dataOffset+length] = updateCRC(0, txBuffer, dataOffset + length); // Send buffer, check that the transmit backlog does not grow above limit - if (io && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE ) + if (!io.isNull() && io->isWritable() && io->bytesToWrite() < TX_BUFFER_SIZE ) { io->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH); } diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h index de7ca8542..6f0bf2e8d 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "uavobjectmanager.h" #include "uavtalk_global.h" @@ -55,7 +56,7 @@ public: ~UAVTalk(); bool sendObject(UAVObject* obj, bool acked, bool allInstances); bool sendObjectRequest(UAVObject* obj, bool allInstances); - void cancelTransaction(); + void cancelTransaction(UAVObject* obj); ComStats getStats(); void resetStats(); @@ -66,6 +67,12 @@ private slots: void processInputStream(void); private: + + typedef struct { + UAVObject* obj; + bool allInstances; + } Transaction; + // Constants static const int TYPE_MASK = 0xF8; static const int TYPE_VER = 0x20; @@ -97,8 +104,7 @@ private: QPointer io; UAVObjectManager* objMngr; QMutex* mutex; - UAVObject* respObj; - bool respAllInstances; + QMap transMap; quint8 rxBuffer[MAX_PACKET_LENGTH]; quint8 txBuffer[MAX_PACKET_LENGTH]; // Variables used by the receive state machine diff --git a/ground/uavobjects/uavobjects.pro b/ground/uavobjects/uavobjects.pro index 4e2c0c66e..5a256ba3d 100644 --- a/ground/uavobjects/uavobjects.pro +++ b/ground/uavobjects/uavobjects.pro @@ -20,6 +20,7 @@ isEmpty(QMAKESPEC) { win32:SPEC = win32-g++ macx-g++:SPEC = macx-g++ linux-g++:SPEC = linux-g++ + linux-g++-32:SPEC = linux-g++ linux-g++-64:SPEC = linux-g++-64 } else { SPEC = $$QMAKESPEC diff --git a/ground/uavobjgenerator/generators/generator_common.cpp b/ground/uavobjgenerator/generators/generator_common.cpp index 7814a9c05..12fae596d 100644 --- a/ground/uavobjgenerator/generators/generator_common.cpp +++ b/ground/uavobjgenerator/generators/generator_common.cpp @@ -56,6 +56,8 @@ void replaceCommonTags(QString& out, ObjectInfo* info) out.replace(QString("$(NAMELC)"), info->namelc); // Replace $(DESCRIPTION) tag out.replace(QString("$(DESCRIPTION)"), info->description); + // Replace $(CATEGORY) tag + out.replace(QString("$(CATEGORY)"), info->category); // Replace $(NAMEUC) tag out.replace(QString("$(NAMEUC)"), info->name.toUpper()); // Replace $(OBJID) tag diff --git a/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.cpp b/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.cpp new file mode 100644 index 000000000..c0669d9e6 --- /dev/null +++ b/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.cpp @@ -0,0 +1,290 @@ +/** + ****************************************************************************** + * + * @file uavobjectgeneratorflight.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief produce flight code for uavobjects + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "uavobjectgeneratorwireshark.h" + +using namespace std; + +bool UAVObjectGeneratorWireshark::generate(UAVObjectParser* parser,QString templatepath,QString outputpath) { + + fieldTypeStrHf << "FT_INT8" << "FT_INT16" << "FT_INT32" <<"FT_UINT8" + <<"FT_UINT16" << "FT_UINT32" << "FT_FLOAT" << "FT_UINT8"; + fieldTypeStrGlib << "gint8" << "gint16" << "gint32" <<"guint8" + <<"guint16" << "guint32" << "gfloat" << "guint8"; + + wiresharkCodePath = QDir( templatepath + QString("ground/openpilotgcs/src/plugins/uavobjects/wireshark")); + + wiresharkOutputPath = QDir( outputpath + QString("wireshark") ); + wiresharkOutputPath.mkpath(wiresharkOutputPath.absolutePath()); + + wiresharkCodeTemplate = readFile( wiresharkCodePath.absoluteFilePath("op-uavobjects/packet-op-uavobjects-template.c") ); + wiresharkMakeTemplate = readFile( wiresharkCodePath.absoluteFilePath("op-uavobjects/Makefile.common-template") ); + + if ( wiresharkCodeTemplate.isNull() || wiresharkMakeTemplate.isNull()) { + cerr << "Error: Could not open wireshark template files." << endl; + return false; + } + + /* Copy static files for wireshark plugins root directory into output directory */ + QStringList topstaticfiles; + topstaticfiles << "Custom.m4" << "Custom.make" << "Custom.nmake"; + for (int i = 0; i < topstaticfiles.length(); ++i) { + QFile::copy(wiresharkCodePath.absoluteFilePath(topstaticfiles[i]), + wiresharkOutputPath.absoluteFilePath(topstaticfiles[i])); + } + + /* Copy static files for op-uavtalk dissector into output directory */ + QDir uavtalkOutputPath = QDir( outputpath + QString("wireshark/op-uavtalk") ); + uavtalkOutputPath.mkpath(uavtalkOutputPath.absolutePath()); + QStringList uavtalkstaticfiles; + uavtalkstaticfiles << "AUTHORS" << "COPYING" << "ChangeLog"; + uavtalkstaticfiles << "CMakeLists.txt" << "Makefile.nmake"; + uavtalkstaticfiles << "Makefile.am" << "moduleinfo.h" << "moduleinfo.nmake"; + uavtalkstaticfiles << "plugin.rc.in"; + uavtalkstaticfiles << "Makefile.common" << "packet-op-uavtalk.c"; + for (int i = 0; i < uavtalkstaticfiles.length(); ++i) { + QFile::copy(wiresharkCodePath.absoluteFilePath("op-uavtalk/" + uavtalkstaticfiles[i]), + uavtalkOutputPath.absoluteFilePath(uavtalkstaticfiles[i])); + } + + /* Copy static files for op-uavobjects dissector into output directory */ + QDir uavobjectsOutputPath = QDir( outputpath + QString("wireshark/op-uavobjects") ); + uavobjectsOutputPath.mkpath(uavobjectsOutputPath.absolutePath()); + QStringList uavostaticfiles; + uavostaticfiles << "AUTHORS" << "COPYING" << "ChangeLog"; + uavostaticfiles << "CMakeLists.txt" << "Makefile.nmake"; + uavostaticfiles << "Makefile.am" << "moduleinfo.h" << "moduleinfo.nmake"; + uavostaticfiles << "plugin.rc.in"; + for (int i = 0; i < uavostaticfiles.length(); ++i) { + QFile::copy(wiresharkCodePath.absoluteFilePath("op-uavobjects/" + uavostaticfiles[i]), + uavobjectsOutputPath.absoluteFilePath(uavostaticfiles[i])); + } + + /* Generate the per-object files from the templates, and keep track of the list of generated filenames */ + QString objFileNames; + for (int objidx = 0; objidx < parser->getNumObjects(); ++objidx) { + ObjectInfo* info = parser->getObjectByIndex(objidx); + process_object(info, uavobjectsOutputPath); + objFileNames.append(" packet-op-uavobjects-" + info->namelc + ".c"); + } + + /* Write the uavobject dissector's Makefile.common */ + wiresharkMakeTemplate.replace( QString("$(UAVOBJFILENAMES)"), objFileNames); + bool res = writeFileIfDiffrent( uavobjectsOutputPath.absolutePath() + "/Makefile.common", + wiresharkMakeTemplate ); + if (!res) { + cout << "Error: Could not write wireshark Makefile" << endl; + return false; + } + + return true; +} + + +/** + * Generate the Flight object files +**/ +bool UAVObjectGeneratorWireshark::process_object(ObjectInfo* info, QDir outputpath) +{ + if (info == NULL) + return false; + + // Prepare output strings + QString outCode = wiresharkCodeTemplate; + + // Replace common tags + replaceCommonTags(outCode, info); + + // Replace the $(SUBTREES) and $(SUBTREESTATICS) tags + QString subtrees; + QString subtreestatics; + subtreestatics.append( QString("static gint ett_uavo = -1;\r\n") ); + subtrees.append( QString("&ett_uavo,\r\n") ); + for (int n = 0; n < info->fields.length(); ++n) { + if (info->fields[n]->numElements > 1) { + /* Reserve a subtree for each array */ + subtreestatics.append( QString("static gint ett_%1_%2 = -1;\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) ); + subtrees.append( QString("&ett_%1_%2,\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) ); + } + } + outCode.replace(QString("$(SUBTREES)"), subtrees); + outCode.replace(QString("$(SUBTREESTATICS)"), subtreestatics); + + // Replace the $(FIELDHANDLES) tag + QString type; + QString fields; + for (int n = 0; n < info->fields.length(); ++n) { + fields.append( QString("static int hf_op_uavobjects_%1_%2 = -1;\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name)); + if (info->fields[n]->numElements > 1) { + QStringList elemNames = info->fields[n]->elementNames; + for (int m = 0; m < elemNames.length(); ++m) { + fields.append( QString("static int hf_op_uavobjects_%1_%2_%3 = -1;\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) + .arg(elemNames[m]) ); + } + } + } + outCode.replace(QString("$(FIELDHANDLES)"), fields); + + // Replace the $(ENUMFIELDNAMES) tag + QString enums; + for (int n = 0; n < info->fields.length(); ++n) { + // Only for enum types + if (info->fields[n]->type == FIELDTYPE_ENUM) { + enums.append(QString("/* Field %1 information */\r\n").arg(info->fields[n]->name) ); + enums.append(QString("/* Enumeration options for field %1 */\r\n").arg(info->fields[n]->name)); + enums.append( QString("static const value_string uavobjects_%1_%2[]= {\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) ); + // Go through each option + QStringList options = info->fields[n]->options; + for (int m = 0; m < options.length(); ++m) { + enums.append ( QString("\t{ %1, \"%2\" },\r\n") + .arg(m) + .arg(options[m].replace(QRegExp(ENUM_SPECIAL_CHARS), "") ) ); + } + enums.append( QString("\t{ 0, NULL }\r\n") ); + enums.append( QString("};\r\n") ); + } + } + outCode.replace(QString("$(ENUMFIELDNAMES)"), enums); + + // Replace the $(POPULATETREE) tag + QString treefields; + for (int n = 0; n < info->fields.length(); ++n) { + if ( info->fields[n]->numElements == 1 ) { + treefields.append( QString(" ptvcursor_add(cursor, hf_op_uavobjects_%1_%2, sizeof(%3), ENC_LITTLE_ENDIAN);\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) + .arg(fieldTypeStrGlib[info->fields[n]->type]) ); + } else { + treefields.append( QString(" {\r\n") ); + treefields.append( QString(" proto_item * it = NULL;\r\n") ); + treefields.append( QString(" it = ptvcursor_add_no_advance(cursor, hf_op_uavobjects_%1_%2, 1, ENC_NA);\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) ); + treefields.append( QString(" ptvcursor_push_subtree(cursor, it, ett_%1_%2);\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) ); + /* Populate each array element into the table */ + QStringList elemNames = info->fields[n]->elementNames; + for (int m = 0; m < elemNames.length(); ++m) { + treefields.append( QString(" ptvcursor_add(cursor, hf_op_uavobjects_%1_%2_%3, sizeof(%4), ENC_LITTLE_ENDIAN);\r\n") + .arg(info->namelc) + .arg(info->fields[n]->name) + .arg(elemNames[m]) + .arg(fieldTypeStrGlib[info->fields[n]->type]) ); + } + treefields.append( QString(" ptvcursor_pop_subtree(cursor);\r\n") ); + treefields.append( QString(" }\r\n") ); + } + } + outCode.replace(QString("$(POPULATETREE)"), treefields); + + // Replace the $(HEADERFIELDS) tag + QString headerfields; + headerfields.append( QString(" static hf_register_info hf[] = {\r\n") ); + for (int n = 0; n < info->fields.length(); ++n) { + // For non-array fields + if ( info->fields[n]->numElements == 1) { + headerfields.append( QString("\t { &hf_op_uavobjects_%1_%2,\r\n") + .arg( info->namelc ) + .arg( info->fields[n]->name ) ); + headerfields.append( QString("\t { \"%1\", \"%2.%3\", %4,\r\n") + .arg( info->fields[n]->name ) + .arg( info->namelc ) + .arg( info->fields[n]->name ) + .arg( fieldTypeStrHf[info->fields[n]->type] ) ); + if ( info->fields[n]->type == FIELDTYPE_ENUM ) { + headerfields.append( QString("\t BASE_DEC, VALS(uavobjects_%1_%2), 0x0, NULL, HFILL \r\n") + .arg( info->namelc ) + .arg( info->fields[n]->name ) ); + } else if ( info->fields[n]->type == FIELDTYPE_FLOAT32 ) { + headerfields.append( QString("\t BASE_NONE, NULL, 0x0, NULL, HFILL \r\n") ); + } else { + headerfields.append( QString("\t BASE_DEC_HEX, NULL, 0x0, NULL, HFILL\r\n") ); + } + headerfields.append( QString("\t },\r\n") ); + headerfields.append( QString("\t },\r\n") ); + } else { + headerfields.append( QString("\t { &hf_op_uavobjects_%1_%2,\r\n") + .arg( info->namelc ) + .arg( info->fields[n]->name ) ); + headerfields.append( QString("\t { \"%1\", \"%2.%3\", FT_NONE,\r\n") + .arg( info->fields[n]->name ) + .arg( info->namelc ) + .arg( info->fields[n]->name ) ); + headerfields.append( QString("\t BASE_NONE, NULL, 0x0, NULL, HFILL\r\n") ); + headerfields.append( QString("\t },\r\n") ); + headerfields.append( QString("\t },\r\n") ); + + QStringList elemNames = info->fields[n]->elementNames; + for (int m = 0; m < elemNames.length(); ++m) { + headerfields.append( QString("\t { &hf_op_uavobjects_%1_%2_%3,\r\n") + .arg( info->namelc ) + .arg( info->fields[n]->name ) + .arg( elemNames[m]) ); + headerfields.append( QString("\t { \"%1\", \"%2.%3.%4\", %5,\r\n") + .arg( elemNames[m] ) + .arg( info->namelc ) + .arg( info->fields[n]->name ) + .arg( elemNames[m] ) + .arg( fieldTypeStrHf[info->fields[n]->type] ) ); + if ( info->fields[n]->type == FIELDTYPE_ENUM ) { + headerfields.append( QString("\t BASE_DEC, VALS(uavobjects_%1_%2), 0x0, NULL, HFILL \r\n") + .arg( info->namelc ) + .arg( info->fields[n]->name ) ); + } else if ( info->fields[n]->type == FIELDTYPE_FLOAT32 ) { + headerfields.append( QString("\t BASE_NONE, NULL, 0x0, NULL, HFILL \r\n") ); + } else { + headerfields.append( QString("\t BASE_DEC_HEX, NULL, 0x0, NULL, HFILL\r\n") ); + } + headerfields.append( QString("\t },\r\n") ); + headerfields.append( QString("\t },\r\n") ); + } + } + } + headerfields.append( QString(" };\r\n") ); + outCode.replace(QString("$(HEADERFIELDS)"), headerfields); + + // Write the flight code + bool res = writeFileIfDiffrent( outputpath.absolutePath() + "/packet-op-uavobjects-" + info->namelc + ".c", outCode ); + if (!res) { + cout << "Error: Could not write wireshark code files" << endl; + return false; + } + + return true; +} + + diff --git a/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.h b/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.h new file mode 100644 index 000000000..402aac17e --- /dev/null +++ b/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.h @@ -0,0 +1,48 @@ +/** + ****************************************************************************** + * + * @file uavobjectgeneratorflight.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief produce flight code for uavobjects + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef UAVOBJECTGENERATORWIRESHARK_H +#define UAVOBJECTGENERATORWIRESHARK_H + +#include "../generator_common.h" + +class UAVObjectGeneratorWireshark +{ +public: + bool generate(UAVObjectParser* gen,QString templatepath,QString outputpath); + QStringList fieldTypeStrHf; + QStringList fieldTypeStrGlib; + QString wiresharkCodeTemplate, wiresharkMakeTemplate; + QDir wiresharkCodePath; + QDir wiresharkOutputPath; + +private: + bool process_object(ObjectInfo* info, QDir outputpath); + +}; + +#endif + diff --git a/ground/uavobjgenerator/main.cpp b/ground/uavobjgenerator/main.cpp index 99cbf528c..725d65cd3 100644 --- a/ground/uavobjgenerator/main.cpp +++ b/ground/uavobjgenerator/main.cpp @@ -34,6 +34,7 @@ #include "generators/gcs/uavobjectgeneratorgcs.h" #include "generators/matlab/uavobjectgeneratormatlab.h" #include "generators/python/uavobjectgeneratorpython.h" +#include "generators/wireshark/uavobjectgeneratorwireshark.h" #define RETURN_ERR_USAGE 1 #define RETURN_ERR_XML 2 @@ -45,13 +46,14 @@ using namespace std; * print usage info */ void usage() { - cout << "Usage: uavobjectgenerator [-gcs] [-flight] [-java] [-python] [-matlab] [-none] [-v] xml_path template_base [UAVObj1] ... [UAVObjN]" << endl; + cout << "Usage: uavobjectgenerator [-gcs] [-flight] [-java] [-python] [-matlab] [-wireshark] [-none] [-v] xml_path template_base [UAVObj1] ... [UAVObjN]" << endl; cout << "Languages: "<< endl; cout << "\t-gcs build groundstation code" << endl; cout << "\t-flight build flight code" << endl; cout << "\t-java build java code" << endl; cout << "\t-python build python code" << endl; cout << "\t-matlab build matlab code" << endl; + cout << "\t-wireshark build wireshark plugin" << endl; cout << "\tIf no language is specified ( and not -none ) -> all are built." << endl; cout << "Misc: "<< endl; cout << "\t-none build no language - just parse xml's" << endl; @@ -103,6 +105,7 @@ int main(int argc, char *argv[]) bool do_java=(arguments_stringlist.removeAll("-java")>0); bool do_python=(arguments_stringlist.removeAll("-python")>0); bool do_matlab=(arguments_stringlist.removeAll("-matlab")>0); + bool do_wireshark=(arguments_stringlist.removeAll("-wireshark")>0); bool do_none=(arguments_stringlist.removeAll("-none")>0); // bool do_all=((do_gcs||do_flight||do_java||do_python||do_matlab)==false); @@ -230,6 +233,13 @@ int main(int argc, char *argv[]) matlabgen.generate(parser,templatepath,outputpath); } + // generate wireshark plugin if wanted + if (do_wireshark|do_all) { + cout << "generating wireshark code" << endl ; + UAVObjectGeneratorWireshark wiresharkgen; + wiresharkgen.generate(parser,templatepath,outputpath); + } + return RETURN_OK; } diff --git a/ground/uavobjgenerator/uavobjectparser.cpp b/ground/uavobjgenerator/uavobjectparser.cpp index 94fce6043..73c4833b0 100644 --- a/ground/uavobjgenerator/uavobjectparser.cpp +++ b/ground/uavobjgenerator/uavobjectparser.cpp @@ -499,6 +499,13 @@ QString UAVObjectParser::processObjectAttributes(QDomNode& node, ObjectInfo* inf info->name = attr.nodeValue(); info->namelc = attr.nodeValue().toLower(); + // Get category attribute if present + attr = attributes.namedItem("category"); + if ( !attr.isNull() ) + { + info->category = attr.nodeValue(); + } + // Get singleinstance attribute attr = attributes.namedItem("singleinstance"); if ( attr.isNull() ) diff --git a/ground/uavobjgenerator/uavobjectparser.h b/ground/uavobjgenerator/uavobjectparser.h index 66b52ff88..cad891d3c 100644 --- a/ground/uavobjgenerator/uavobjectparser.h +++ b/ground/uavobjgenerator/uavobjectparser.h @@ -96,6 +96,7 @@ typedef struct { int loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */ QList fields; /** The data fields for the object **/ QString description; /** Description used for Doxygen **/ + QString category; /** Description used for Doxygen **/ } ObjectInfo; class UAVObjectParser @@ -127,6 +128,7 @@ private: QString processObjectFields(QDomNode& childNode, ObjectInfo* info); QString processObjectAccess(QDomNode& childNode, ObjectInfo* info); QString processObjectDescription(QDomNode& childNode, QString * description); + QString processObjectCategory(QDomNode& childNode, QString * category); QString processObjectMetadata(QDomNode& childNode, UpdateMode* mode, int* period, bool* acked); void calculateID(ObjectInfo* info); quint32 updateHash(quint32 value, quint32 hash); diff --git a/ground/uavobjgenerator/uavobjgenerator.pro b/ground/uavobjgenerator/uavobjgenerator.pro index 31ffc3199..28d3bc532 100644 --- a/ground/uavobjgenerator/uavobjgenerator.pro +++ b/ground/uavobjgenerator/uavobjgenerator.pro @@ -15,6 +15,7 @@ SOURCES += main.cpp \ generators/gcs/uavobjectgeneratorgcs.cpp \ generators/matlab/uavobjectgeneratormatlab.cpp \ generators/python/uavobjectgeneratorpython.cpp \ + generators/wireshark/uavobjectgeneratorwireshark.cpp \ generators/generator_common.cpp HEADERS += uavobjectparser.h \ generators/generator_io.h \ @@ -22,4 +23,5 @@ HEADERS += uavobjectparser.h \ generators/gcs/uavobjectgeneratorgcs.h \ generators/matlab/uavobjectgeneratormatlab.h \ generators/python/uavobjectgeneratorpython.h \ + generators/wireshark/uavobjectgeneratorwireshark.h \ generators/generator_common.h diff --git a/package/winx86/openpilotgcs.nsi b/package/winx86/openpilotgcs.nsi index c36a4bb39..363760ec0 100644 --- a/package/winx86/openpilotgcs.nsi +++ b/package/winx86/openpilotgcs.nsi @@ -1,7 +1,7 @@ # # Project: OpenPilot # NSIS configuration file for OpenPilot GCS -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2010-2011. +# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2010-2012. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,14 +21,15 @@ # This script requires Unicode NSIS 2.46 or higher: # http://www.scratchpaper.com/ -# Features: -# - Installs to the user local appdata path, no admin rights required. -# # TODO: -# - optionally install for all users (to Program Files with admin rights on Vista/7). # - install only built/used modules, not a whole directory. # - remove only installed files, not a whole directory. +;-------------------------------- +; Includes + +!include "x64.nsh" + ;-------------------------------- ; Paths @@ -36,12 +37,13 @@ !define PROJECT_ROOT "..\.." !define NSIS_DATA_TREE "." !define GCS_BUILD_TREE "..\..\build\ground\openpilotgcs" + !define UAVO_SYNTH_TREE "..\..\build\uavobject-synthetics" ; Default installation folder - InstallDir "$LOCALAPPDATA\OpenPilot" + InstallDir "$PROGRAMFILES\OpenPilot" ; Get installation folder from registry if available - InstallDirRegKey HKCU "Software\OpenPilot" "Install Location" + InstallDirRegKey HKLM "Software\OpenPilot" "Install Location" ;-------------------------------- ; Version information @@ -82,7 +84,7 @@ XPStyle on ; Request application privileges for Windows Vista/7 - RequestExecutionLevel user + RequestExecutionLevel admin ; Compression level SetCompressor /solid lzma @@ -90,7 +92,7 @@ ;-------------------------------- ; Branding - BrandingText "© 2010-2011 The OpenPilot Team, http://www.openpilot.org" + BrandingText "© 2010-2012 The OpenPilot Team, http://www.openpilot.org" !define MUI_ICON "${NSIS_DATA_TREE}\resources\openpilot.ico" !define MUI_HEADERIMAGE @@ -113,6 +115,7 @@ ;-------------------------------- ; Settings for MUI_PAGE_FINISH !define MUI_FINISHPAGE_RUN + !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\HISTORY.txt" !define MUI_FINISHPAGE_RUN_FUNCTION "RunApplication" ;-------------------------------- @@ -148,6 +151,7 @@ ;-------------------------------- ; Installer sections +; Copy GCS core files Section "Core files" InSecCore SectionIn RO SetOutPath "$INSTDIR\bin" @@ -156,6 +160,7 @@ Section "Core files" InSecCore File "${PROJECT_ROOT}\HISTORY.txt" SectionEnd +; Copy GCS plugins Section "Plugins" InSecPlugins SectionIn RO SetOutPath "$INSTDIR\lib\openpilotgcs\plugins" @@ -163,6 +168,7 @@ Section "Plugins" InSecPlugins File /r "${GCS_BUILD_TREE}\lib\openpilotgcs\plugins\*.pluginspec" SectionEnd +; Copy GCS resources Section "Resources" InSecResources SetOutPath "$INSTDIR\share\openpilotgcs\diagrams" File /r "${GCS_BUILD_TREE}\share\openpilotgcs\diagrams\*" @@ -176,22 +182,51 @@ Section "Resources" InSecResources File /r "${GCS_BUILD_TREE}\share\openpilotgcs\pfd\*" SectionEnd +; Copy Notify plugin sound files Section "Sound files" InSecSounds SetOutPath "$INSTDIR\share\openpilotgcs\sounds" File /r "${GCS_BUILD_TREE}\share\openpilotgcs\sounds\*" SectionEnd +; Copy localization files +; Disabled until GCS source is stable and properly localized Section "Localization" InSecLocalization SetOutPath "$INSTDIR\share\openpilotgcs\translations" ; File /r "${GCS_BUILD_TREE}\share\openpilotgcs\translations\openpilotgcs_*.qm" File /r "${GCS_BUILD_TREE}\share\openpilotgcs\translations\qt_*.qm" SectionEnd +; Copy firmware files Section "Firmware" InSecFirmware ; SetOutPath "$INSTDIR\firmware\${FIRMWARE_DIR}" ; File /r "${PACKAGE_DIR}\${FIRMWARE_DIR}\*" SetOutPath "$INSTDIR\firmware" - File /r "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_coptercontrol-${PACKAGE_LBL}.opfw" + File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_coptercontrol-${PACKAGE_LBL}.opfw" + File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_pipxtreme-${PACKAGE_LBL}.opfw" +SectionEnd + +; Copy utility files +Section "-Utilities" InSecUtilities + SetOutPath "$INSTDIR\utilities" + File "/oname=OPLogConvert-${PACKAGE_LBL}.m" "${UAVO_SYNTH_TREE}\matlab\OPLogConvert.m" +SectionEnd + +; Copy driver files +Section "-Drivers" InSecDrivers + SetOutPath "$INSTDIR\drivers" + File "${PROJECT_ROOT}\flight\Project\Windows USB\OpenPilot-CDC.inf" +SectionEnd + +; Preinstall OpenPilot CDC driver +Section "CDC driver" InSecInstallDrivers + InitPluginsDir + SetOutPath "$PLUGINSDIR" + ${If} ${RunningX64} + File "/oname=dpinst.exe" "${NSIS_DATA_TREE}\redist\dpinst_x64.exe" + ${Else} + File "/oname=dpinst.exe" "${NSIS_DATA_TREE}\redist\dpinst_x86.exe" + ${EndIf} + ExecWait '"$PLUGINSDIR\dpinst.exe" /lm /path "$INSTDIR\drivers"' SectionEnd Section "Shortcuts" InSecShortcuts @@ -239,6 +274,9 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${InSecSounds} $(DESC_InSecSounds) !insertmacro MUI_DESCRIPTION_TEXT ${InSecLocalization} $(DESC_InSecLocalization) !insertmacro MUI_DESCRIPTION_TEXT ${InSecFirmware} $(DESC_InSecFirmware) + !insertmacro MUI_DESCRIPTION_TEXT ${InSecUtilities} $(DESC_InSecUtilities) + !insertmacro MUI_DESCRIPTION_TEXT ${InSecDrivers} $(DESC_InSecDrivers) + !insertmacro MUI_DESCRIPTION_TEXT ${InSecInstallDrivers} $(DESC_InSecInstallDrivers) !insertmacro MUI_DESCRIPTION_TEXT ${InSecShortcuts} $(DESC_InSecShortcuts) !insertmacro MUI_FUNCTION_DESCRIPTION_END @@ -247,6 +285,7 @@ SectionEnd Function .onInit + SetShellVarContext all !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd @@ -260,6 +299,8 @@ Section "un.OpenPilot GCS" UnSecProgram RMDir /r /rebootok "$INSTDIR\lib" RMDir /r /rebootok "$INSTDIR\share" RMDir /r /rebootok "$INSTDIR\firmware" + RMDir /r /rebootok "$INSTDIR\utilities" + RMDir /r /rebootok "$INSTDIR\drivers" Delete /rebootok "$INSTDIR\HISTORY.txt" Delete /rebootok "$INSTDIR\Uninstall.exe" @@ -306,6 +347,7 @@ SectionEnd Function un.onInit + SetShellVarContext all !insertmacro MUI_UNGETLANGUAGE FunctionEnd diff --git a/package/winx86/redist/dpinst_x64.exe b/package/winx86/redist/dpinst_x64.exe new file mode 100644 index 000000000..3182f9868 Binary files /dev/null and b/package/winx86/redist/dpinst_x64.exe differ diff --git a/package/winx86/redist/dpinst_x86.exe b/package/winx86/redist/dpinst_x86.exe new file mode 100644 index 000000000..a8d609956 Binary files /dev/null and b/package/winx86/redist/dpinst_x86.exe differ diff --git a/package/winx86/translations/strings_de.nsh b/package/winx86/translations/strings_de.nsh index 8a0f3d6fa..2eea9dd8d 100644 --- a/package/winx86/translations/strings_de.nsh +++ b/package/winx86/translations/strings_de.nsh @@ -31,6 +31,9 @@ LangString DESC_InSecSounds ${LANG_GERMAN} "GCS Sounddateien (benötigt für akustische Ereignisbenachrichtigungen)." LangString DESC_InSecLocalization ${LANG_GERMAN} "GCS Lokalisierung (für unterstützte Sprachen)." LangString DESC_InSecFirmware ${LANG_GERMAN} "OpenPilot firmware binaries." + LangString DESC_InSecUtilities ${LANG_GERMAN} "OpenPilot utilities (Matlab log parser)." + LangString DESC_InSecDrivers ${LANG_GERMAN} "OpenPilot hardware driver files (optional OpenPilot CDC driver)." + LangString DESC_InSecInstallDrivers ${LANG_GERMAN} "Install OpenPilot CDC driver (optional)." LangString DESC_InSecShortcuts ${LANG_GERMAN} "Installiere Verknüpfungen unter Startmenü->Anwendungen." ;-------------------------------- diff --git a/package/winx86/translations/strings_en.nsh b/package/winx86/translations/strings_en.nsh index 3e0fbb401..3e640ad4d 100644 --- a/package/winx86/translations/strings_en.nsh +++ b/package/winx86/translations/strings_en.nsh @@ -31,6 +31,9 @@ LangString DESC_InSecSounds ${LANG_ENGLISH} "GCS sound files (used for audible event notifications)." LangString DESC_InSecLocalization ${LANG_ENGLISH} "GCS localization (for supported languages)." LangString DESC_InSecFirmware ${LANG_ENGLISH} "OpenPilot firmware binaries." + LangString DESC_InSecUtilities ${LANG_ENGLISH} "OpenPilot utilities (Matlab log parser)." + LangString DESC_InSecDrivers ${LANG_ENGLISH} "OpenPilot hardware driver files (optional OpenPilot CDC driver)." + LangString DESC_InSecInstallDrivers ${LANG_ENGLISH} "Install OpenPilot CDC driver (optional)." LangString DESC_InSecShortcuts ${LANG_ENGLISH} "Install application start menu shortcuts." ;-------------------------------- diff --git a/package/winx86/translations/strings_es.nsh b/package/winx86/translations/strings_es.nsh index aa43b06bd..21aeb31d4 100644 --- a/package/winx86/translations/strings_es.nsh +++ b/package/winx86/translations/strings_es.nsh @@ -31,6 +31,9 @@ LangString DESC_InSecSounds ${LANG_SPANISH} "Archivos de sonido del GCS (usados para los eventos y notificaciones audibles)." LangString DESC_InSecLocalization ${LANG_SPANISH} "Localización GCS (idiomas soportados)." LangString DESC_InSecFirmware ${LANG_SPANISH} "OpenPilot firmware binaries." + LangString DESC_InSecUtilities ${LANG_SPANISH} "OpenPilot utilities (Matlab log parser)." + LangString DESC_InSecDrivers ${LANG_SPANISH} "OpenPilot hardware driver files (optional OpenPilot CDC driver)." + LangString DESC_InSecInstallDrivers ${LANG_SPANISH} "Install OpenPilot CDC driver (optional)." LangString DESC_InSecShortcuts ${LANG_SPANISH} "Instalar accesos directos de la aplicación (menú inicio y escritorio)." ;-------------------------------- diff --git a/package/winx86/translations/strings_fr.nsh b/package/winx86/translations/strings_fr.nsh index 7c831590c..3b1c9efb0 100644 --- a/package/winx86/translations/strings_fr.nsh +++ b/package/winx86/translations/strings_fr.nsh @@ -31,6 +31,9 @@ LangString DESC_InSecSounds ${LANG_FRENCH} "Fichiers son GCS (pour les notifications sonores)." LangString DESC_InSecLocalization ${LANG_FRENCH} "Fichiers de localisation (langues supportées)." LangString DESC_InSecFirmware ${LANG_FRENCH} "OpenPilot firmware binaries." + LangString DESC_InSecUtilities ${LANG_FRENCH} "OpenPilot utilities (Matlab log parser)." + LangString DESC_InSecDrivers ${LANG_FRENCH} "OpenPilot hardware driver files (optional OpenPilot CDC driver)." + LangString DESC_InSecInstallDrivers ${LANG_FRENCH} "Install OpenPilot CDC driver (optional)." LangString DESC_InSecShortcuts ${LANG_FRENCH} "Installer les raccourcis dans le menu démarrer." ;-------------------------------- diff --git a/package/winx86/translations/strings_ru.nsh b/package/winx86/translations/strings_ru.nsh index 4b5a380dd..f62e708d2 100644 --- a/package/winx86/translations/strings_ru.nsh +++ b/package/winx86/translations/strings_ru.nsh @@ -31,6 +31,9 @@ LangString DESC_InSecSounds ${LANG_RUSSIAN} "Звуковые файлы (используются для звуковых уведомлений о событиях)." LangString DESC_InSecLocalization ${LANG_RUSSIAN} "Файлы языковой поддержки (для поддерживаемых языков)." LangString DESC_InSecFirmware ${LANG_RUSSIAN} "Файлы прошивок OpenPilot." + LangString DESC_InSecUtilities ${LANG_RUSSIAN} "Утилиты (конвертор логов для Matlab)." + LangString DESC_InSecDrivers ${LANG_RUSSIAN} "Файлы драйверов (опциональный драйвер CDC порта)." + LangString DESC_InSecInstallDrivers ${LANG_RUSSIAN} "Установка опционального OpenPilot CDC драйвера." LangString DESC_InSecShortcuts ${LANG_RUSSIAN} "Установка ярлыков для приложения." ;-------------------------------- diff --git a/package/winx86/translations/strings_zh_CN.nsh b/package/winx86/translations/strings_zh_CN.nsh index 5dad290a8..5eff43762 100644 --- a/package/winx86/translations/strings_zh_CN.nsh +++ b/package/winx86/translations/strings_zh_CN.nsh @@ -31,6 +31,9 @@ LangString DESC_InSecSounds ${LANG_TRADCHINESE} "地面站音频文件(用于对于特定事件的提醒)." LangString DESC_InSecLocalization ${LANG_TRADCHINESE} "地面站本土化(适用于它所支持的语言)." LangString DESC_InSecFirmware ${LANG_TRADCHINESE} "OpenPilot firmware binaries." + LangString DESC_InSecUtilities ${LANG_TRADCHINESE} "OpenPilot utilities (Matlab log parser)." + LangString DESC_InSecDrivers ${LANG_TRADCHINESE} "OpenPilot hardware driver files (optional OpenPilot CDC driver)." + LangString DESC_InSecInstallDrivers ${LANG_TRADCHINESE} "Install OpenPilot CDC driver (optional)." LangString DESC_InSecShortcuts ${LANG_TRADCHINESE} "安装开始菜单的快捷方式." ;-------------------------------- diff --git a/shared/uavobjectdefinition/manualcontrolsettings.xml b/shared/uavobjectdefinition/manualcontrolsettings.xml index c2c8ec715..09d4ca618 100644 --- a/shared/uavobjectdefinition/manualcontrolsettings.xml +++ b/shared/uavobjectdefinition/manualcontrolsettings.xml @@ -23,7 +23,8 @@ - + + diff --git a/shared/uavobjectdefinition/systemsettings.xml b/shared/uavobjectdefinition/systemsettings.xml index f903e9f80..b5f5e9d4c 100644 --- a/shared/uavobjectdefinition/systemsettings.xml +++ b/shared/uavobjectdefinition/systemsettings.xml @@ -1,7 +1,7 @@ Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand - +