Index: tos/lib/tosthreads/csystem/VolumeMapP.nc =================================================================== RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/tosthreads/csystem/VolumeMapP.nc,v retrieving revision 1.1 diff -u -r1.1 VolumeMapP.nc --- tos/lib/tosthreads/csystem/VolumeMapP.nc 12 Jun 2008 14:02:39 -0000 1.1 +++ tos/lib/tosthreads/csystem/VolumeMapP.nc 9 Feb 2009 23:39:16 -0000 @@ -22,21 +22,28 @@ /** * @author Chieh-Jan Mike Liang + * + * ConfigStorage support: + * @author Jó Ágila Bitsch Link */ module VolumeMapP { - provides { - interface BlockRead[uint8_t volume_id]; + provides { + interface BlockRead[uint8_t volume_id]; interface BlockWrite[uint8_t volume_id]; interface LogRead[uint8_t volume_id]; interface LogWrite[uint8_t volume_id]; + interface ConfigStorage[uint8_t volume_id]; + interface Mount[uint8_t volume_id]; } - - uses { - interface BlockRead as SubBlockRead[uint8_t volume_id]; - interface BlockWrite as SubBlockWrite[uint8_t volume_id]; + + uses { + interface BlockRead as SubBlockRead[uint8_t volume_id]; + interface BlockWrite as SubBlockWrite[uint8_t volume_id]; interface LogRead as SubLogRead[uint8_t volume_id]; interface LogWrite as SubLogWrite[uint8_t volume_id]; + interface ConfigStorage as SubConfigStorage[uint8_t volume_id]; + interface Mount as SubMount[uint8_t volume_id]; } } @@ -60,7 +67,7 @@ command storage_len_t BlockRead.getSize[uint8_t volume_id]() { return call SubBlockRead.getSize[volume_id](); } - + command error_t BlockWrite.write[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) { return call SubBlockWrite.write[volume_id](addr, buf, len); } @@ -84,7 +91,7 @@ event void SubBlockWrite.syncDone[uint8_t volume_id](error_t error) { signal BlockWrite.syncDone[volume_id](error); } - + default command error_t SubBlockRead.read[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; } @@ -96,7 +103,7 @@ default command storage_len_t SubBlockRead.getSize[uint8_t volume_id]() { return FAIL; } - + default command error_t SubBlockWrite.write[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; } @@ -108,13 +115,13 @@ default command error_t SubBlockWrite.sync[uint8_t volume_id]() { return FAIL; } - + default event void BlockRead.readDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {} default event void BlockRead.computeCrcDone[uint8_t volume_id](storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error) {} default event void BlockWrite.writeDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {} default event void BlockWrite.eraseDone[uint8_t volume_id](error_t error) {} default event void BlockWrite.syncDone[uint8_t volume_id](error_t error) {} - + command error_t LogRead.read[uint8_t volume_id](void* buf, storage_len_t len) { return call SubLogRead.read[volume_id](buf, len); } @@ -138,7 +145,7 @@ command storage_len_t LogRead.getSize[uint8_t volume_id]() { return call SubLogRead.getSize[volume_id](); } - + command error_t LogWrite.append[uint8_t volume_id](void* buf, storage_len_t len) { return call SubLogWrite.append[volume_id](buf, len); } @@ -166,7 +173,7 @@ event void SubLogWrite.syncDone[uint8_t volume_id](error_t error) { signal LogWrite.syncDone[volume_id](error); } - + default command error_t SubLogRead.read[uint8_t volume_id](void* buf, storage_len_t len) { return FAIL; } @@ -182,7 +189,7 @@ default command storage_len_t SubLogRead.getSize[uint8_t volume_id]() { return 0; } - + default command error_t SubLogWrite.append[uint8_t volume_id](void* buf, storage_len_t len) { return FAIL; } @@ -198,10 +205,53 @@ default command error_t SubLogWrite.sync[uint8_t volume_id]() { return FAIL; } - + default event void LogRead.readDone[uint8_t volume_id](void* buf, storage_len_t len, error_t error) {} default event void LogRead.seekDone[uint8_t volume_id](error_t error) {} default event void LogWrite.appendDone[uint8_t volume_id](void* buf, storage_len_t len, bool recordsLost, error_t error) {} default event void LogWrite.eraseDone[uint8_t volume_id](error_t error) {} default event void LogWrite.syncDone[uint8_t volume_id](error_t error) {} + + + + command error_t ConfigStorage.read[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) { + return call SubConfigStorage.read[volume_id](addr, buf, len); + } + event void SubConfigStorage.readDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) { + signal ConfigStorage.readDone[volume_id](addr, buf, len, error); + } + default event void ConfigStorage.readDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {} + + command error_t ConfigStorage.write[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) { + return call SubConfigStorage.write[volume_id](addr, buf, len); + } + event void SubConfigStorage.writeDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) { + signal ConfigStorage.writeDone[volume_id](addr, buf, len, error); + } + default event void ConfigStorage.writeDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {} + + command error_t ConfigStorage.commit[uint8_t volume_id]() { + return call SubConfigStorage.commit[volume_id](); + } + event void SubConfigStorage.commitDone[uint8_t volume_id](error_t error) { + signal ConfigStorage.commitDone[volume_id](error); + } + default event void ConfigStorage.commitDone[uint8_t volume_id](error_t error) {} + + command storage_len_t ConfigStorage.getSize[uint8_t volume_id]() { + return call SubConfigStorage.getSize[volume_id](); + } + + command bool ConfigStorage.valid[uint8_t volume_id]() { + return call SubConfigStorage.valid[volume_id](); + } + + command error_t Mount.mount[uint8_t volume_id]() { + return call SubMount.mount[volume_id](); + } + event void SubMount.mountDone[uint8_t volume_id](error_t error) { + signal Mount.mountDone[volume_id](error); + } + default event void Mount.mountDone[uint8_t volume_id](error_t error) {} + } Index: tos/lib/tosthreads/csystem/VolumeMapC.nc =================================================================== RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/tosthreads/csystem/VolumeMapC.nc,v retrieving revision 1.1 diff -u -r1.1 VolumeMapC.nc --- tos/lib/tosthreads/csystem/VolumeMapC.nc 12 Jun 2008 14:02:39 -0000 1.1 +++ tos/lib/tosthreads/csystem/VolumeMapC.nc 9 Feb 2009 23:39:16 -0000 @@ -22,22 +22,29 @@ /** * @author Chieh-Jan Mike Liang + * + * ConfigStorage support: + * @author Jó Ágila Bitsch Link */ -configuration VolumeMapC { - provides { - interface BlockRead[uint8_t volume_id]; +configuration VolumeMapC { + provides { + interface BlockRead[uint8_t volume_id]; interface BlockWrite[uint8_t volume_id]; interface LogRead[uint8_t volume_id]; interface LogWrite[uint8_t volume_id]; + interface ConfigStorage[uint8_t volume_id]; + interface Mount[uint8_t volume_id]; } -} +} -implementation { +implementation { components VolumeMapP; - - BlockRead = VolumeMapP; + + BlockRead = VolumeMapP; BlockWrite = VolumeMapP; LogRead = VolumeMapP; LogWrite = VolumeMapP; -} + ConfigStorage = VolumeMapP; + Mount = VolumeMapP; +} Index: tos/lib/tosthreads/csystem/TosThreadApiC.nc =================================================================== RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/tosthreads/csystem/TosThreadApiC.nc,v retrieving revision 1.4 diff -u -r1.4 TosThreadApiC.nc --- tos/lib/tosthreads/csystem/TosThreadApiC.nc 17 Jun 2008 19:19:10 -0000 1.4 +++ tos/lib/tosthreads/csystem/TosThreadApiC.nc 9 Feb 2009 23:39:16 -0000 @@ -28,11 +28,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * @author Kevin Klues */ - + #include "tosthread.h" configuration TosThreadApiC { @@ -63,14 +63,25 @@ #endif #if defined(TOSTHREAD_BLOCKSTORAGE_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CBlockStorageC; - #endif + #endif + #if defined(TOSTHREAD_CONFIGSTORAGE_H) //|| defined(TOSTHREAD_DYNAMIC_LOADER) + components CConfigStorageC; + #endif #if defined(TOSTHREAD_LOGSTORAGE_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CLogStorageC; - #endif + #endif #if defined(TOSTHREAD_COLLECTION_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CCollectionC; - #endif - + #endif + #if defined(TOSTHREAD_RANDOM_H) //|| defined(TOSTHREAD_DYNAMIC_LOADER) + components CRandomC; + #endif + + // CC2420 specific + #if defined(TOSTHREAD_CC2420PACKET_H) //|| defined(TOSTHREAD_DYNAMIC_LOADER) + components CCC2420PacketC; + #endif + //Telosb sensorboard specific. #if defined(TOSTHREAD_HAMAMATSUS1087_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CHamamatsuS1087ParC; @@ -81,12 +92,15 @@ #if defined(TOSTHREAD_SENSIRIONSHT11_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CSensirionSht11C; #endif - + #if defined(TOSTHREAD_USERBUTTON_H) //|| defined(TOSTHREAD_DYNAMIC_LOADER) + components CUserButtonC; + #endif + //Universal sensorboard specific #if defined(TOSTHREAD_SINESENSOR_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CSineSensorC; #endif - + //Basicsb sensorboard specific #if defined(TOSTHREAD_PHOTO_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CPhotoC; Index: tos-storage-at45db.in =================================================================== RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc/tos-storage-at45db.in,v retrieving revision 1.4 diff -u -r1.4 tos-storage-at45db.in --- tos-storage-at45db.in 23 May 2008 01:04:36 -0000 1.4 +++ tos-storage-at45db.in 14 Feb 2009 19:09:40 -0000 @@ -229,8 +229,8 @@ outFile.write(" interface BlockWrite[uint8_t volume_id]; \n") outFile.write(" interface LogRead[uint8_t volumeId]; \n") outFile.write(" interface LogWrite[uint8_t volumeId]; \n") -# outFile.write(" interface Mount[uint8_t volumeId]; \n") -# outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") + outFile.write(" interface Mount[uint8_t volumeId]; \n") + outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") outFile.write(" } \n") outFile.write("} \n") outFile.write("\n") @@ -241,6 +241,8 @@ outFile.write(" BlockWrite = VolumeMapP; \n") outFile.write(" LogRead = VolumeMapP; \n") outFile.write(" LogWrite = VolumeMapP; \n") + outFile.write(" Mount = VolumeMapP; \n") + outFile.write(" ConfigStorage = VolumeMapP; \n") for i in range(len(volumeNames)): if volumeTypes[volumeNames[i]] == "block": @@ -257,9 +259,9 @@ outFile.write(" VolumeMapP.SubLogWrite[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n") outFile.write("\n") -# elif volumeTypes[volumeNames[i]] == "config": -# outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + elif volumeTypes[volumeNames[i]] == "config": + outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") outFile.write("} \n") Index: tos-storage-pxa27xp30.in =================================================================== RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc/tos-storage-pxa27xp30.in,v retrieving revision 1.5 diff -u -r1.5 tos-storage-pxa27xp30.in --- tos-storage-pxa27xp30.in 23 May 2008 01:04:36 -0000 1.5 +++ tos-storage-pxa27xp30.in 14 Feb 2009 19:09:40 -0000 @@ -200,8 +200,8 @@ outFile.write(" interface BlockWrite[uint8_t volume_id]; \n") outFile.write(" interface LogRead[uint8_t volumeId]; \n") outFile.write(" interface LogWrite[uint8_t volumeId]; \n") -# outFile.write(" interface Mount[uint8_t volumeId]; \n") -# outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") + outFile.write(" interface Mount[uint8_t volumeId]; \n") + outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") outFile.write(" } \n") outFile.write("} \n") outFile.write("\n") @@ -212,6 +212,8 @@ outFile.write(" BlockWrite = VolumeMapP; \n") outFile.write(" LogRead = VolumeMapP; \n") outFile.write(" LogWrite = VolumeMapP; \n") + outFile.write(" Mount = VolumeMapP; \n") + outFile.write(" ConfigStorage = VolumeMapP; \n") for i in range(len(volumeNames)): if volumeTypes[volumeNames[i]] == "block": @@ -228,8 +230,8 @@ outFile.write(" VolumeMapP.SubLogWrite[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n") outFile.write("\n") -# elif volumeTypes[volumeNames[i]] == "config": -# outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + elif volumeTypes[volumeNames[i]] == "config": + outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") outFile.write("} \n") Index: tos-storage-stm25p.in =================================================================== RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc/tos-storage-stm25p.in,v retrieving revision 1.6 diff -u -r1.6 tos-storage-stm25p.in --- tos-storage-stm25p.in 23 May 2008 01:04:36 -0000 1.6 +++ tos-storage-stm25p.in 14 Feb 2009 19:09:40 -0000 @@ -247,8 +247,8 @@ outFile.write(" interface BlockWrite[uint8_t volume_id]; \n") outFile.write(" interface LogRead[uint8_t volumeId]; \n") outFile.write(" interface LogWrite[uint8_t volumeId]; \n") -# outFile.write(" interface Mount[uint8_t volumeId]; \n") -# outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") + outFile.write(" interface Mount[uint8_t volumeId]; \n") + outFile.write(" interface ConfigStorage[uint8_t volumeId]; \n") outFile.write(" } \n") outFile.write("} \n") outFile.write("\n") @@ -259,6 +259,8 @@ outFile.write(" BlockWrite = VolumeMapP; \n") outFile.write(" LogRead = VolumeMapP; \n") outFile.write(" LogWrite = VolumeMapP; \n") + outFile.write(" Mount = VolumeMapP; \n") + outFile.write(" ConfigStorage = VolumeMapP; \n") for i in range(len(volumeNames)): if volumeTypes[volumeNames[i]] == "block": @@ -275,8 +277,8 @@ outFile.write(" VolumeMapP.SubLogWrite[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n") outFile.write("\n") -# elif volumeTypes[volumeNames[i]] == "config": -# outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") -# outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + elif volumeTypes[volumeNames[i]] == "config": + outFile.write(" components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") + outFile.write(" ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n") outFile.write("} \n") Index: tos/lib/tosthreads/sensorboards/tmote_onboard/tmote_onboard_sensors.h =================================================================== RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/tosthreads/sensorboards/tmote_onboard/tmote_onboard_sensors.h,v retrieving revision 1.1 diff -u -r1.1 tmote_onboard_sensors.h --- tos/lib/tosthreads/sensorboards/tmote_onboard/tmote_onboard_sensors.h 12 Jun 2008 14:02:43 -0000 1.1 +++ tos/lib/tosthreads/sensorboards/tmote_onboard/tmote_onboard_sensors.h 9 Feb 2009 23:39:17 -0000 @@ -28,16 +28,17 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * @author Kevin Klues */ - + #ifndef TMOTE_ONBOARD_SENSORS_H #define TMOTE_ONBOARD_SENSORS_H #include "tosthread_sensirionSht11.h" #include "tosthread_hamamatsuS1087.h" #include "tosthread_hamamatsuS10871.h" +#include "tosthread_userbutton.h" #endif //TMOTE_ONBOARD_SENSORS_H Index: tos/lib/tosthreads/csystem/CRandomP.nc =================================================================== RCS file: tos/lib/tosthreads/csystem/CRandomP.nc diff -N tos/lib/tosthreads/csystem/CRandomP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/csystem/CRandomP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,21 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +module CRandomP { + uses { + interface ParameterInit as SeedInit; + interface Random; + } +} +implementation { + error_t randSeed(uint16_t seed) @C() AT_SPONTANEOUS { + return call SeedInit.init(seed); + } + uint16_t rand16() @C() AT_SPONTANEOUS { + return call Random.rand16(); + } + uint32_t rand32() @C() AT_SPONTANEOUS { + return call Random.rand32(); + } +} Index: tos/lib/tosthreads/csystem/CConfigStorageC.nc =================================================================== RCS file: tos/lib/tosthreads/csystem/CConfigStorageC.nc diff -N tos/lib/tosthreads/csystem/CConfigStorageC.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/csystem/CConfigStorageC.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +configuration CConfigStorageC {} + +implementation { + components CConfigStorageP, + BlockingConfigStorageP, + VolumeMapC; + + CConfigStorageP.BlockingConfig -> BlockingConfigStorageP; + + BlockingConfigStorageP.Mount -> VolumeMapC.Mount; + BlockingConfigStorageP.ConfigStorage -> VolumeMapC.ConfigStorage; +} Index: tos/lib/tosthreads/chips/cc2420/CCC2420PacketP.nc =================================================================== RCS file: tos/lib/tosthreads/chips/cc2420/CCC2420PacketP.nc diff -N tos/lib/tosthreads/chips/cc2420/CCC2420PacketP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/chips/cc2420/CCC2420PacketP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,22 @@ +/** + * @author Jó Ágila Bitsch Link + */ +module CCC2420PacketP { + uses { + interface CC2420Packet; + } +} +implementation { + uint8_t cc2420_getPower(message_t* msg) @C() AT_SPONTANEOUS { + return call CC2420Packet.getPower(msg); + } + void cc2420_setPower(message_t* msg, uint8_t power) @C() AT_SPONTANEOUS { + return call CC2420Packet.setPower(msg,power); + } + int8_t cc2420_getRssi(message_t* msg) @C() AT_SPONTANEOUS { + return call CC2420Packet.getRssi(msg); + } + uint8_t cc2420_getLqi(message_t* msg) @C() AT_SPONTANEOUS { + return call CC2420Packet.getLqi(msg); + } +} Index: tos/lib/tosthreads/csystem/CConfigStorageP.nc =================================================================== RCS file: tos/lib/tosthreads/csystem/CConfigStorageP.nc diff -N tos/lib/tosthreads/csystem/CConfigStorageP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/csystem/CConfigStorageP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,29 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +module CConfigStorageP { + uses { + interface BlockingConfig[uint8_t volume_id]; + } +} +implementation { + error_t volumeConfigMount(uint8_t volumeId) @C() AT_SPONTANEOUS { + return call BlockingConfig.mount[volumeId](); + } + error_t volumeConfigRead(uint8_t volumeId, storage_addr_t addr, void *buf, storage_len_t len) @C() AT_SPONTANEOUS { + return call BlockingConfig.read[volumeId](addr, buf, len); + } + error_t volumeConfigWrite(uint8_t volumeId, storage_addr_t addr, void *buf, storage_len_t len) @C() AT_SPONTANEOUS { + return call BlockingConfig.write[volumeId](addr, buf, len); + } + error_t volumeConfigCommit(uint8_t volumeId) @C() AT_SPONTANEOUS { + return call BlockingConfig.commit[volumeId](); + } + storage_len_t volumeConfigGetSize(uint8_t volumeId) @C() AT_SPONTANEOUS { + return call BlockingConfig.getSize[volumeId](); + } + bool volumeConfigValid(uint8_t volumeId) @C() AT_SPONTANEOUS { + return call BlockingConfig.valid[volumeId](); + } +} Index: tos/lib/tosthreads/system/BlockingConfigStorageC.nc =================================================================== RCS file: tos/lib/tosthreads/system/BlockingConfigStorageC.nc diff -N tos/lib/tosthreads/system/BlockingConfigStorageC.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/system/BlockingConfigStorageC.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,25 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#include "Storage.h" +#define UQ_BLOCKING_CONFIG_STORAGE_VOLUME "Blocking.Config.Storage.Volume" + +generic configuration BlockingConfigStorageC(volume_id_t volume_id) { + provides { + interface BlockingConfig; + } +} + +implementation { + enum { + VOLUME_ID = unique(UQ_BLOCKING_CONFIG_STORAGE_VOLUME), + }; + + components new ConfigStorageC(volume_id), + BlockingConfigStorageP; + + BlockingConfig = BlockingConfigStorageP.BlockingConfig[VOLUME_ID]; + BlockingConfigStorageP.ConfigStorage[VOLUME_ID] -> ConfigStorageC; + BlockingConfigStorageP.Mount[VOLUME_ID] -> ConfigStorageC; +} Index: tos/lib/tosthreads/system/BlockingConfigStorageP.nc =================================================================== RCS file: tos/lib/tosthreads/system/BlockingConfigStorageP.nc diff -N tos/lib/tosthreads/system/BlockingConfigStorageP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/system/BlockingConfigStorageP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,29 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +configuration BlockingConfigStorageP { + provides { + interface BlockingConfig[uint8_t id]; + } + uses { + interface Mount[uint8_t id]; + interface ConfigStorage[uint8_t id]; + } +} + +implementation { + components MainC, + BlockingConfigStorageImplP; + + MainC.SoftwareInit -> BlockingConfigStorageImplP; + + BlockingConfig = BlockingConfigStorageImplP; + Mount = BlockingConfigStorageImplP; + ConfigStorage = BlockingConfigStorageImplP; + + components SystemCallC, + SystemCallQueueC; + BlockingConfigStorageImplP.SystemCall -> SystemCallC; + BlockingConfigStorageImplP.SystemCallQueue -> SystemCallQueueC; +} Index: tos/lib/tosthreads/interfaces/BlockingNotify.nc =================================================================== RCS file: tos/lib/tosthreads/interfaces/BlockingNotify.nc diff -N tos/lib/tosthreads/interfaces/BlockingNotify.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/interfaces/BlockingNotify.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#include + +interface BlockingNotify { + command error_t notify(val_t* m, uint32_t timeout); +} Index: apps/tosthreads/capps/TestConfigStorage/volumes-at45db.xml =================================================================== RCS file: apps/tosthreads/capps/TestConfigStorage/volumes-at45db.xml diff -N apps/tosthreads/capps/TestConfigStorage/volumes-at45db.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apps/tosthreads/capps/TestConfigStorage/volumes-at45db.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ + + + Index: tos/lib/tosthreads/chips/cc2420/CCC2420PacketC.nc =================================================================== RCS file: tos/lib/tosthreads/chips/cc2420/CCC2420PacketC.nc diff -N tos/lib/tosthreads/chips/cc2420/CCC2420PacketC.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/chips/cc2420/CCC2420PacketC.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +/** + * @author Jó Ágila Bitsch Link + */ +configuration CCC2420PacketC{} +implementation { + components CCC2420PacketP as P; + components CC2420ActiveMessageC as CC2420Radio; + + P.CC2420Packet -> CC2420Radio; +} Index: tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonC.nc =================================================================== RCS file: tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonC.nc diff -N tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonC.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonC.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +/** + * @author Jó Ágila Bitsch Link + */ +#include "UserButton.h" + +configuration BlockingUserButtonC{ + provides { + interface BlockingNotify; + interface Get; + } +} +implementation { + components BlockingUserButtonP as Button; + + BlockingNotify = Button; + Get = Button; +} Index: tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonImplP.nc =================================================================== RCS file: tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonImplP.nc diff -N tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonImplP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonImplP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,83 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#include "UserButton.h" + + +module BlockingUserButtonImplP { + provides { + interface Init; + interface BlockingNotify; + } + uses { + interface Timer[uint8_t id]; + interface Notify; + interface SystemCall; + interface ThreadScheduler; + } +} +implementation { + + typedef struct params { + uint32_t timeout; + button_state_t *state; + error_t error; + } params_t; + + syscall_t s; + params_t p; + bool busy=FALSE; + + void timerTask(syscall_t* sc) { + call Timer.startOneShot[sc->thread->id](p.timeout); + } + + command error_t Init.init() { + return SUCCESS; + } + + + command error_t BlockingNotify.notify(button_state_t* state, uint32_t timeout) { + atomic { + if(busy == TRUE) + return EBUSY; + busy = TRUE; + } + p.timeout=timeout; + p.state=state; + + call Notify.enable(); + atomic { + p.error = EBUSY; + if(timeout != 0) + call SystemCall.start(&timerTask, &s, 0, &p); + else + call SystemCall.start(SYSCALL_WAIT_ON_EVENT, &s, 0, &p); + } + call Notify.disable(); + + atomic { + busy = FALSE; + return p.error; + } + } + + event void Notify.notify(button_state_t state) { + if( (p.error == EBUSY) ) { + call Timer.stop[s.thread->id](); + *(p.state) = state; + p.error = SUCCESS; + call SystemCall.finish(&s); + } + return; + } + + event void Timer.fired[uint8_t id]() { + thread_t* t = call ThreadScheduler.threadInfo(id); + if( (p.error == EBUSY) ) { + p.error = FAIL; + call SystemCall.finish(t->syscall); + } + } +} Index: apps/tosthreads/capps/TestConfigStorage/volumes-stm25p.xml =================================================================== RCS file: apps/tosthreads/capps/TestConfigStorage/volumes-stm25p.xml diff -N apps/tosthreads/capps/TestConfigStorage/volumes-stm25p.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apps/tosthreads/capps/TestConfigStorage/volumes-stm25p.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ + + + Index: apps/tosthreads/capps/TestConfigStorage/volumes-pxa27xp30.xml =================================================================== RCS file: apps/tosthreads/capps/TestConfigStorage/volumes-pxa27xp30.xml diff -N apps/tosthreads/capps/TestConfigStorage/volumes-pxa27xp30.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apps/tosthreads/capps/TestConfigStorage/volumes-pxa27xp30.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ + + + Index: tos/lib/tosthreads/interfaces/BlockingConfig.nc =================================================================== RCS file: tos/lib/tosthreads/interfaces/BlockingConfig.nc diff -N tos/lib/tosthreads/interfaces/BlockingConfig.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/interfaces/BlockingConfig.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#include "Storage.h" + +interface BlockingConfig { + command error_t mount(); + command error_t read(storage_addr_t addr, void* buf, storage_len_t len); + command error_t write(storage_addr_t addr, void* buf, storage_len_t len); + command error_t commit(); + command storage_len_t getSize(); + command bool valid(); +} + Index: tos/lib/tosthreads/csystem/tosthread_random.h =================================================================== RCS file: tos/lib/tosthreads/csystem/tosthread_random.h diff -N tos/lib/tosthreads/csystem/tosthread_random.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/csystem/tosthread_random.h 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#ifndef TOSTHREAD_RANDOM_H +#define TOSTHREAD_RANDOM_H + +#include "TinyError.h" + +extern error_t randSeed(uint16_t seed); +extern uint16_t rand16(); +extern uint32_t rand32(); + +#endif //TOSTHREAD_RANDOM_H Index: tos/lib/tosthreads/csystem/tosthread_configstorage.h =================================================================== RCS file: tos/lib/tosthreads/csystem/tosthread_configstorage.h diff -N tos/lib/tosthreads/csystem/tosthread_configstorage.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/csystem/tosthread_configstorage.h 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#ifndef TOSTHREAD_CONFIGSTORAGE_H +#define TOSTHREAD_CONFIGSTORAGE_H + +#include "Storage.h" + +extern error_t volumeConfigMount(uint8_t volumeId); +extern error_t volumeConfigRead(uint8_t volumeId, storage_addr_t addr, void *buf, storage_len_t len); +extern error_t volumeConfigWrite(uint8_t volumeId, storage_addr_t addr, void *buf, storage_len_t len); +extern error_t volumeConfigCommit(uint8_t volumeId); +extern storage_len_t volumeConfigGetSize(uint8_t volumeId); +extern bool volumeConfigValid(uint8_t volumeId); + +#endif //TOSTHREAD_CONFIGSTORAGE_H Index: apps/tosthreads/capps/TestConfigStorage/TestConfigStorage.c =================================================================== RCS file: apps/tosthreads/capps/TestConfigStorage/TestConfigStorage.c diff -N apps/tosthreads/capps/TestConfigStorage/TestConfigStorage.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apps/tosthreads/capps/TestConfigStorage/TestConfigStorage.c 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,51 @@ +#include "tosthread.h" +#include "printf.h" +#include "tosthread_leds.h" +#include "tosthread_configstorage.h" +#include "StorageVolumes.h" +#include "TinyError.h" +#include "tosthread_random.h" + + +//Initialize variables associated with each thread +tosthread_t printf_thread; +void thread_run(void* arg); + +void tosthread_main(void* arg) { + tosthread_create(&printf_thread, thread_run, NULL, 200); +} + +nx_uint16_t testval; +nx_uint16_t testval1; + +void thread_run(void* arg) { + uint32_t counter = 0; + error_t ret; + ret=volumeConfigMount(VOLUME_TESTCONFIGSTORAGE); + printf("mount returned %d\n",ret); + printfflush(); + + randSeed(23); + testval1=testval=rand16(); + printf("test value: %d\n",testval); + printfflush(); + + ret=volumeConfigWrite(VOLUME_TESTCONFIGSTORAGE,0,&testval,2); + printf("write returned %d\n",ret); + printfflush(); + ret=volumeConfigCommit(VOLUME_TESTCONFIGSTORAGE); + printf("commit returned %d\n",ret); + printfflush(); + ret=volumeConfigRead(VOLUME_TESTCONFIGSTORAGE,0,&testval,2); + printf("read returned %d\n",ret); + printf("the value was %d\n",testval); + printfflush(); + + + for(;;) { + printf("Counter: %lu\n", counter++); + printfflush(); + setLeds(counter); + tosthread_sleep(200); + } +} Index: apps/tosthreads/capps/TestConfigStorage/README =================================================================== RCS file: apps/tosthreads/capps/TestConfigStorage/README diff -N apps/tosthreads/capps/TestConfigStorage/README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apps/tosthreads/capps/TestConfigStorage/README 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +README for TOSThreads TestConfigStorage +Author: Jó Ágila Bitsch Link +It's based on the TestPrintf application by Kevin Klues + +Description: + +This application tests the operation of the blocking ConfigStorage and +the Printf client in TOSThreads. It first does some config storage test +and then continuously prints the value of a counter starting at 0, +increasing as it prints. + +You can install TestConfigStorage on a mote via the following command: + make cthreads install + +Valid platforms are currently: tmote, telosb, iris, mica2, and micaz + +Once burned on a mote, the java based PrintfClient must be ran to verify +proper operation of the application. + java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSBXXX: + +NOTE: The baud rate 57600 must be used telos based motes, as its configuration +has been changed to work with this baud rate when compiled for tosthreads. I.e. +DO NOT just substitute 'telosb' or 'tmote' for above. Explicitly +set it to 57600. + +Once this java application is running, you should see output of the sort +continuously being streamed to your terminal: + +mount returned 0 +test value: 10152 +write returned 0 +commit returned 0 +read returned 0 +the value was 10152 +Counter: 0 +Counter: 1 +Counter: 2 +... +... + +Tools: + None. + +Known bugs/limitations: + None. Index: apps/tosthreads/capps/TestConfigStorage/Makefile =================================================================== RCS file: apps/tosthreads/capps/TestConfigStorage/Makefile diff -N apps/tosthreads/capps/TestConfigStorage/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apps/tosthreads/capps/TestConfigStorage/Makefile 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +TOSTHREAD_MAIN=TestConfigStorage.c +CFLAGS += -I$(TOSDIR)/lib/tosthreads/lib/printf +CFLAGS += -I$(TOSDIR)/lib/tosthreads/sensorboards/tmote_onboard + +include $(MAKERULES) Index: tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonP.nc =================================================================== RCS file: tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonP.nc diff -N tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,19 @@ +/** + * @author Jó Ágila Bitsch Link + */ +#include "UserButton.h" + +module CUserButtonP { + uses { + interface Get; + interface BlockingNotify; + } +} +implementation { + button_state_t userbutton_get() @C() AT_SPONTANEOUS { + return call Get.get(); + } + error_t userbutton_notify(button_state_t* state, uint32_t timeout) @C() AT_SPONTANEOUS { + return call BlockingNotify.notify(state,timeout); + } +} Index: tos/lib/tosthreads/chips/cc2420/tosthread_cc2420packet.h =================================================================== RCS file: tos/lib/tosthreads/chips/cc2420/tosthread_cc2420packet.h diff -N tos/lib/tosthreads/chips/cc2420/tosthread_cc2420packet.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/chips/cc2420/tosthread_cc2420packet.h 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#ifndef TOSTHREAD_CC2420PACKET_H +#define TOSTHREAD_CC2420PACKET_H + +#include "message.h" + + +extern uint8_t cc2420_getPower(message_t* msg); +extern void cc2420_setPower(message_t* msg, uint8_t power); +extern int8_t cc2420_getRssi(message_t* msg); +extern uint8_t cc2420_getLqi(message_t* msg); + +#endif //TOSTHREAD_CC2420PACKET_H Index: tos/lib/tosthreads/sensorboards/tmote_onboard/tosthread_userbutton.h =================================================================== RCS file: tos/lib/tosthreads/sensorboards/tmote_onboard/tosthread_userbutton.h diff -N tos/lib/tosthreads/sensorboards/tmote_onboard/tosthread_userbutton.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/sensorboards/tmote_onboard/tosthread_userbutton.h 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#ifndef TOSTHREAD_USERBUTTON_H +#define TOSTHREAD_USERBUTTON_H + +#include "UserButton.h" +#include "TinyError.h" + +extern button_state_t userbutton_get(); +extern error_t userbutton_notify(button_state_t* state, uint32_t timeout); + +#endif //TOSTHREAD_USERBUTTON_H Index: tos/lib/tosthreads/csystem/CRandomC.nc =================================================================== RCS file: tos/lib/tosthreads/csystem/CRandomC.nc diff -N tos/lib/tosthreads/csystem/CRandomC.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/csystem/CRandomC.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +configuration CRandomC {} + +implementation { + components CRandomP, + RandomC; + + CRandomP.Random -> RandomC; + CRandomP.SeedInit -> RandomC; +} Index: tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonC.nc =================================================================== RCS file: tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonC.nc diff -N tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonC.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/sensorboards/tmote_onboard/CUserButtonC.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +configuration CUserButtonC {} + +implementation { + components CUserButtonP, + BlockingUserButtonC; + + CUserButtonP.Get -> BlockingUserButtonC; + CUserButtonP.BlockingNotify -> BlockingUserButtonC; +} Index: tos/lib/tosthreads/system/BlockingConfigStorageImplP.nc =================================================================== RCS file: tos/lib/tosthreads/system/BlockingConfigStorageImplP.nc diff -N tos/lib/tosthreads/system/BlockingConfigStorageImplP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/system/BlockingConfigStorageImplP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,217 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +module BlockingConfigStorageImplP { + provides { + interface Init; + interface BlockingConfig[uint8_t volume_id]; + } + + uses { + interface Mount[uint8_t volume_id]; + interface ConfigStorage[uint8_t volume_id]; + interface SystemCall; + interface SystemCallQueue; + } +} + +implementation { + typedef struct mount_params { + error_t error; + } mount_params_t; + + typedef struct read_params { + storage_addr_t addr; + void *buf; + storage_len_t len; + error_t error; + } read_params_t; + + typedef struct write_params { + storage_addr_t addr; + void *buf; + storage_len_t len; + error_t error; + } write_params_t; + + typedef struct commit_params { + error_t error; + } commit_params_t; + + syscall_queue_t vol_queue; + + command error_t Init.init() + { + call SystemCallQueue.init(&vol_queue); + return SUCCESS; + } + + // ===== MOUNT ===== // + void mountTask(syscall_t *s) + { + mount_params_t *p = s->params; + p->error = call Mount.mount[s->id](); + if(p->error != SUCCESS) { + call SystemCall.finish(s); + } + } + + command error_t BlockingConfig.mount[uint8_t volume_id]() + { + syscall_t s; + mount_params_t p; + atomic { + if(call SystemCallQueue.find(&vol_queue, volume_id) != NULL) + return EBUSY; + call SystemCallQueue.enqueue(&vol_queue, &s); + } + + call SystemCall.start(&mountTask, &s, volume_id, &p); + + atomic { + call SystemCallQueue.remove(&vol_queue, &s); + return p.error; + } + } + + event void Mount.mountDone[uint8_t volume_id](error_t error) + { + syscall_t *s = call SystemCallQueue.find(&vol_queue, volume_id); + mount_params_t *p = s->params; + p->error = error; + call SystemCall.finish(s); + } + + + // ===== READ ===== // + void readTask(syscall_t *s) + { + read_params_t *p = s->params; + p->error = call ConfigStorage.read[s->id](p->addr,p->buf, p->len); + if(p->error != SUCCESS) { + call SystemCall.finish(s); + } + } + + command error_t BlockingConfig.read[uint8_t volume_id](storage_addr_t addr, void *buf, storage_len_t len) + { + syscall_t s; + read_params_t p; + atomic { + if(call SystemCallQueue.find(&vol_queue, volume_id) != NULL) + return EBUSY; + call SystemCallQueue.enqueue(&vol_queue, &s); + } + + p.addr = addr; + p.buf = buf; + p.len = len; + call SystemCall.start(&readTask, &s, volume_id, &p); + + atomic { + call SystemCallQueue.remove(&vol_queue, &s); + return p.error; + } + } + + event void ConfigStorage.readDone[uint8_t volume_id](storage_addr_t addr, void *buf, storage_len_t len, error_t error) + { + syscall_t *s = call SystemCallQueue.find(&vol_queue, volume_id); + read_params_t *p = s->params; + if (p->addr == addr&&p->buf == buf) { + p->error = error; + call SystemCall.finish(s); + } + } + + // ===== WRITE ===== // + void writeTask(syscall_t *s) + { + write_params_t *p = s->params; + p->error = call ConfigStorage.write[s->id](p->addr,p->buf, p->len); + if(p->error != SUCCESS) { + call SystemCall.finish(s); + } + } + + command error_t BlockingConfig.write[uint8_t volume_id](storage_addr_t addr, void *buf, storage_len_t len) + { + syscall_t s; + write_params_t p; + atomic { + if(call SystemCallQueue.find(&vol_queue, volume_id) != NULL) + return EBUSY; + call SystemCallQueue.enqueue(&vol_queue, &s); + } + + p.addr = addr; + p.buf = buf; + p.len = len; + call SystemCall.start(&writeTask, &s, volume_id, &p); + + atomic { + call SystemCallQueue.remove(&vol_queue, &s); + return p.error; + } + } + + event void ConfigStorage.writeDone[uint8_t volume_id](storage_addr_t addr, void *buf, storage_len_t len, error_t error) + { + syscall_t *s = call SystemCallQueue.find(&vol_queue, volume_id); + write_params_t *p = s->params; + if (p->addr == addr&&p->buf == buf) { + p->error = error; + call SystemCall.finish(s); + } + } + + // ===== COMMIT ===== // +void commitTask(syscall_t *s) + { + commit_params_t *p = s->params; + p->error = call ConfigStorage.commit[s->id](); + if(p->error != SUCCESS) { + call SystemCall.finish(s); + } + } + + command error_t BlockingConfig.commit[uint8_t volume_id]() + { + syscall_t s; + commit_params_t p; + atomic { + if(call SystemCallQueue.find(&vol_queue, volume_id) != NULL) + return EBUSY; + call SystemCallQueue.enqueue(&vol_queue, &s); + } + + call SystemCall.start(&commitTask, &s, volume_id, &p); + + atomic { + call SystemCallQueue.remove(&vol_queue, &s); + return p.error; + } + } + + event void ConfigStorage.commitDone[uint8_t volume_id](error_t error) + { + syscall_t *s = call SystemCallQueue.find(&vol_queue, volume_id); + commit_params_t *p = s->params; + p->error = error; + call SystemCall.finish(s); + } + + + + // ===== MISC ===== // + command storage_len_t BlockingConfig.getSize[uint8_t volume_id]() { return call ConfigStorage.getSize[volume_id](); } + command bool BlockingConfig.valid[uint8_t volume_id]() { return call ConfigStorage.valid[volume_id](); } + + default command error_t Mount.mount[uint8_t volume_id]() { return FAIL; } + default command error_t ConfigStorage.read[uint8_t volume_id](storage_addr_t addr,void* buf, storage_len_t len) { return FAIL; } + default command error_t ConfigStorage.write[uint8_t volume_id](storage_addr_t addr,void* buf, storage_len_t len) { return FAIL; } + default command error_t ConfigStorage.commit[uint8_t volume_id]() { return FAIL; } + default command storage_len_t ConfigStorage.getSize[uint8_t volume_id]() { return 0; } + default command bool ConfigStorage.valid[uint8_t volume_id]() { return FALSE; } +} Index: tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonP.nc =================================================================== RCS file: tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonP.nc diff -N tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonP.nc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tos/lib/tosthreads/sensorboards/tmote_onboard/BlockingUserButtonP.nc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,33 @@ +/** + * @author Jó Ágila Bitsch Link + */ + +#include "thread.h" +#include "UserButton.h" + + +configuration BlockingUserButtonP { + provides { + interface BlockingNotify; + interface Get; + } +} +implementation { + components MainC; + components UserButtonC; + components BlockingUserButtonImplP; + + MainC.SoftwareInit -> BlockingUserButtonImplP; + BlockingUserButtonImplP.Notify -> UserButtonC; + + BlockingNotify = BlockingUserButtonImplP; + Get = UserButtonC; + + components SystemCallC; + components TinyThreadSchedulerC; + BlockingUserButtonImplP.SystemCall -> SystemCallC; + BlockingUserButtonImplP.ThreadScheduler -> TinyThreadSchedulerC; + + components ThreadTimersC; + BlockingUserButtonImplP.Timer -> ThreadTimersC; +}