[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/diagmsg Assert.h, NONE, 1.1 AssertC.nc, NONE, 1.1 AssertP.nc, NONE, 1.1 DiagMsg.nc, NONE, 1.1 DiagMsg.txt, NONE, 1.1 DiagMsgC.nc, NONE, 1.1 DiagMsgM.nc, NONE, 1.1 NoDiagMsgC.nc, NONE, 1.1

Janos Sallai sallai at users.sourceforge.net
Mon Nov 5 12:37:13 PST 2007


Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/diagmsg
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27501

Added Files:
	Assert.h AssertC.nc AssertP.nc DiagMsg.nc DiagMsg.txt 
	DiagMsgC.nc DiagMsgM.nc NoDiagMsgC.nc 
Log Message:
platform support for the IRIS mote (atm1218 MCU and rf230 radio)

--- NEW FILE: Assert.h ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

#ifndef __ASSERT_H__
#define __ASSERT_H__

#ifdef ASSERT_NONE

	#define ASSERT(COND) for(;0;)

#else

	void assert(bool condition, const char* file, uint16_t line);
	#define ASSERT(COND) assert(COND, __FILE__, __LINE__)

#endif

#endif//__ASSERT_H__

--- NEW FILE: AssertC.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

configuration AssertC
{
}

implementation
{
#ifndef ASSERT_NONE

	components AssertP, DiagMsgC;
	AssertP.DiagMsg -> DiagMsgC;

#endif
}

--- NEW FILE: AssertP.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

module AssertP
{
	uses interface DiagMsg;
}

implementation
{
	void assert(bool condition, const char* file, uint16_t line) __attribute__((noinline)) @C() @spontaneous()
	{
		if( ! condition && call DiagMsg.record() )
		{
			uint8_t del = 0;
			uint8_t len = 0;

			while( file[len] != 0 )
			{
				if( file[len] == '\\' || file[len] == '/' )
					del = len + 1;

				++len;
			}

			file += del;

			call DiagMsg.str("assert");
			call DiagMsg.str(file);
			call DiagMsg.uint16(line);
			call DiagMsg.send();
		}
	}
}

--- NEW FILE: DiagMsg.nc ---
/*
 * Copyright (c) 2002-2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

/**
 * The DiagMsg interface allows messages to be sent back to the base station
 * containing several values and their type information, like in 
 * <code>printf(...)</code>. The base station must be connected to a PC using 
 * a serial cable. On the PC a Java application (net.tinyos.util.DiagMsg) 
 * decodes the message and displays its content using the correct type 
 * information. See the implementation for the format of the message.
 */
interface DiagMsg
{
	/**
	 * Initiates the recording of a new DiagMsg. It returns FALSE if
	 * the component is busy recording or sending another message.
	 */
	async command bool record();

	/**
	 * Adds a new value to the end of the message. If the message 
	 * cannot hold more information, then the new value is simply dropped.
	 */
	async command void int8(int8_t value);
	async command void uint8(uint8_t value);
	async command void hex8(uint8_t value);
	async command void int16(int16_t value);
	async command void uint16(uint16_t value);
	async command void hex16(uint16_t value);
	async command void int32(int32_t value);
	async command void int64(int64_t value);
	async command void uint64(uint64_t value);
	async command void uint32(uint32_t value);
	async command void hex32(uint32_t value);
	async command void real(float value);
	async command void chr(char value);

	/**
	 * Adds an array of values to the end of the message. 
	 * The maximum length of the array is <code>15</code>.
	 * If the message cannot hold all elements of the array,
	 * then no value is stored.
	 */
	async command void int8s(const int8_t *value, uint8_t len);
	async command void uint8s(const uint8_t *value, uint8_t len);
	async command void hex8s(const uint8_t *value, uint8_t len);
	async command void int16s(const int16_t *value, uint8_t len);
	async command void uint16s(const uint16_t *value, uint8_t len);
	async command void hex16s(const uint16_t *value, uint8_t len);
	async command void int32s(const int32_t *value, uint8_t len);
	async command void uint32s(const uint32_t *value, uint8_t len);
	async command void hex32s(const uint32_t *value, uint8_t len);
	async command void int64s(const int64_t *value, uint8_t len);
	async command void uint64s(const uint64_t *value, uint8_t len);
	async command void reals(const float *value, uint8_t len);
	async command void chrs(const char *value, uint8_t len);

	/**
	 * This is a shorthand method for <code>chrs</code>
	 */
	async command void str(const char* value);

	/**
	 * Initiates the sending of the recorded message. 
	 */
	async command void send();
}

--- NEW FILE: DiagMsg.txt ---
DiagMsg:

Author/Contact: miklos.maroti at vanderbilt.edu (Miklos Maroti, ISIS, Vanderbilt)

DESCRIPTION:

The DiagMsg component allows messages to be sent back to the base station 
containing several diagnostic or debugging values together with their type 
information. The base station must run the GenericBase or TOSBase application 
which forwards all messages to a PC connected to the base station. A java 
programm (PrintDiagMsgs) displays the messages on the screen according to 
the formating rules contained in the message.

The following data types are supported: 1,2, 4 and 8 byte long signed, unsigned and 
hexadecimal integers, characters, floating point numbers, strings and arrays 
of the previous types (of length up to 15). Each field requires an additional 
4 bit type descriptor.

USAGE:

When you want to report some data, write code something like this:

	if( call DiagMsg.record() )
	{
		call DiagMsg.str("test");
		call DiagMsg.uint8(17);
		call DiagMsg.int16(1973);
		call DiagMsg.real(12.345);
		call DiagMsg.chr('Z');
		call DiagMsg.uint32(123456789);
		call DiagMsg.send();
	}

The DiagMsg component will record the message and will send it as soon 
as possible. You can record up to 29 bytes of data in a single message.
Each field uses and additional 4-bit type descriptor. For arrays, including
strings, there is an additional 1-byte length descriptor as well. The diag 
message above, for example, uses

	5+1+1+2+4+1+4+7*0.5 = 21.5

that is 22 bytes. If the message cannot hold more fields, then additional 
fields will be silently ignored. 

THE JAVA PROGRAM:

The java program (DiagMsgs) displays each DiagMsg in a line. The program 
can connect to a SerialForward application, or can use the serial port directly.

TUNABLE PARAMETERS:

The DiagMsg component can be configured by defining the following values in 
your make file:

DIAGMSG_BASE_STATION: The node ID of the base station or 0xFFFF to broadcast
the message. The default value is to broadcast the message.

DIAGMSG_RETRY_COUNT: The DiagMsg component will retry messages this many times 
before dropping them. The base station must acknowledge them (this is done 
automatically).

DIAGMSG_RECORDED_MSGS: The DiagMsg component keeps an internal buffer of this 
many messages. This allows sending several small messages without waiting for 
their completion.

--- NEW FILE: DiagMsgC.nc ---
/*
 * Copyright (c) 2002-2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

configuration DiagMsgC
{
	provides interface DiagMsg;
}

implementation 
{
#ifdef DIAGMSG_NONE

components NoDiagMsgC;
	DiagMsg = NoDiagMsgC;

#else

	enum
	{
		AM_DIAG_MSG = 0xB1,
	};

	components DiagMsgM, MainC, SerialActiveMessageC;

	DiagMsg = DiagMsgM.DiagMsg;

	MainC.SoftwareInit -> DiagMsgM.Init;
	DiagMsgM.AMSend -> SerialActiveMessageC.AMSend[AM_DIAG_MSG];
	DiagMsgM.Packet -> SerialActiveMessageC;

#endif
}

--- NEW FILE: DiagMsgM.nc ---
/*
 * Copyright (c) 2002-2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

#include <message.h>

module DiagMsgM
{
	provides 
	{
		interface DiagMsg;
		interface Init;
	}

	uses 
	{
		interface AMSend;
		interface Packet;
	}
}

#ifndef DIAGMSG_BASE_STATION
#define	DIAGMSG_BASE_STATION	AM_BROADCAST_ADDR
#endif

#ifndef DIAGMSG_RETRY_COUNT
#define	DIAGMSG_RETRY_COUNT	2
#endif

#ifndef DIAGMSG_RECORDED_MSGS
#define DIAGMSG_RECORDED_MSGS	10
#endif

implementation
{
	enum
	{
		STATE_READY = 1,
		STATE_RECORDING_FIRST = 2,	// recording the first 4-bit descriptor
		STATE_RECORDING_SECOND = 3,	// recording the second 4-bit descriptor
		STATE_MSG_FULL = 4,
		STATE_BUFFER_FULL = 5,
	};

	norace volatile uint8_t state;	// the state of the recording

	message_t msgs[DIAGMSG_RECORDED_MSGS];	// circular buffer of messages

	norace message_t *recording;	// the message that is beeing or going to be recorded
	message_t *sending;	// the message that is beeing sent, or the null pointer

	norace uint8_t nextData;	// points to the next unsued byte
	norace uint8_t prevType;	// points to the type descriptor
	norace uint8_t retries;	// number of remaining retries

	command error_t Init.init()
	{
		state = STATE_READY;
		recording = msgs;
		sending = 0;

		return SUCCESS;
	}

	// two type fields are stored in on byte
	enum
	{
		TYPE_END = 0,
		TYPE_INT8 = 1,
		TYPE_UINT8 = 2,
		TYPE_HEX8 = 3,
		TYPE_INT16 = 4,
		TYPE_UINT16 = 5,
		TYPE_HEX16 = 6,
		TYPE_INT32 = 7,
		TYPE_UINT32 = 8,
		TYPE_HEX32 = 9,
		TYPE_FLOAT = 10,
		TYPE_CHAR = 11,
		TYPE_INT64 = 12,
		TYPE_UINT64 = 13,
		TYPE_ARRAY = 15,
	};

/*
	The format of the payload is as follows: 
	
	Each value has an associated data type descriptor. The descriptor takes 4-bits,
	and two descriptors are packed into one byte. The double-descriptor is followed
	by the data bytes needed to store the corresponding value. Two sample layouts are:

	[D2, D1] [V1] ... [V1] [V2] ... [V2]
	[D2, D1] [V1] ... [V1] [V2] ... [V2] [0, D3] [V3] ... [V3]

	where D1, D2, D3 denotes the data type descriptors, and V1, V2 and V3
	denotes the bytes where the corresponding values are stored. If there is an odd
	number of data descriptors, then a zero data descriptor <code>TYPE_END</code> 
	is inserted.

	Each data type (except arrays) uses a fixed number of bytes to store the value.
	For arrays, the first byte of the array holds the data type of the array (higer
	4 bits) and the length of the array (lower 4 bits). The actual data follows 
	this first byte.
*/

	async command bool DiagMsg.record()
	{
		atomic
		{
			// currently recording or no more space
			if( state != STATE_READY )
				return FALSE;

			state = STATE_RECORDING_FIRST;
			nextData = 0;
		}

		return TRUE;
	}

	/**
	 * Allocates space in the message for <code>size</code> bytes
	 * and sets the type information to <code>type</code>. 
	 * Returns the index in <code>msg.data</code> where the data 
	 * should be stored or <code>-1</code> if no more space is avaliable.
	 */
	int8_t allocate(uint8_t size, uint8_t type)
	{
		int8_t ret = -1;

		if( state == STATE_RECORDING_FIRST )
		{
			if( nextData + 1 + size <= TOSH_DATA_LENGTH )
			{
				state = STATE_RECORDING_SECOND;

				prevType = nextData++;
				((uint8_t*) &(recording->data))[prevType] = type;
				ret = nextData;
				nextData += size;
			}
			else
				state = STATE_MSG_FULL;
		}
		else if( state == STATE_RECORDING_SECOND )
		{
			if( nextData + size <= TOSH_DATA_LENGTH )
			{
				state = STATE_RECORDING_FIRST;

				((uint8_t*) &(recording->data))[prevType] += (type << 4);
				ret = nextData;
				nextData += size;
			}
			else
				state = STATE_MSG_FULL;
		}

		return ret;
	}

#define IMPLEMENT(NAME, TYPE, TYPE2) \
	async command void DiagMsg.NAME(TYPE value) \
	{ \
		int8_t start = allocate(sizeof(TYPE), TYPE2); \
		if( start >= 0 ) \
			*(TYPE*)((uint8_t*) &(recording->data) + start) = value; \
	} \
	async command void DiagMsg.NAME##s(const TYPE *value, uint8_t len) \
	{ \
		int8_t start; \
		if( len > 15 ) len = 15; \
		start = allocate(sizeof(TYPE)*len + 1, TYPE_ARRAY); \
		if( start >= 0 ) \
		{ \
			((uint8_t*) &(recording->data))[start++] = (TYPE2 << 4) + len; \
			while( len-- != 0 ) \
				((TYPE*)((uint8_t*) &(recording->data) + start))[len] = value[len]; \
		} \
	}

	IMPLEMENT(int8, int8_t, TYPE_INT8)
	IMPLEMENT(uint8, uint8_t, TYPE_UINT8)
	IMPLEMENT(hex8, uint8_t, TYPE_HEX8)
	IMPLEMENT(int16, int16_t, TYPE_INT16)
	IMPLEMENT(uint16, uint16_t, TYPE_UINT16)
	IMPLEMENT(hex16, uint16_t, TYPE_HEX16)
	IMPLEMENT(int32, int32_t, TYPE_INT32)
	IMPLEMENT(uint32, uint32_t, TYPE_UINT32)
	IMPLEMENT(hex32, uint32_t, TYPE_HEX32)
	IMPLEMENT(int64, int64_t, TYPE_INT64)
	IMPLEMENT(uint64, uint64_t, TYPE_UINT64)
	IMPLEMENT(real, float, TYPE_FLOAT)
	IMPLEMENT(chr, char, TYPE_CHAR)

	async command void DiagMsg.str(const char* str)
	{
		int8_t len = 0;
		while( str[len] != 0 && len < 15 )
			++len;
		
		call DiagMsg.chrs(str, len);
	}

	// TODO: this is a hack because setPayloadLength should be async
	inline void setPayloadLength(message_t* msg, uint8_t length)
	{
		(*(uint8_t*) &(msg->header)) = length;
	}

	inline uint8_t getPayloadLength(message_t* msg)
	{
		return *(uint8_t*) &(msg->header);
	}

	task void send()
	{
		message_t* msg;

		atomic msg = sending;

		if( call AMSend.send(DIAGMSG_BASE_STATION, msg, getPayloadLength(msg)) != SUCCESS )
			post send();
	}

	// calculates the next message_t pointer in the <code>msgs</code> circular buffer
	static inline message_t* nextPointer(message_t* ptr)
	{
		if( ++ptr >= msgs + DIAGMSG_RECORDED_MSGS )
			return msgs;
		else
			return ptr;
	}

	async command void DiagMsg.send()
	{
		// no message recorded
		if( state == STATE_READY )
			return;

		// store the length
		setPayloadLength(recording, nextData);

		atomic
		{
			if( sending == 0 )
			{
				sending = recording;
				retries = DIAGMSG_RETRY_COUNT;
				post send();
			}
	
			recording = nextPointer(recording);

			if( recording == sending )
				state = STATE_BUFFER_FULL;
			else
				state = STATE_READY;
		}
	}

	event void AMSend.sendDone(message_t* p, error_t error)
	{
		atomic
		{
			// retry if not successful
			if( error != SUCCESS && --retries > 0 )
				post send();
			else
			{
				p = nextPointer(sending);
				if( p != recording )
				{
					sending = p;
					retries = DIAGMSG_RETRY_COUNT;
					post send();
				}
				else
				{
					sending = 0;

					if( state == STATE_BUFFER_FULL )
					{
						state = STATE_READY;
						if( call DiagMsg.record() )
						{
							call DiagMsg.str("DiagMsgOverflow");
							call DiagMsg.send();
						}
					}
				}
			}
		}
	}
}

--- NEW FILE: NoDiagMsgC.nc ---
/*
 * Copyright (c) 2003-2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

module NoDiagMsgC
{
	provides interface DiagMsg;
}

implementation
{
	async command bool DiagMsg.record()
	{
		return FALSE;
	}

#define IMPLEMENT(NAME, TYPE, TYPE2) \
	async command void DiagMsg.NAME(TYPE value) { } \
	async command void DiagMsg.NAME##s(const TYPE *value, uint8_t len) { }

	IMPLEMENT(int8, int8_t, TYPE_INT8)
	IMPLEMENT(uint8, uint8_t, TYPE_UINT8)
	IMPLEMENT(hex8, uint8_t, TYPE_HEX8)
	IMPLEMENT(int16, int16_t, TYPE_INT16)
	IMPLEMENT(uint16, uint16_t, TYPE_UINT16)
	IMPLEMENT(hex16, uint16_t, TYPE_HEX16)
	IMPLEMENT(int32, int32_t, TYPE_INT32)
	IMPLEMENT(uint32, uint32_t, TYPE_UINT32)
	IMPLEMENT(hex32, uint32_t, TYPE_HEX32)
	IMPLEMENT(int64, int64_t, TYPE_INT64)
	IMPLEMENT(uint64, uint64_t, TYPE_UINT64)
	IMPLEMENT(real, float, TYPE_FLOAT)
	IMPLEMENT(chr, char, TYPE_CHAR)

	async command void DiagMsg.str(const char* str) { }
	async command void DiagMsg.send() { }
}



More information about the Tinyos-2-commits mailing list