[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/ustutt/ncunit/mote
Assert.nc, NONE, 1.1 AssertM.nc, NONE, 1.1 ncunit.h, NONE,
1.1 debug_gcc.h, NONE, 1.1 dbg.h, NONE, 1.1 debugoutput.h,
NONE, 1.1 AssertC.nc, NONE, 1.1
Andreas Lachenmann
lachenmann at users.sourceforge.net
Tue Feb 20 04:33:07 PST 2007
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/ustutt/ncunit/java/avrora/sim/clock
ClockPrescaler.java, NONE, 1.1 Synchronizer.java, NONE,
1.1 DerivedClock.java, NONE, 1.1 ClockDomain.java, NONE,
1.1 Clock.java, NONE, 1.1 SystemClock.java, NONE,
1.1 DeltaQueue.java, NONE, 1.1 MainClock.java, NONE,
1.1 StepSynchronizer.java, NONE, 1.1 IntervalSynchronizer.java,
NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/ustutt/ncunit/java/ncunit/parser
NCUnitParserConstants.java, NONE, 1.1 ParseException.java,
NONE, 1.1 NCUnitParser.java, NONE, 1.1 SimpleCharStream.java,
NONE, 1.1 TokenMgrError.java, NONE,
1.1 NCUnitParserTokenManager.java, NONE, 1.1 Token.java, NONE,
1.1 ncunit.jj, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/ustutt/ncunit/mote
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4808/contrib/ustutt/ncunit/mote
Added Files:
Assert.nc AssertM.nc ncunit.h debug_gcc.h dbg.h debugoutput.h
AssertC.nc
Log Message:
added files to repository
--- NEW FILE: Assert.nc ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "ncunit.h"
interface Assert {
// Checks if the pointer is NULL
command void assertNull(void* pointer);
command void assertNullMsg(char* message, void* pointer);
// Checks if the pointer is not NULL
command void assertNotNull(void* pointer);
command void assertNotNullMsg(char* message, void* pointer);
// Checks if the value is TRUE
command void assertTrue(bool value);
command void assertTrueMsg(char* message, bool value);
// Checks if the value is FALSE
command void assertFalse(bool value);
command void assertFalseMsg(char* message, bool value);
// Checks if the pointers point to the same address
command void assertSame(void* pointer1, void* pointer2);
command void assertSameMsg(char* message, void* pointer1, void* pointer2);
// Checks if the pointers point not to the same address
command void assertNotSame(void* pointer1, void* pointer2);
command void assertNotSameMsg(char* message, void* pointer1, void* pointer2);
// Checks if the integers are equal
command void assertEqualsInt(int32_t int1, int32_t int2);
command void assertEqualsIntMsg(char* message, int32_t int1, int32_t int2);
// Checks if the integers are equal
command void assertEqualsUint(uint32_t uint1, uint32_t uint2);
command void assertEqualsUintMsg(char* message, uint32_t uint1, uint32_t uint2);
// Checks if the bools are equal
command void assertEqualsBool(bool bool1, bool bool2);
command void assertEqualsBoolMsg(char* message, bool bool1, bool bool2);
// Checks if the doubles are equal
command void assertEqualsDouble(double double1, double double2);
command void assertEqualsDoubleMsg(char* message, double double1, double double2);
// Checks if the floats are equal
command void assertEqualsFloat(float float1, float float2);
command void assertEqualsFloatMsg(char* message, float float1, float float2);
// Checks if the memory regions pointed to by the pointers have the same content
command void assertEqualsMem(void* pointer1, void* pointer2, uint16_t size);
command void assertEqualsMemMsg(char* message, void* pointer1, void* pointer2, uint16_t size);
// Fail the test case
command void fail();
command void failMsg(char* message);
// Execute Java code in the simulator to test assertions
// timerDelay may contain a timer value in milliseconds if the
// check code should be executed after some time (otherwise 0).
command void assertJavaClass(char* javaClass, uint32_t timerDelay);
command void assertJavaClassMsg(char* message, char* javaClass, uint32_t timerDelay);
// Checks if the given function is called during the remainig simulation
command void assertCalls(char* functionName, char* paramName, volatile void* value, CompOperator op);
command void assertCallsMsg(char* message, char* functionName, char* paramName, volatile void* value, CompOperator op);
// Returns a pointer to the given variable.
// Use "$" as a separator between component and variable name (e.g., AssertM$variable).
command void* getDataPointer(char* variableName);
}
--- NEW FILE: AssertM.nc ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
module AssertM {
provides {
interface Assert;
}
uses interface Leds;
}
implementation {
enum {
MSG_LENGTH = 80,
};
#include "ncunit.h"
typedef struct AssertJavaClassInfo {
volatile char* javaClass;
volatile char* message;
volatile uint32_t timerDelay;
} AssertJavaClassInfo;
typedef struct AssertCallsInfo {
volatile char* functionName;
volatile char* message;
volatile char* parameterName;
volatile void* comparisonValue;
volatile CompOperator compOperator;
} AssertCallsInfo;
typedef struct VariablePointerInfo{
volatile void* pointer;
volatile char* variableName;
} __attribute__((packed)) VariablePointerInfo;
static void assertFailMsg(char* message) __attribute__((noinline)) {
asm volatile ("nop"::);
#ifdef PLATFORM_PC
dbg_clear(DBG_USR1, "Assert failed: %s\n", message);
exit(1);
#endif
}
static void assertJavaClassMsg(AssertJavaClassInfo* info) __attribute__((noinline)) {
asm volatile ("nop"::);
}
static void assertCallsMsg(AssertCallsInfo* info) __attribute__((noinline)) {
asm volatile ("nop"::);
call Leds.yellowToggle();
}
static void getDataPointer(VariablePointerInfo* info) __attribute__((noinline)) {
asm volatile ("nop"::);
}
command void Assert.assertNull(void* pointer) {
call Assert.assertNullMsg("", pointer);
}
command void Assert.assertNullMsg(char* message, void* pointer) {
if (pointer != NULL) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertNull not NULL -- %s", message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertNotNull(void* pointer) {
call Assert.assertNotNullMsg("", pointer);
}
command void Assert.assertNotNullMsg(char* message, void* pointer) {
if (pointer == NULL) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertNotNull NULL -- %s", message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertTrue(bool value) {
call Assert.assertTrueMsg("", value);
}
command void Assert.assertTrueMsg(char* message, bool value) {
if (value != TRUE) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertTrue not TRUE -- %s", message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertFalse(bool value) {
call Assert.assertFalseMsg("", value);
}
command void Assert.assertFalseMsg(char* message, bool value) {
if (value != FALSE) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertFalse not FALSE -- %s", message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertSame(void* pointer1, void* pointer2) {
call Assert.assertSameMsg("", pointer1, pointer2);
}
command void Assert.assertSameMsg(char* message, void* pointer1, void* pointer2) {
if (pointer1 != pointer2) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertSame not the same %#x != %#x -- %s", pointer1, pointer2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertNotSame(void* pointer1, void* pointer2) {
call Assert.assertNotSameMsg("", pointer1, pointer2);
}
command void Assert.assertNotSameMsg(char* message, void* pointer1, void* pointer2) {
if (pointer1 == pointer2) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertNotSame are the same %#x == %#x -- %s", pointer1, pointer2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertEqualsInt(int32_t int1, int32_t int2) {
call Assert.assertEqualsIntMsg("", int1, int2);
}
command void Assert.assertEqualsIntMsg(char* message, int32_t int1, int32_t int2) {
if (int1 != int2) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertEqualsInt not equal %li != %li -- %s", int1, int2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertEqualsUint(uint32_t uint1, uint32_t uint2) {
call Assert.assertEqualsUintMsg("", uint1, uint2);
}
command void Assert.assertEqualsUintMsg(char* message, uint32_t uint1, uint32_t uint2) {
if (uint1 != uint2) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertEqualsUint not equal %li != %li -- %s", uint1, uint2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertEqualsBool(bool bool1, bool bool2) {
call Assert.assertEqualsBoolMsg("", bool1, bool2);
}
command void Assert.assertEqualsBoolMsg(char* message, bool bool1, bool bool2) {
if (bool1 != bool2) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertEqualsBool not equal %i != %i -- %s", bool1, bool2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertEqualsDouble(double double1, double double2) {
call Assert.assertEqualsDoubleMsg("", double1, double2);
}
command void Assert.assertEqualsDoubleMsg(char* message, double double1, double double2) {
if (double1 != double2) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertEqualsDouble not equal %f != %f -- %s", double1, double2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertEqualsFloat(float float1, float float2) {
call Assert.assertEqualsFloatMsg("", float1, float2);
}
command void Assert.assertEqualsFloatMsg(char* message, float float1, float float2) {
if (float1 != float2) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertEqualsFloat not equal %f != %f -- %s", float1, float2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.assertEqualsMem(void* pointer1, void* pointer2, uint16_t size) {
call Assert.assertEqualsMemMsg("", pointer1, pointer2, size);
}
command void Assert.assertEqualsMemMsg(char* message, void* pointer1, void* pointer2, uint16_t size) {
if (memcmp(pointer1, pointer2, size) != 0) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertEqualsMem not equal *%#x != *%#x -- %s", pointer1, pointer2, message);
assertFailMsg(completeMsg);
}
}
command void Assert.fail() {
call Assert.failMsg("");
}
command void Assert.failMsg(char* message) {
char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: failMsg -- %s", message);
assertFailMsg(completeMsg);
}
command void Assert.assertJavaClass(char* javaClass, uint32_t timerDelay) {
call Assert.assertJavaClassMsg("", javaClass, timerDelay);
}
command void Assert.assertJavaClassMsg(char* message, char* javaClass, uint32_t timerDelay) {
AssertJavaClassInfo javaClassInfo;
/* char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: assertJavaClassMsg %s -- %s", javaClass, message);*/
javaClassInfo.message = message;
javaClassInfo.javaClass = javaClass;
javaClassInfo.timerDelay = timerDelay;
assertJavaClassMsg(&javaClassInfo);
}
command void Assert.assertCalls(char* functionName, char* paramName, volatile void* value, CompOperator op) {
call Assert.assertCallsMsg("", functionName, paramName, value, op);
}
command void Assert.assertCallsMsg(char* message, char* functionName, char* paramName, volatile void* value, CompOperator op) {
volatile AssertCallsInfo callsInfo;
/* char completeMsg[MSG_LENGTH];
sprintf(completeMsg, "nCUnit: asserCallsMsg %s -- %s", functionName, message);*/
callsInfo.message = message;
callsInfo.functionName = functionName;
callsInfo.parameterName = paramName;
callsInfo.comparisonValue = value;
callsInfo.compOperator = op;
assertCallsMsg(&callsInfo);
}
command void* Assert.getDataPointer(char* variableName) {
VariablePointerInfo pointerInfo;
pointerInfo.variableName = variableName;
getDataPointer(&pointerInfo);
return (void*) pointerInfo.pointer;
}
}
--- NEW FILE: ncunit.h ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef NCUNIT_H_INCLUDED
#define NCUNIT_H_INCLUDED
struct @test {
};
typedef enum {
COMP_NONE = 0,
COMP_EQUALS = 1,
COMP_NOT_EQUALS = 2,
} CompOperator;
#endif
--- NEW FILE: debug_gcc.h ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef DEBUG_GCC_H
#define DEBUG_GCC_H
/*#include "debugoutput.h"
#include <stdarg.h>
#include <stdio.h>
enum {
MAX_DEBUG_STRING = 100,
};
typedef struct DebugData {
uint8_t level;
char string[MAX_DEBUG_STRING + 1];
} __attribute__((packed)) DebugData;
void __attribute__((noinline)) _debugOutput(DebugData* debugData) {
asm volatile ("nop"::);
}
// nesC compiler suppresses calls to dbg!
static void debug(uint8_t level, char* formatString, ...) {
va_list arguments;
DebugData debugData;
debugData.level = level;
va_start(arguments, formatString);
vsnprintf(debugData.string, MAX_DEBUG_STRING, formatString, arguments);
_debugOutput(&debugData);
va_end(arguments);
}
*/
static void __attribute__((noinline)) debug_int(uint16_t intValue) {
asm volatile ("nop"::);
}
#endif /* DBG_H */
--- NEW FILE: dbg.h ---
// $Id: dbg.h,v 1.1 2007/02/20 12:33:04 lachenmann Exp $
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/*
*
* Authors: David Gay, Philip Levis (from work by Mike Castelle), Nelson Lee
* Date last modified: 6/25/02
*
*/
/*
* FILE: dbg.h
* AUTHOR: pal
* DESCR: Run-time configuration of debug output in FULLPC mode.
*
* Debug output determined by DBG environment variable. dbg_modes.h has
* definitions of the settings possible. One can specify multiple debugging
* outputs by comma-delimiting (e.g. DBG=sched,timer). Compiling with
* NDEBUG defined (e.g. -DNDEBUG) will stop all of the debugging
* output, will remove the debugging commands from the object file.
*
* example usage: dbg(DBG_TIMER, "timer went off at %d\n", time);
*
*/
/**
* @author David Gay
* @author Philip Levis (from work by Mike Castelle)
* @author Nelson Lee
* @author pal
*/
#ifndef DBG_H
#define DBG_H
/* We're in FULLPC mode, and debugging is not turned off */
#if defined(PLATFORM_PC) && !defined(NDEBUG)
#include "dbg_modes.h"
#include <stdio.h>
#include <stdarg.h>
#include "nido.h"
#include "GuiMsg.h"
typedef struct dbg_mode {
char* d_name;
unsigned long long d_mode;
} TOS_dbg_mode_names;
TOS_dbg_mode dbg_modes = 0;
norace bool dbg_suppress_stdout = 0;
static bool dbg_active(TOS_dbg_mode mode)
{
return (dbg_modes & mode) != 0;
}
static void dbg_add_mode(const char *mode);
static void dbg_add_modes(const char *modes);
static void dbg_init(void);
static void dbg_help(void);
static void dbg_unset();
static void dbg_set(TOS_dbg_mode);
static void dbg(TOS_dbg_mode mode, const char *format, ...)
{
DebugMsgEvent ev;
if (dbg_active(mode)) {
va_list args;
// XXX MDW - used to be printf
va_start(args, format);
if (!(mode & DBG_SIM)) {
vsnprintf(ev.debugMessage, sizeof(ev.debugMessage), format, args);
sendTossimEvent(NODE_NUM, AM_DEBUGMSGEVENT, tos_state.tos_time, &ev);
}
if (! dbg_suppress_stdout) {
// XXX MDW - used to be vprintf
fprintf(stdout, "%i: ", NODE_NUM);
vfprintf(stdout, format, args);
va_end(args);
}
}
}
static void dbg_clear(TOS_dbg_mode mode, const char *format, ...)
{
DebugMsgEvent ev;
if (dbg_active(mode)) {
va_list args;
va_start(args, format);
if (!(mode & DBG_SIM)) {
vsnprintf(ev.debugMessage, sizeof(ev.debugMessage), format, args);
sendTossimEvent(NODE_NUM, AM_DEBUGMSGEVENT, tos_state.tos_time, &ev);
}
if (! dbg_suppress_stdout) {
// XXX MDW - used to be vprintf
vfprintf(stdout, format, args);
va_end(args);
}
}
}
#elif (defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2TEST)) && !defined(NDEBUG)
#include "debugoutput.h"
#include <stdarg.h>
#include <stdio.h>
enum {
MAX_DEBUG_STRING = 100,
};
typedef struct DebugData {
uint8_t level;
char string[MAX_DEBUG_STRING + 1];
} __attribute__((packed)) DebugData;
static void _debugOutput(DebugData* debugData) __attribute__((noinline)) {
asm volatile ("nop"::);
}
// nesC compiler suppresses calls to dbg!
static void debug(uint8_t level, char* formatString, ...) {
va_list arguments;
DebugData debugData;
debugData.level = level;
va_start(arguments, formatString);
vsnprintf(debugData.string, MAX_DEBUG_STRING, formatString, arguments);
_debugOutput(&debugData);
va_end(arguments);
}
static void debug_int(uint16_t intValue) __attribute__((noinline)) {
asm volatile ("nop"::);
}
#define dbg(...) { }
#define dbg_clear(...) { }
#define dbg_add_mode(...) { }
#define dbg_add_modes(...) { }
#define dbg_init() { }
#define dbg_help() { }
#define dbg_active(x) (TRUE)
#else
/* No debugging */
#include "dbg_modes.h"
#define dbg(...) { }
#define dbg_clear(...) { }
#define dbg_add_mode(...) { }
#define dbg_add_modes(...) { }
#define dbg_init() { }
#define dbg_help() { }
#define dbg_active(x) (FALSE)
#define debug(...) { }
#endif
#endif /* DBG_H */
--- NEW FILE: debugoutput.h ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef DEBUG_OUTPUT_H
#define DEBUG_OUTPUT_H
#define DBG_MODE(x) (x)
enum {
DBG_ALL = 0xff,
/*====== Core mote modes =============*/
DBG_BOOT = DBG_MODE(0), /* the boot sequence */
DBG_CLOCK = DBG_MODE(1), /* clock */
DBG_TASK = DBG_MODE(2), /* task stuff */
DBG_SCHED = DBG_MODE(3), /* switch, scheduling */
DBG_SENSOR = DBG_MODE(4), /* sensor readings */
DBG_LED = DBG_MODE(5), /* LEDs */
DBG_CRYPTO = DBG_MODE(6), /* Cryptography/security */
/*====== Networking modes ============*/
DBG_ROUTE = DBG_MODE(7), /* network routing */
DBG_AM = DBG_MODE(8), /* Active Messages */
DBG_CRC = DBG_MODE(9), /* packet CRC stuff */
DBG_PACKET = DBG_MODE(10), /* Packet level stuff */
DBG_ENCODE = DBG_MODE(11), /* Radio encoding/decoding */
DBG_RADIO = DBG_MODE(12), /* radio bits */
/*====== Misc. hardware & system =====*/
DBG_LOG = DBG_MODE(13), /* Logger component */
DBG_ADC = DBG_MODE(14), /* Analog Digital Converter */
DBG_I2C = DBG_MODE(15), /* I2C bus */
DBG_UART = DBG_MODE(16), /* UART */
DBG_PROG = DBG_MODE(17), /* Remote programming */
DBG_SOUNDER = DBG_MODE(18), /* SOUNDER component */
DBG_TIME = DBG_MODE(19), /* Time and Timer components */
DBG_POWER = DBG_MODE(20), /* Power profiling */
/*====== Simulator modes =============*/
DBG_SIM = DBG_MODE(21), /* Simulator */
DBG_QUEUE = DBG_MODE(22), /* Simulator event queue */
DBG_SIMRADIO = DBG_MODE(23), /* Simulator radio model */
DBG_HARD = DBG_MODE(24), /* Hardware emulation */
DBG_MEM = DBG_MODE(25), /* malloc/free */
//DBG_RESERVED = DBG_MODE(26), /* reserved for future use */
/*====== For application use =========*/
DBG_USR1 = DBG_MODE(27), /* User component 1 */
DBG_USR2 = DBG_MODE(28), /* User component 2 */
DBG_USR3 = DBG_MODE(29), /* User component 3 */
DBG_TEMP = DBG_MODE(30), /* Temorpary testing use */
DBG_ERROR = DBG_MODE(31), /* Error condition */
DBG_NONE = 0, /* Nothing */
DBG_DEFAULT = DBG_ALL /* default modes, 0 for none */
};
//static void debug(uint8_t level, char* formatString, ...);
#endif
--- NEW FILE: AssertC.nc ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* - Neither the names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
configuration AssertC {
provides {
interface Assert;
}
}
implementation {
components AssertM, LedsC;
Assert = AssertM;
AssertM.Leds -> LedsC;
}
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/ustutt/ncunit/java/avrora/sim/clock
ClockPrescaler.java, NONE, 1.1 Synchronizer.java, NONE,
1.1 DerivedClock.java, NONE, 1.1 ClockDomain.java, NONE,
1.1 Clock.java, NONE, 1.1 SystemClock.java, NONE,
1.1 DeltaQueue.java, NONE, 1.1 MainClock.java, NONE,
1.1 StepSynchronizer.java, NONE, 1.1 IntervalSynchronizer.java,
NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/ustutt/ncunit/java/ncunit/parser
NCUnitParserConstants.java, NONE, 1.1 ParseException.java,
NONE, 1.1 NCUnitParser.java, NONE, 1.1 SimpleCharStream.java,
NONE, 1.1 TokenMgrError.java, NONE,
1.1 NCUnitParserTokenManager.java, NONE, 1.1 Token.java, NONE,
1.1 ncunit.jj, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list