1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-251 UAVObject/WatchdogStatus: Sorry forgot files earlier for monitoring what

triggered previous watchdog resets

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2369 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2011-01-10 05:42:57 +00:00 committed by peabody124
parent bbbd9a10e3
commit 3abcfc9608
6 changed files with 526 additions and 0 deletions

View File

@ -0,0 +1,93 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup WatchdogStatus WatchdogStatus
* @brief For monitoring the flags in the watchdog and especially the bootup flags
*
* Autogenerated files and functions for WatchdogStatus Object
* @{
*
* @file watchdogstatus.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the WatchdogStatus object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: watchdogstatus.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @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 WATCHDOGSTATUS_H
#define WATCHDOGSTATUS_H
// Object constants
#define WATCHDOGSTATUS_OBJID 3594971408U
#define WATCHDOGSTATUS_NAME "WatchdogStatus"
#define WATCHDOGSTATUS_METANAME "WatchdogStatusMeta"
#define WATCHDOGSTATUS_ISSINGLEINST 1
#define WATCHDOGSTATUS_ISSETTINGS 0
#define WATCHDOGSTATUS_NUMBYTES sizeof(WatchdogStatusData)
// Object access macros
/**
* @function WatchdogStatusGet(dataOut)
* @brief Populate a WatchdogStatusData object
* @param[out] dataOut
*/
#define WatchdogStatusGet(dataOut) UAVObjGetData(WatchdogStatusHandle(), dataOut)
#define WatchdogStatusSet(dataIn) UAVObjSetData(WatchdogStatusHandle(), dataIn)
#define WatchdogStatusInstGet(instId, dataOut) UAVObjGetInstanceData(WatchdogStatusHandle(), instId, dataOut)
#define WatchdogStatusInstSet(instId, dataIn) UAVObjSetInstanceData(WatchdogStatusHandle(), instId, dataIn)
#define WatchdogStatusConnectQueue(queue) UAVObjConnectQueue(WatchdogStatusHandle(), queue, EV_MASK_ALL_UPDATES)
#define WatchdogStatusConnectCallback(cb) UAVObjConnectCallback(WatchdogStatusHandle(), cb, EV_MASK_ALL_UPDATES)
#define WatchdogStatusCreateInstance() UAVObjCreateInstance(WatchdogStatusHandle())
#define WatchdogStatusRequestUpdate() UAVObjRequestUpdate(WatchdogStatusHandle())
#define WatchdogStatusRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(WatchdogStatusHandle(), instId)
#define WatchdogStatusUpdated() UAVObjUpdated(WatchdogStatusHandle())
#define WatchdogStatusInstUpdated(instId) UAVObjUpdated(WatchdogStatusHandle(), instId)
#define WatchdogStatusGetMetadata(dataOut) UAVObjGetMetadata(WatchdogStatusHandle(), dataOut)
#define WatchdogStatusSetMetadata(dataIn) UAVObjSetMetadata(WatchdogStatusHandle(), dataIn)
#define WatchdogStatusReadOnly(dataIn) UAVObjReadOnly(WatchdogStatusHandle())
// Object data
typedef struct {
uint16_t BootupFlags;
uint16_t ActiveFlags;
} __attribute__((packed)) WatchdogStatusData;
// Field information
// Field BootupFlags information
// Field ActiveFlags information
// Generic interface functions
int32_t WatchdogStatusInitialize();
UAVObjHandle WatchdogStatusHandle();
#endif // WATCHDOGSTATUS_H
/**
* @}
* @}
*/

View File

@ -0,0 +1,111 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup WatchdogStatus WatchdogStatus
* @brief For monitoring the flags in the watchdog and especially the bootup flags
*
* Autogenerated files and functions for WatchdogStatus Object
* @{
*
* @file watchdogstatus.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the WatchdogStatus object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: watchdogstatus.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @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 "openpilot.h"
#include "watchdogstatus.h"
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
* \return 0 Success
* \return -1 Failure
*/
int32_t WatchdogStatusInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(WATCHDOGSTATUS_OBJID, WATCHDOGSTATUS_NAME, WATCHDOGSTATUS_METANAME, 0,
WATCHDOGSTATUS_ISSINGLEINST, WATCHDOGSTATUS_ISSETTINGS, WATCHDOGSTATUS_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
WatchdogStatusData data;
UAVObjMetadata metadata;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(WatchdogStatusData));
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.access = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.telemetryAcked = 0;
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.telemetryUpdatePeriod = 5000;
metadata.gcsTelemetryAcked = 0;
metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
metadata.loggingUpdatePeriod = 5000;
UAVObjSetMetadata(obj, &metadata);
}
/**
* Get object handle
*/
UAVObjHandle WatchdogStatusHandle()
{
return handle;
}
/**
* @}
*/

View File

@ -0,0 +1,134 @@
/**
******************************************************************************
*
* @file watchdogstatus.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup UAVObjectsPlugin UAVObjects Plugin
* @{
*
* @note Object definition file: watchdogstatus.xml.
* 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
* (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 "watchdogstatus.h"
#include "uavobjectfield.h"
const QString WatchdogStatus::NAME = QString("WatchdogStatus");
const QString WatchdogStatus::DESCRIPTION = QString("For monitoring the flags in the watchdog and especially the bootup flags");
/**
* Constructor
*/
WatchdogStatus::WatchdogStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
QStringList BootupFlagsElemNames;
BootupFlagsElemNames.append("0");
fields.append( new UAVObjectField(QString("BootupFlags"), QString(""), UAVObjectField::UINT16, BootupFlagsElemNames, QStringList()) );
QStringList ActiveFlagsElemNames;
ActiveFlagsElemNames.append("0");
fields.append( new UAVObjectField(QString("ActiveFlags"), QString(""), UAVObjectField::UINT16, ActiveFlagsElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
// Set the default field values
setDefaultFieldValues();
// Set the object description
setDescription(DESCRIPTION);
}
/**
* Get the default metadata for this object
*/
UAVObject::Metadata WatchdogStatus::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 0;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.flightTelemetryAcked = 0;
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
metadata.flightTelemetryUpdatePeriod = 5000;
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
metadata.loggingUpdatePeriod = 5000;
return metadata;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
void WatchdogStatus::setDefaultFieldValues()
{
}
/**
* Get the object data fields
*/
WatchdogStatus::DataFields WatchdogStatus::getData()
{
QMutexLocker locker(mutex);
return data;
}
/**
* Set the object data fields
*/
void WatchdogStatus::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**
* Create a clone of this object, a new instance ID must be specified.
* Do not use this function directly to create new instances, the
* UAVObjectManager should be used instead.
*/
UAVDataObject* WatchdogStatus::clone(quint32 instID)
{
WatchdogStatus* obj = new WatchdogStatus();
obj->initialize(instID, this->getMetaObject());
return obj;
}
/**
* Static function to retrieve an instance of the object.
*/
WatchdogStatus* WatchdogStatus::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{
return dynamic_cast<WatchdogStatus*>(objMngr->getObject(WatchdogStatus::OBJID, instID));
}

View File

@ -0,0 +1,81 @@
/**
******************************************************************************
*
* @file watchdogstatus.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup UAVObjectsPlugin UAVObjects Plugin
* @{
*
* @note Object definition file: watchdogstatus.xml.
* 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
* (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 WATCHDOGSTATUS_H
#define WATCHDOGSTATUS_H
#include "uavdataobject.h"
#include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT WatchdogStatus: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
quint16 BootupFlags;
quint16 ActiveFlags;
} __attribute__((packed)) DataFields;
// Field information
// Field BootupFlags information
// Field ActiveFlags information
// Constants
static const quint32 OBJID = 3594971408U;
static const QString NAME;
static const QString DESCRIPTION;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
WatchdogStatus();
DataFields getData();
void setData(const DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
static WatchdogStatus* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private:
DataFields data;
void setDefaultFieldValues();
};
#endif // WATCHDOGSTATUS_H

View File

@ -0,0 +1,96 @@
##
##############################################################################
#
# @file watchdogstatus.py
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
# @brief Implementation of the WatchdogStatus object. This file has been
# automatically generated by the UAVObjectGenerator.
#
# @note Object definition file: watchdogstatus.xml.
# This is an automatically generated file.
# DO NOT modify manually.
#
# @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
#
import uavobject
import struct
from collections import namedtuple
# This is a list of instances of the data fields contained in this object
_fields = [ \
uavobject.UAVObjectField(
'BootupFlags',
'H',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'ActiveFlags',
'H',
1,
[
'0',
],
{
}
),
]
class WatchdogStatus(uavobject.UAVObject):
## Object constants
OBJID = 3594971408
NAME = "WatchdogStatus"
METANAME = "WatchdogStatusMeta"
ISSINGLEINST = 1
ISSETTINGS = 0
def __init__(self):
uavobject.UAVObject.__init__(self,
self.OBJID,
self.NAME,
self.METANAME,
0,
self.ISSINGLEINST)
for f in _fields:
self.add_field(f)
def __str__(self):
s = ("0x%08X (%10u) %-30s %3u bytes format '%s'\n"
% (self.OBJID, self.OBJID, self.NAME, self.get_struct().size, self.get_struct().format))
for f in self.get_tuple()._fields:
s += ("\t%s\n" % f)
return (s)
def main():
# Instantiate the object and dump out some interesting info
x = WatchdogStatus()
print (x)
if __name__ == "__main__":
#import pdb ; pdb.run('main()')
main()

View File

@ -0,0 +1,11 @@
<xml>
<object name="WatchdogStatus" singleinstance="true" settings="false">
<description>For monitoring the flags in the watchdog and especially the bootup flags</description>
<field name="BootupFlags" units="" type="uint16" elements="1"/>
<field name="ActiveFlags" units="" type="uint16" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="periodic" period="5000"/>
<logging updatemode="periodic" period="5000"/>
</object>
</xml>