By any chance, is the first compile error you're seeing something like "parse error before 'result'" ?
BlockStorage uses it's own result type, storage_result_t, to pass results around. This is different than result_t. And its definition is in the file Storage.h. Storage.h is not being included anywhere in the example I sent you. I have it setup a little differently on my system, so I didn't think about this when sending this code to you. But, what you should do is add the line includes Storage; To the top of the WriteToFlashC.nc component. This will include the Storage.h file from /tos/Flash and then the compiler will know what BlockStorage is talking about when it says "storage_result_t" Below are the errors I get when I compile a BlockStorage app without including Storage.h, maybe it's similar to what you're seeing. Johnathan - are you maintaining the /tos/Flash/ code? Is it possible to add a line to the BlockStorage.h file to #include "Storage.h" automatically so developers don't have these errors? I see BlockStorage.h is included by the BlockStorage components and interfaces, and those components always reference types defined in Storage.h, but do not include Storage.h. What do you think? Attached is a version of the BlockStorage.h file with that added line. I tested it on my system to verify the update. -David In file included from FlashViewerM.nc:43: D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:33: parse error be fore `result' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:36: parse error be fore `result' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:39: parse error be fore `result' In file included from FlashViewerM.nc:44: D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:33: parse error b efore `result' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:36: parse error b efore `result' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:39: parse error b efore `result' FlashViewerM.nc:165: conflicting types for `BlockRead.readDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:33: previous decla ration of `BlockRead.readDone' FlashViewerM.nc:176: conflicting types for `BlockRead.verifyDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:36: previous decla ration of `BlockRead.verifyDone' FlashViewerM.nc:180: conflicting types for `BlockRead.computeCrcDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:39: previous decla ration of `BlockRead.computeCrcDone' FlashViewerM.nc:185: conflicting types for `BlockWrite.writeDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:33: previous decl aration of `BlockWrite.writeDone' FlashViewerM.nc:196: conflicting types for `BlockWrite.eraseDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:36: previous decl aration of `BlockWrite.eraseDone' FlashViewerM.nc:205: conflicting types for `BlockWrite.commitDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:39: previous decl aration of `BlockWrite.commitDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/STM25P/BlockStorageM.nc:170 : co nflicting types for `BlockWrite.writeDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:33: previous decl aration of `BlockWrite.writeDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/STM25P/BlockStorageM.nc:171 : co nflicting types for `BlockWrite.eraseDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:36: previous decl aration of `BlockWrite.eraseDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/STM25P/BlockStorageM.nc:172 : co nflicting types for `BlockWrite.commitDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockWrite.nc:39: previous decl aration of `BlockWrite.commitDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/STM25P/BlockStorageM.nc:173 : co nflicting types for `BlockRead.readDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:33: previous decla ration of `BlockRead.readDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/STM25P/BlockStorageM.nc:174 : co nflicting types for `BlockRead.verifyDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:36: previous decla ration of `BlockRead.verifyDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/STM25P/BlockStorageM.nc:175 : co nflicting types for `BlockRead.computeCrcDone' D:/TinyOS/cygwin/opt/tinyos-1.1.14/tos/lib/Flash/BlockRead.nc:39: previous decla ration of `BlockRead.computeCrcDone' make: *** [exe0] Error 1 -----Original Message----- From: L Tony [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 07, 2006 2:34 PM To: [EMAIL PROTECTED] Subject: RE: [Tinyos-help] write/read from flash on telosb mote Hi,David Thanks for your help. Now I have some idea of how to use BlockStorage from your example. It seems that the example still has some compile errors. I add "PFLAGS += -I%T/lib/Flash" in makefile. But the compiling result shows some error in Mount.nc, BlockRead, BlockWrite and in WriteToFlashM.nc, BlockWrite.writeDone(eraseDone,commitDone) not implemented. Can you help me solve these problems? Thank you so much. Best regards, Tony >From: "David Moss" <[EMAIL PROTECTED]> >To: "'L Tony'" <[EMAIL PROTECTED]>,<[email protected]> >Subject: RE: [Tinyos-help] write/read from flash on telosb mote >Date: Mon, 6 Mar 2006 15:54:37 -0700 > >Here's an example I whooped up for you, with comments throughout on the >behavior of BlockStorage. Hopefully everyone will find this useful. > >And I also hope it works without too many corrections, or at least it may >get some concepts across. I haven't tried to compile it. > >Make sure you format the flash using BlockStorage's format application (or >some custom variant of it) first before >you try using BlockStorage. Also, search this mailing list for previous >discussions on BlockStorage. > >-David > > > >/** WriteToFlash.h header file - set some stuff up */ >///////////////////////////////////////////////////// > >enum { > // Keep each interface connected to your module using the same >paramaterized interface number! > BLOCKSTORAGE_WRITETOFLASH = unique("BlockStorage"), >}; > >//////////////////////////////////////////////////eof > > > > > >/** Configuration file */ >///////////////////////////////////////////////////// > >includes WriteToFlash; > >configuration WriteToFlashC { >} > >implementation { > components Main, WriteToFlashM, BlockStorageC; > > Main.StdControl -> WriteToFlashM; > > WriteToFlashM.Mount -> BlockStorageC.Mount[BLOCKSTORAGE_WRITETOFLASH]; > WriteToFlashM.BlockWrite -> >BlockStorageC.BlockWrite[BLOCKSTORAGE_WRITETOFLASH]; > WriteToFlashM.BlockRead -> >BlockStorageC.BlockRead[BLOCKSTORAGE_WRITETOFLASH]; >} > > >//////////////////////////////////////////////////eof > > > > >/** This is the actual module you should be interested in */ >///////////////////////////////////////////////////// > >module WriteToFlashM { > provides { > interface StdControl; > } > uses { > interface Mount; > interface BlockWrite; > interface BlockRead; > } >} > >implementation { > > /** String to write to flash */ > char myString[] = "Hello BlockStorage World!"; > > /** Something to read into as an example */ > char readBuffer[256]; > > > /***************** Prototypes *****************/ > result_t checkStorageResult(storage_result_t result); > > > /***************** StdControl Commands ****************/ > command result_t StdControl.init() { > return SUCCESS; > } > > command result_t StdControl.start() { > // Only mount to a volume after start(). > call Mount.mount(0); // mount to volume 0 set by the standalone format >app run earlier. > return SUCCESS; > } > > command result_t StdControl.stop() { > return SUCCESS; > } > > > /***************** Mount Events ****************/ > event void Mount.mountDone(storage_result_t result, volume_id_t id) { > // Only now you can write and read flash! > // Address 0x0 is the base address of the volume you're mounted to. > // There are no limitations to the addresses you can read or write, even >outside > // of the current volume. > // When issuing a BlockStorage command, always wait for the event > // before trying to issue another command. > // Let's write to flash... > > if(!checkStorageResult(result)) { > // woops, did you format the flash correctly? with volume 0? > // Maybe flip on your red led here and find out. > return; > } > > if(!call BlockWrite.write(0x0, &myString, sizeof(myString)) { > // Boy, you must have really screwed something up > // We mounted ok, so this error would be extremely unlikely > // unless some other component tried to use the BlockStorage >interface. > } > } > > > /***************** BlockWrite Events ****************/ > event void BlockWrite.writeDone(storage_result_t result, block_addr_t >addr, void* buf, block_addr_t len) { > if(checkStorageResult(result)) { > // hooray, we wrote to flash. Let's read it now. > if(!call BlockRead.read(0x0, &readBuffer, sizeof(myString))) { > // unlikely error. > } > } > } > > event void BlockWrite.eraseDone(storage_result_t result) { > // Full sectors are erased on the M25P80 telos flash type. > // That's 64kB to erase at one time! > // Takes about 1 solid second to erase a sector. > // AT45DB flash type only erases the first page of flash > // no matter where you're mounted (I need to verify this) > // The sector you are erasing on the M25P80 flash is the > // volume you're mounted to. > } > > event void BlockWrite.commitDone(storage_result_t result) { > // Stubbed out for the STM25P80 flash type on telos motes, but > // totally in use for the AT45DB041B flash type on the mica2, mica2dot, >micaz, > // etc. motes. For cross platform compatibility, commit your data > // when that data really needs to exist on flash. > } > > /***************** BlockRead Events ****************/ > event void BlockRead.readDone(storage_result_t result, block_addr_t addr, >void* buf, block_addr_t len) { > if(checkStorageResult(result)) { > // Hooray! we read from flash. > // your readBuffer should contain the same value as your myString >array. > // green led's on, you're good to go. > } > } > > event void BlockRead.verifyDone(storage_result_t result) { > // never used it... > } > > event void BlockRead.computeCrcDone(storage_result_t result, uint16_t crc, >block_addr_t addr, block_addr_t len) { > // Reads the given range of flash addresses and computes the 16-bit crc. > } > > > /***************** Functions ****************/ > // this function will convert the storage_result_t results into > // simple SUCCESS or FAILs for fast and careless error checking: > result_t checkStorageResult(storage_result_t result) { > if(result == STORAGE_OK) { > return SUCCESS; > } else { > return FAIL; > } > } >} >//////////////////////////////////////////////////eof > > > > > > >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] On Behalf Of L Tony >Sent: Monday, March 06, 2006 3:20 PM >To: [email protected] >Subject: [Tinyos-help] write/read from flash on telosb mote > > >Hi, > >I use telosb mote. In my project, I use a t-mote to receive a sequence of >packets. For every received packet, the mote writes some value (like RSSI) >to the mote's flash. Then I connect the mote to laptop and read all the >bytes from flash. I searched the archive and found I should use the updated >BlockStorage instead of ByteEEPROM. But I don't know how the BlockStorage >works. Are there any example application using BlockStorage? Thanks. > >Best regards, >Tony > >_________________________________________________________________ >享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com > >_______________________________________________ >Tinyos-help mailing list >[email protected] >https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _________________________________________________________________ 与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
BlockStorage.h
Description: Binary data
_______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
