⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storagem.nc

📁 无线传感器网络中的节点定位算法。详见ReadMe文件。在TinyOS上实现的节点定位算法。
💻 NC
字号:
/* * StorageM.nc * David Moore <dcm@csail.mit.edu> * * Module to deal with storing non-volatile data in the on-board EEPROM. * * * Copyright (C) 2004  Massachusetts Institute of Technology * * 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 2 * 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. */module StorageM {    provides {        interface Storage;    }}#define MAGIC_BYTES 0x43524943implementation {    command result_t Storage.ReadDataHeader(uint8_t * version,            uint8_t * buf, uint16_t len)    {        uint32_t magic = 0;        eeprom_read_block(&magic, (void *)0, sizeof(uint32_t));        if (magic != MAGIC_BYTES)            return FALSE;        if (version)            *version = eeprom_read_byte((void *)4);        if (buf && len > 0)            eeprom_read_block(buf, (void *)8, len);        return TRUE;    }    command void Storage.WriteDataHeader(uint8_t version,            uint8_t * buf, uint16_t len)    {        uint32_t magic = MAGIC_BYTES;        uint16_t i;        eeprom_write_byte((void *)0, (magic & 0x000000ff) >> 0);        eeprom_write_byte((void *)1, (magic & 0x0000ff00) >> 8);        eeprom_write_byte((void *)2, (magic & 0x00ff0000) >> 16);        eeprom_write_byte((void *)3, (magic & 0xff000000) >> 24);        eeprom_write_byte((void *)4, version);        eeprom_write_byte((void *)5, 0);        eeprom_write_byte((void *)6, 0);        eeprom_write_byte((void *)7, 0);        if (buf && len > 0) {            for (i=0; i<len; i++)                eeprom_write_byte((void *)(8+i), buf[i]);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -