显示标签为“Wireless Sensor Networks”的博文。显示所有博文
显示标签为“Wireless Sensor Networks”的博文。显示所有博文

2008年4月2日

TinyOS和NesC资料

一些关于TinyOS和NesC的资料,因为经常有朋友问,所以就贴在这吧,有些事可以下载的文档,有些是链接,中文相关的就不提供。

NesC语言相关:

The nesC Language_ A Holistic Approach to Networked Embedded Systems(PDF)

nesC Language Reference Manual(PDF)

NCC Manual Page

nesC Source Documentation

nesC的PPT资料

TinyOS相关:

TinyOS编程经典资料:tinyos-programming(PDF)

TinyOS FAQ

tinyos hardware page

TinyOS网上教程

Lesson 1: An Introduction to TinyOS
Lesson 1 introduces the major concepts required to program TinyOS applications. These include a description of components, interfaces, commands, and events. The TinyOS programming model is explained. The role of each of the different file types is detailed.
Lesson 2: Event-driven Sensor Acquisition
The TinyOS platform provides primitives to obtain sensing data from tiny networked devices. This lesson details how to build a simple sensing application that records the light exposure on a photo diode.
Lesson 3: Introducing Tasks for Application Data Processing
The roles of both tasks and events are described. This lesson illustrates the use of tasks to process data from the sense application in lesson 2 and events to receive the sensor data and pass it on to the background running task.
Lesson 4: Composing Components to Send and Receive Messages
Lesson 4 introduces basic abstraction to send integers via the RFM radio stack. A counter application is built that sends the current value of the counter over the RF radio.
Lesson 5: Using the TOSSIM Simulator to Develop TinyOS Components
TOSSIM is the TinyOS simulator. Learn how to build, debug, and run components using TOSSIM.
Lesson 6: Displaying Data on a PC
In order to utilize the data from the tiny networked sensors, we must be able to analyze it on the host computer. This lesson provides an example application that graphs the light readings from the sensors over time.
Lesson 7: Broadcasting Packets
Lesson 7 has three components:
  • It shows how to inject packets from a host environment.
  • This is used to drive a simple message-based command interpreter. A general abstraction is used for sending arbitrary packets over the RFM radio stack.
  • A multihop broadcast application is built that floods the network with a task to be performed.
Lesson 8: Data Logging Application
The final lesson provides a fairly complete application for remote data logging and collection. It also illustrates a simple multihop data propogation method that allows data to be collected by a central location.

Technorati Tags: NesC,TinyOS,下载,链接


阅读全文...

Crossbow单节点声音采集NesC程序源码

<可以自由转载,但请注明以下内容,谢谢合作!>
<作者:Enoch Wang  引用自:
http://chinawangquan.spaces.live.com>

      在【TinyOS、NesC程序开发经验谈】文中已给出RSSI采集的代码,在【CrossBow公司MIB600基板Mote节点数据的接收(VC++篇)】文中给出了VC++平台下获取数据的方法,在【无线传感器网络MICA平台的RSSI原始数据转换为dBm值的方法】文中介绍了MICA平台的RSSI原始数据转换为dBm值的方法,应一些朋友的要求将简单的单节点声音采集NesC程序源码如下给出。

       (可以使用示例程序修改而成,以下代码即为示例程序修改而成,可以为大家修改程序作为借鉴。)  


/********************************************************************
        Copyright (C), 2006-2007, by Enoch.
        FileName:       SensorBoardApp.h 
        Author:         Enoch
        Version:        1.0.0.0
        Date:           2006 09 01
        Description:    Hardware specific definitions for the MTS300/310.
*********************************************************************/
#define MTS310
#define FEATURE_SOUNDER     1
// Define SOUND_STATE_CHANGE one of two ways:
//      One time sound at test init   ==>  FALSE
//      Continuous beeping throughout ==>  !sound_state
#define SOUND_STATE_CHANGE  FALSE
//#define SOUND_STATE_CHANGE  !sound_state
// crossbow sensor board id
#ifndef MTS310
#define  SENSOR_BOARD_ID 0x83               //MTS300 sensor board id
#else
#define  SENSOR_BOARD_ID 0x84               //MTS300 sensor board id
#endif
/********************************************************************
        Copyright (C), 2006-2007, by Enoch.
        FileName:       TestSouder.h 
        Author:         Enoch
        Version:        1.0.0.0
        Date:           2006 09 01
        Description:    Hardware specific definitions for the MTS300/310.
*********************************************************************/
enum
{
    INITIAL_TIMER_RATE = 10,
    INITIAL_TIMER_REAE_STEP = 8
};
enum
{
    BASE_ADDRESS = 0
};
typedef struct SurgeMsg
{
    uint8_t addr;
    uint16_t seq;
    uint16_t sound;
} __attribute__ ((packed))SurgeMsg;
enum
{
    AM_SURGEMSG = 17
};
 
/********************************************************************
        Copyright (C), 2006-2007, by Enoch.
        FileName:       TestSouder.nc 
        Author:         Enoch
        Version:        1.0.0.0
        Date:           2006 09 01
        Description:    Components for testing the souder.
*********************************************************************/
includes SensorBoardApp;
includes TestSounder;
configuration TestSounder
{
    // this module does not provide any interface
}
implementation
{
    components Main, TestSounderM, TimerC, GenericComm as Comm, LedsC, MicC;
    Main.StdControl -> TestSounderM;
    Main.StdControl -> Comm;
    TestSounderM.TimerSend -> TimerC.Timer[unique("timer")];
    TestSounderM.SendSound -> Comm.SendMsg[AM_SURGEMSG];
    TestSounderM.ReceiveSound -> Comm.ReceiveMsg[AM_SURGEMSG];
    TestSounderM.UARTSend -> Comm.SendMsg[AM_SURGEMSG+2];
    /* Mic Controller */
    TestSounderM.MicControl -> MicC;
    TestSounderM.Mic -> MicC;
    TestSounderM.MicADC ->MicC;
    TestSounderM.Leds -> LedsC;
    TestSounderM.TimerSend -> TimerC.Timer[unique("Timer")];
}
 
/********************************************************************
        Copyright (C), 2006-2007, by Eonch.
        FileName:       TestSouderM.nc 
        Author:         Eonch
        Version:        1.0.0.0
        Date:           2006 09 01
        Description:    Implementation for testing the souder.
*********************************************************************/
includes sensorboard;
includes TestSounder;
module TestSounderM
{
    provides
    {
        interface StdControl;
    }
    uses
    {
        interface SendMsg as SendSound;
         interface ReceiveMsg as ReceiveSound;
        interface SendMsg as UARTSend;
        // Mic
        interface StdControl as MicControl;
        interface Mic;
        interface ADC as MicADC;
        interface Timer as TimerSend;
        interface Leds;
    }
}
implementation
{
    TOS_Msg UARTSendData, MoteSendData;
    uint16_t seq;
    enum { START, BUSY, SOUND_DONE};
    enum { SENSOR_ID = 0, PACKET_ID, NODE_ID=2, RSVD,
       VREF=4, THERM =6, PHOTO = 8, MIC = 10,
       ACCEL_X=12, ACCEL_Y=14, MAG_X=16, MAG_Y=18 };
    
    command result_t StdControl.init()
    {
        seq = 0;
        call Leds.init();
        call MicControl.init();
        call Mic.muxSel(1);  // Set the mux so that raw microhpone output is selected
        call Mic.gainAdjust(64);  // Set the gain of the microphone.
        return SUCCESS;
    }
 
    command result_t StdControl.start()
    {
        call Leds.redOn();
        if (TOS_LOCAL_ADDRESS != BASE_ADDRESS)
         {
             seq = 0;
             call MicControl.start();
             call TimerSend.start(TIMER_REPEAT, INITIAL_TIMER_RATE);
             call Leds.greenOn();
         }
        return SUCCESS;   
    }
   
    command result_t StdControl.stop()
    {
        call TimerSend.stop();
        return SUCCESS;   
    }
    
    event result_t TimerSend.fired()
    {
        if (TOS_LOCAL_ADDRESS != BASE_ADDRESS)
         {
            call MicADC.getData();
         }
        return SUCCESS;   
    }
    /****************************************************************************
     * MicroPhone ADC data ready
     *****************************************************************************/  
    async event result_t MicADC.dataReady(uint16_t data)
    {
        SurgeMsg* msg = (SurgeMsg *)MoteSendData.data;
        // Data
         atomic
         {
             msg->addr = TOS_LOCAL_ADDRESS;
         }
         msg->seq = ++seq;
         msg->sound = data;
         call SendSound.send(BASE_ADDRESS, sizeof(SurgeMsg), &MoteSendData);
         call Leds.yellowToggle();
        return SUCCESS;
    }
    event result_t SendSound.sendDone(TOS_MsgPtr msg, result_t success)
     {
          call Leds.greenToggle();
          return SUCCESS;
     }
    // Motes Reciece Message
     event TOS_MsgPtr ReceiveSound.receive(TOS_MsgPtr msgptr)
     {
         /* Mote 0 for UART */
         if (TOS_LOCAL_ADDRESS == BASE_ADDRESS)
         {
             SurgeMsg* msg = (SurgeMsg *)msgptr->data;
             SurgeMsg* uart_msg = (SurgeMsg *)UARTSendData.data;
             if (((SurgeMsg*)msgptr->data)->addr == BASE_ADDRESS)
             {
                 return msgptr;
             }
            uart_msg->addr  = msg->addr;
            uart_msg->sound = msg->sound;
            uart_msg->seq   = msg->seq;
            /* Upstream the data */    
             call UARTSend.send(TOS_UART_ADDR, sizeof(SurgeMsg), &UARTSendData);
         }
         /* Node ID > 1 process */
         else
         {
         }
         return msgptr;
     }
    // UART Send Message
       event result_t UARTSend.sendDone(TOS_MsgPtr msg, result_t success)
     {
         call Leds.yellowToggle();
          return SUCCESS;
     }
}
 
/********************************************************************
        Copyright (C), 2006-2007, by Eonch.
        FileName:       Makefile  
        Author:         Eonch
        Version:        1.0.0.0
        Date:           2006 09 01
        Description:    Implementation for testing the souder.
*********************************************************************/
# $Id: Makefile, v1.0 2006/09/01 By Enoch Exp $
XBOWROOT=%T/../contrib/xbow/tos
COMPONENT=TestSounder
SENSORBOARD=mts310
# For MICAZ
PFLAGS+= -I../../beta/tos/lib/CC2420Radio -I%T/lib/Broadcast -I%T/lib/Attributes
PFLAGS= -I$(XBOWROOT)/interfaces  -I$(XBOWROOT)/system  -I$(XBOWROOT)/platform/$(PLATFORM) -I$(XBOWROOT)/lib -I$(XBOWROOT)/sensorboards/$(SENSORBOARD)
include ../MakeXbowlocal
include ${TOSROOT}/tools/make/Makerules


Related to Wireless Sensor Networks:
 

阅读全文...