[Tinyos-commits] CVS: tinyos-1.x/tos/lib/Registry AttrBackend.nc, NONE, 1.1 Attribute.nc, NONE, 1.1 AttributeM.nc, NONE, 1.1 GenericBackend.nc, NONE, 1.1 NucleusAttrWrapperC.nc, NONE, 1.1 README, NONE, 1.1 RegistryM.nc, NONE, 1.1

Kamin Whitehouse kaminw at users.sourceforge.net
Fri Sep 23 03:13:57 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/Registry
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4228/Registry

Added Files:
	AttrBackend.nc Attribute.nc AttributeM.nc GenericBackend.nc 
	NucleusAttrWrapperC.nc README RegistryM.nc 
Log Message:
These are 5 new tinyos libraries to: 1) automatically define a namespace of node attributes such as location, sensor values, etc, which is exposed through a central 'registry' 2) store these attributes to flash 3) expand that namespace to attributes of neighbors (hood) 4) expose arbitrary functions, including the get/set functions of registry attributes to other nodes and/or the pc through an rpc interface 5) expose arbitrary module variables through the same rpc interface.  These libraries require code generation and must be used with nesc 1.2 or later. the code generation scripts are in tinyos-1.x/tools/scripts/codeGeneration.

--- NEW FILE: AttrBackend.nc ---
/*									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.
 */

/**
 * @author Kamin Whitehouse
 */

interface AttrBackend
{
  command uint8_t size();
  command const void* get(); //return NULL if not valid
  command result_t set(const void* val);
  command result_t update();
  event void updated(const void* newval);//newval=NULL if not valid
}


--- NEW FILE: Attribute.nc ---
/*									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.
 */

/**
 * @author Kamin Whitehouse
 */

interface Attribute<t>
{
  command bool valid();
  command t get();
  command result_t set(t val);
  command bool update();
  event void updated(t val);
}


--- NEW FILE: AttributeM.nc ---
/*									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.
 */

/**
 * @author Kamin Whitehouse
 */

generic module AttributeM(typedef AttributeType_t) {
  provides{
    interface StdControl;
    interface Attribute<AttributeType_t>;
    interface AttrBackend;
  }
}
implementation {
  AttributeType_t val;
  bool isvalid;

  command result_t StdControl.init() {
    isvalid=0;
    return SUCCESS;
  }

  command result_t StdControl.start() {
    return SUCCESS;
  }

  command result_t StdControl.stop() {
    return SUCCESS;
  }

  command bool Attribute.valid() {
    return isvalid;
  }

  command AttributeType_t Attribute.get() {
    return val;
  }

  command const void* AttrBackend.get() {
    return &val;
  }

  command result_t Attribute.set(AttributeType_t newval) {
    val=newval;
    isvalid=TRUE;
    signal Attribute.updated(val);
    signal AttrBackend.updated(&val);
    return SUCCESS;
  }
  command result_t AttrBackend.set(const void* newval) {
    if (newval!=NULL)
      return call Attribute.set( (*(AttributeType_t*)newval));
    else
      return FAIL;
  }

  command result_t Attribute.update() {
    //the default Attribute is cached, not split-phase
    return FAIL;
  }
  command result_t AttrBackend.update() {
    //the default Attribute is cached, not split-phase
    return FAIL;
  }


  default event void Attribute.updated(AttributeType_t newval)  {
  }
  default event void AttrBackend.updated(const void* newval)  {
  }


  command uint8_t AttrBackend.size() {
    return sizeof(AttributeType_t);
  }

}


--- NEW FILE: GenericBackend.nc ---
/*									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.
 */

/**
 * @author Kamin Whitehouse
 */

interface GenericBackend
{

  command uint8_t size(const void* itemID);
  command const void* get(const void* itemID); //return NULL if not valid
  command result_t update(const void* itemID);
  event void updated(const void* itemID, const void* newvalue);//newvalue= NULL if not valid
  command result_t set(const void* itemID, const void* data);

}


--- NEW FILE: NucleusAttrWrapperC.nc ---
includes Attrs;

generic module NucleusAttrWrapperC(typedef attr_type)
{
  provides interface Attr<attr_type>;
  provides interface AttrSet<attr_type>;
  uses interface Attribute<attr_type>;
}
implementation
{
  command result_t Attr.get( attr_type* buf )
  {
    if( call Attribute.valid() )
    {
      attr_type stackHolder = call Attribute.get();
      memcpy(buf, &stackHolder, sizeof(attr_type));
      signal Attr.getDone(buf);
      return SUCCESS;
    }
    else{
      return FAIL;
    }
  }

  event void Attribute.updated( attr_type val )
  {
    signal Attr.changed(&val);
  }

  default event result_t Attr.getDone( attr_type* buf )
  {
    return SUCCESS;
  }

  default event result_t Attr.changed( attr_type* buf )
  {
    return SUCCESS;
  }

  command result_t AttrSet.set( attr_type* buf )
  {
    result_t result;
    attr_type stackHolder;
    memcpy(&stackHolder, buf, sizeof(attr_type));
    result = call Attribute.set(stackHolder);
    signal AttrSet.setDone(buf);
    return result;
  }

  default event result_t AttrSet.setDone( attr_type* buf )
  {
    return SUCCESS;
  }
}


--- NEW FILE: README ---
directory: tinyos-1.x/tos/lib/Registry
author: kamin whitehouse
date: 9/23/05

Please see the following wiki page for documentation:
http://today.cs.berkeley.edu/nestfe/index.php/Registry

--- NEW FILE: RegistryM.nc ---
/*									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.
 */

/**
 * @author Kamin Whitehouse
 */

module RegistryM{
  provides {
    interface StdControl;
    interface GenericBackend;
    interface AttrBackend as MockAttrBackend;
  }
  uses {
    interface AttrBackend[AttrID_t attrID];
  }
}
implementation {

  /*******************
   * this module just translates from the runtime parameter used by
   * GenericBackend to the compile time parameter used by AttrBackend.
   *****************/

  command uint8_t GenericBackend.size(const void* itemID){
    return call AttrBackend.size[*(AttrID_t*)itemID]();
  }

  command const void* GenericBackend.get(const void* itemID){
    return call AttrBackend.get[*(AttrID_t*)itemID]();
  }

  command result_t GenericBackend.update(const void* itemID){
    return call AttrBackend.update[*(AttrID_t*)itemID]();
  }

  command result_t GenericBackend.set(const void* itemID, const void* data){
    return call AttrBackend.set[*(AttrID_t*)itemID](data);
  }

  event void AttrBackend.updated[uint8_t attrID](const void* val){
    signal GenericBackend.updated(&attrID, val);
  }

  default command uint8_t AttrBackend.size[AttrID_t attrID](){
    return 0;
  }

  default command const void* AttrBackend.get[AttrID_t attrID](){
    return NULL;
  }

  default command result_t AttrBackend.set[AttrID_t attrID](const void* val){
    return FAIL;
  }

  default command result_t AttrBackend.update[AttrID_t attrID](){
    return FAIL;
  }

  default event void GenericBackend.updated(const void* itemID, const void* newvalue){
  }

  // Stub StdControl implementation to make RegistryC happy if there are
  // no other StdControl's to wire to
  command result_t StdControl.init() { return SUCCESS; }
  command result_t StdControl.start() { return SUCCESS; }
  command result_t StdControl.stop() { return SUCCESS; }

  // Mock AttrBackend implementaiton to make RegistryC happy if there are
  // no other AttrBackend's to wire to
  command uint8_t MockAttrBackend.size() { return 0; }
  command const void* MockAttrBackend.get() { return NULL; }
  command result_t MockAttrBackend.set(const void* val) { return FAIL; }
  command result_t MockAttrBackend.update() { return FAIL; }
}




More information about the Tinyos-commits mailing list