Changeset 199
- Timestamp:
- 10/07/09 22:41:53 (4 years ago)
- Location:
- apps/TSCH
- Files:
-
- 13 edited
-
TSCHP.nc (modified) (3 diffs)
-
cellusage/CellUsageP.nc (modified) (4 diffs)
-
debugwsn.py (modified) (1 diff)
-
forwarding/ForwardingP.nc (modified) (2 diffs)
-
idmanager/IDManagerP.nc (modified) (1 diff)
-
keepalive/KeepAliveC.nc (modified) (2 diffs)
-
multiplex/MultiplexC.nc (modified) (1 diff)
-
neighbors/NeighborsP.nc (modified) (8 diffs)
-
reservation/ReservationP.nc (modified) (4 diffs)
-
serialio/SerialIOP.nc (modified) (1 diff)
-
slotengine/SlotEngineP.nc (modified) (5 diffs)
-
testlowertsch/TestLowerTSCHC.nc (modified) (2 diffs)
-
tschqueue/TSCHQueueP.nc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/TSCH/TSCHP.nc
r196 r199 72 72 73 73 task void addReservation() { 74 call ReservationUpdate.addSlot(nextHop.neighbor);74 call ReservationUpdate.addSlot(nextHop.neighbor); 75 75 } 76 76 77 77 task void removeReservation() { 78 call ReservationUpdate.removeSlot(nextHop.neighbor);78 call ReservationUpdate.removeSlot(nextHop.neighbor); 79 79 } 80 80 … … 165 165 } 166 166 167 //Notify 167 //Notify (button pressed) 168 168 event void Notify.notify(button_state_t val) { 169 169 if (val==TRUE) { … … 171 171 post printDebug(); 172 172 } else { 173 call TimerSend.startOneShot(2*((call Random.rand16())%SEND_PERIOD_MS));173 call TimerSend.startOneShot(2*((call Random.rand16())%SEND_PERIOD_MS)); 174 174 } 175 175 } -
apps/TSCH/cellusage/CellUsageP.nc
r192 r199 14 14 } 15 15 implementation { 16 /*-------------------------------- variables -----------------------------------------*/ 17 16 18 cellUsageInformation cellTable[LENGTHCELLFRAME]; 17 19 bool cellStatsBusy; … … 19 21 bool cellStatsACK; 20 22 21 /* **************************** prototypes *******************************/23 /*-------------------------------- prototypes ----------------------------------------*/ 22 24 23 25 task void printTable(); … … 38 40 channelOffset_t getCellChannelOffset(slotOffset_t slotOffset); 39 41 40 /***************************** interfaces *******************************/ 42 /*-------------------------------- helper functions ----------------------------------*/ 43 44 task void cellStatsUpdate() { 45 cellType_t type = getCellType(cellStatsSlotOffset); 46 if (type==CELLTYPE_OFF || type==CELLTYPE_RESERVED){ 47 //not an error, this happens for the first ADv received 48 return; 49 } 50 incrementNumUsed(cellStatsSlotOffset); 51 updateLastUsedTimestamp(cellStatsSlotOffset); 52 if (cellStatsACK==TRUE) { 53 incrementNumACK(cellStatsSlotOffset); 54 } 55 cellStatsBusy = FALSE; 56 } 57 58 task void printTable() { 59 //TBC 60 signal DebugPrint.done(); 61 } 62 63 void setCellType(slotOffset_t slotOffset, cellType_t type) { 64 cellTable[slotOffset].myActivity = (cellTable[slotOffset].myActivity & ~0x70) | (type<<4); 65 initCellStats(slotOffset); 66 } 67 68 void setCellNeighbor(slotOffset_t slotOffset, uint16_t neighborId) { 69 cellTable[slotOffset].neighbor=neighborId; 70 } 71 72 void setCellChannelOffset(slotOffset_t slotOffset, channelOffset_t channelOffset) { 73 cellTable[slotOffset].myActivity = (cellTable[slotOffset].myActivity & ~0x0F) | channelOffset; 74 } 75 76 void incrementNumUsed(slotOffset_t slotOffset) { 77 if (cellTable[slotOffset].numUsed<0xFF) { 78 cellTable[slotOffset].numUsed++; 79 } 80 } 81 82 void incrementNumACK(slotOffset_t slotOffset) { 83 if (cellTable[slotOffset].numUsed<0xFF) { 84 cellTable[slotOffset].numACK++; 85 } 86 } 87 88 void updateLastUsedTimestamp(slotOffset_t slotOffset) { 89 cellTable[slotOffset].lastUsedTimestamp=(call GlobalTime.getLocalTime()); 90 } 91 92 cellType_t getCellType(slotOffset_t slotOffset) { 93 if (call GlobalSync.isSync()==FALSE){ 94 return CELLTYPE_ADV; 95 } 96 return (cellTable[slotOffset].myActivity & 0x70)>>4; 97 } 98 99 uint16_t getCellNeighbor(slotOffset_t slotOffset) { 100 if (call GlobalSync.isSync()==FALSE){ 101 return 0; 102 } 103 return cellTable[slotOffset].neighbor; 104 } 105 106 channelOffset_t getCellChannelOffset(slotOffset_t slotOffset) { 107 if (call GlobalSync.isSync()==FALSE){ 108 return 0; 109 } 110 return (cellTable[slotOffset].myActivity & 0x0F); 111 } 112 113 uint8_t getNumUsed(slotOffset_t slotOffset) { 114 return cellTable[slotOffset].numUsed; 115 } 116 117 uint8_t getNumACK(slotOffset_t slotOffset) { 118 return cellTable[slotOffset].numACK; 119 } 120 121 uint32_t getLastUsedTimestamp(slotOffset_t slotOffset) { 122 return cellTable[slotOffset].lastUsedTimestamp; 123 } 124 125 void initCellStats(slotOffset_t slotOffset) { 126 cellTable[slotOffset].numUsed = 0; 127 cellTable[slotOffset].numACK = 0; 128 cellTable[slotOffset].lastUsedTimestamp = 0; 129 } 130 131 void initCellTable() { 132 slotOffset_t slotCounter; 133 //all slots OFF 134 for (slotCounter=0;slotCounter<LENGTHCELLFRAME;slotCounter++){ 135 setCellNeighbor(slotCounter,0); 136 setCellType(slotCounter,CELLTYPE_OFF); 137 setCellChannelOffset(slotCounter,0); 138 initCellStats(slotCounter); 139 } 140 //set CELLTYPE_ADV slot 141 setCellType(ADVSLOTOFFSET,CELLTYPE_ADV); 142 setCellChannelOffset(ADVSLOTOFFSET,ADVRESCHANNELOFFSET); 143 //set CELLTYPE_RXRES slot 144 slotCounter=ADVSLOTOFFSET; 145 while (slotCounter==ADVSLOTOFFSET) { 146 slotCounter=(call Random.rand16())%LENGTHCELLFRAME; 147 } 148 setCellType(slotCounter,CELLTYPE_RXRES); 149 setCellChannelOffset(slotCounter,ADVRESCHANNELOFFSET); 150 } 151 152 /*-------------------------------- interfaces ----------------------------------------*/ 41 153 42 154 //SoftwareInit … … 263 375 //don't do anything. Should only be implemented by SlotEngineC 264 376 } 265 266 /***************************** helper functions *******************************/267 268 task void cellStatsUpdate() {269 cellType_t type = getCellType(cellStatsSlotOffset);270 if (type==CELLTYPE_OFF || type==CELLTYPE_RESERVED){271 //not an error, this happens for the first ADv received272 return;273 }274 incrementNumUsed(cellStatsSlotOffset);275 updateLastUsedTimestamp(cellStatsSlotOffset);276 if (cellStatsACK==TRUE) {277 incrementNumACK(cellStatsSlotOffset);278 }279 cellStatsBusy = FALSE;280 }281 282 task void printTable() {283 //TBC284 signal DebugPrint.done();285 }286 287 void setCellType(slotOffset_t slotOffset, cellType_t type) {288 cellTable[slotOffset].myActivity = (cellTable[slotOffset].myActivity & ~0x70) | (type<<4);289 initCellStats(slotOffset);290 }291 292 void setCellNeighbor(slotOffset_t slotOffset, uint16_t neighborId) {293 cellTable[slotOffset].neighbor=neighborId;294 }295 296 void setCellChannelOffset(slotOffset_t slotOffset, channelOffset_t channelOffset) {297 cellTable[slotOffset].myActivity = (cellTable[slotOffset].myActivity & ~0x0F) | channelOffset;298 }299 300 void incrementNumUsed(slotOffset_t slotOffset) {301 if (cellTable[slotOffset].numUsed<0xFF) {302 cellTable[slotOffset].numUsed++;303 }304 }305 306 void incrementNumACK(slotOffset_t slotOffset) {307 if (cellTable[slotOffset].numUsed<0xFF) {308 cellTable[slotOffset].numACK++;309 }310 }311 312 void updateLastUsedTimestamp(slotOffset_t slotOffset) {313 cellTable[slotOffset].lastUsedTimestamp=(call GlobalTime.getLocalTime());314 }315 316 cellType_t getCellType(slotOffset_t slotOffset) {317 if (call GlobalSync.isSync()==FALSE){318 return CELLTYPE_ADV;319 }320 return (cellTable[slotOffset].myActivity & 0x70)>>4;321 }322 323 uint16_t getCellNeighbor(slotOffset_t slotOffset) {324 if (call GlobalSync.isSync()==FALSE){325 return 0;326 }327 return cellTable[slotOffset].neighbor;328 }329 330 channelOffset_t getCellChannelOffset(slotOffset_t slotOffset) {331 if (call GlobalSync.isSync()==FALSE){332 return 0;333 }334 return (cellTable[slotOffset].myActivity & 0x0F);335 }336 337 uint8_t getNumUsed(slotOffset_t slotOffset) {338 return cellTable[slotOffset].numUsed;339 }340 341 uint8_t getNumACK(slotOffset_t slotOffset) {342 return cellTable[slotOffset].numACK;343 }344 345 uint32_t getLastUsedTimestamp(slotOffset_t slotOffset) {346 return cellTable[slotOffset].lastUsedTimestamp;347 }348 349 void initCellStats(slotOffset_t slotOffset) {350 cellTable[slotOffset].numUsed = 0;351 cellTable[slotOffset].numACK = 0;352 cellTable[slotOffset].lastUsedTimestamp = 0;353 }354 355 void initCellTable() {356 slotOffset_t slotCounter;357 //all slots OFF358 for (slotCounter=0;slotCounter<LENGTHCELLFRAME;slotCounter++){359 setCellNeighbor(slotCounter,0);360 setCellType(slotCounter,CELLTYPE_OFF);361 setCellChannelOffset(slotCounter,0);362 initCellStats(slotCounter);363 }364 //set CELLTYPE_ADV slot365 setCellType(ADVSLOTOFFSET,CELLTYPE_ADV);366 setCellChannelOffset(ADVSLOTOFFSET,ADVRESCHANNELOFFSET);367 //set CELLTYPE_RXRES slot368 slotCounter=ADVSLOTOFFSET;369 while (slotCounter==ADVSLOTOFFSET) {370 slotCounter=(call Random.rand16())%LENGTHCELLFRAME;371 }372 setCellType(slotCounter,CELLTYPE_RXRES);373 setCellChannelOffset(slotCounter,ADVRESCHANNELOFFSET);374 }375 377 } -
apps/TSCH/debugwsn.py
r192 r199 7 7 8 8 root=Tk() 9 root.title("Wireless Sensor Network Debugg ing Tool")9 root.title("Wireless Sensor Network Debugger") 10 10 11 11 #========================= helper functions ========================== -
apps/TSCH/forwarding/ForwardingP.nc
r192 r199 12 12 } 13 13 implementation { 14 /*-------------------------------- variables -----------------------------------------*/ 15 14 16 message_t* current_msg; 15 17 error_t current_error; 16 18 bool busy; 17 19 20 /*-------------------------------- prototypes ----------------------------------------*/ 21 22 task void signalSendDone(); 23 task void printDebug(); 24 25 /*-------------------------------- helper functions ----------------------------------*/ 18 26 task void signalSendDone(){ 19 27 signal SentFromUpper.sendDone(current_msg,current_error); … … 21 29 } 22 30 23 task void printDebug() {31 task void printDebug() { 24 32 signal DebugPrint.done(); 25 33 } 34 35 /*-------------------------------- interfaces ----------------------------------------*/ 26 36 27 37 //SoftwareInit -
apps/TSCH/idmanager/IDManagerP.nc
r196 r199 6 6 } 7 7 implementation { 8 /*-------------------------------- variables -----------------------------------------*/ 9 8 10 uint16_t myID; 9 11 uint16_t myPANID; 10 12 bool isSink; 13 14 /*-------------------------------- interfaces ----------------------------------------*/ 11 15 12 16 //SoftwareInit -
apps/TSCH/keepalive/KeepAliveC.nc
r192 r199 10 10 } 11 11 implementation { 12 /*-------------------------------- variables -----------------------------------------*/ 13 12 14 message_t pkt; 13 15 bool busy; 16 17 /*-------------------------------- prototypes ----------------------------------------*/ 18 19 task void sendKeepAlive(); 20 21 /*-------------------------------- helper functions ----------------------------------*/ 14 22 15 23 task void sendKeepAlive() { … … 29 37 } 30 38 } 39 40 /*-------------------------------- interfaces ----------------------------------------*/ 31 41 32 42 //SoftwareInit -
apps/TSCH/multiplex/MultiplexC.nc
r192 r199 10 10 } 11 11 implementation { 12 /*-------------------------------- interfaces ----------------------------------------*/ 12 13 13 14 //ReceiveAll -
apps/TSCH/neighbors/NeighborsP.nc
r192 r199 19 19 } 20 20 implementation { 21 /*-------------------------------- variables -----------------------------------------*/ 22 21 23 neighborEntry_t neighbors[MAXNUMNEIGHBORS]; 22 24 25 /*-------------------------------- prototypes ----------------------------------------*/ 26 27 void updateStatsAtTx(uint16_t dest, bool ack, uint32_t timestamp, error_t error); 28 bool isNeighborFunction(uint16_t neighbor); 23 29 task void printTable(); 30 31 /*-------------------------------- helper functions ----------------------------------*/ 24 32 25 33 void updateStatsAtTx(uint16_t dest, bool ack, uint32_t timestamp, error_t error){ … … 50 58 } 51 59 60 task void printTable() { 61 //TBC 62 signal DebugPrint.done(); 63 } 64 65 /*-------------------------------- interfaces ----------------------------------------*/ 66 52 67 //SoftwareInit 53 68 command error_t SoftwareInit.init() { … … 146 161 } 147 162 148 //Receive 163 //ReceiveADV 149 164 event message_t* ReceiveADV.receive(message_t *msg,void *payload,uint8_t len) { 150 165 uint8_t i=0; … … 204 219 return msg; 205 220 } 206 221 207 222 //IndicateRx 208 223 event void IndicateRx.indicate(uint16_t src, uint32_t timestamp, uint16_t rssi){ … … 225 240 } 226 241 242 //SendDATA 227 243 event void SendDATA.sendDone(message_t *msg, error_t error) { 228 244 updateStatsAtTx(((cc2420_header_t*)msg->header)->dest, … … 231 247 error); 232 248 } 249 250 //SendRES 233 251 event void SendRES.sendDone(message_t *msg, error_t error) { 234 252 updateStatsAtTx(((cc2420_header_t*)msg->header)->dest, … … 237 255 error); 238 256 } 257 258 //SendADV 239 259 event void SendADV.sendDone(message_t *msg, error_t error) { 240 260 } 261 262 //SendKA 241 263 event void SendKA.sendDone(message_t *msg, error_t error) { 242 264 updateStatsAtTx(((cc2420_header_t*)msg->header)->dest, … … 254 276 post printTable(); 255 277 } 256 257 task void printTable() {258 //TBC259 signal DebugPrint.done();260 }261 278 } -
apps/TSCH/reservation/ReservationP.nc
r192 r199 16 16 } 17 17 implementation { 18 /*-------------------------------- variables -----------------------------------------*/ 19 18 20 ongoingRes_t ongoingRes[NUMONGOINGRES]; 19 21 22 /*-------------------------------- prototypes ----------------------------------------*/ 23 24 bool registerRES(uint16_t neighbor,uint8_t type,bool randomCell,slotOffset_t slotOffset,channelOffset_t channelOffset,bool localRequester); 20 25 task void processOngoingRes(); 21 26 task void printTable(); 27 28 /*-------------------------------- helper functions ----------------------------------*/ 22 29 23 30 bool registerRES(uint16_t neighbor, uint8_t type, bool randomCell, slotOffset_t slotOffset, … … 205 212 return; 206 213 } 214 215 task void printTable() { 216 //TBC 217 signal DebugPrint.done(); 218 } 219 220 /*-------------------------------- interfaces ----------------------------------------*/ 207 221 208 222 //SoftwareInit … … 289 303 } 290 304 291 //S end305 //SimpleSend 292 306 event void SimpleSend.sendDone(message_t *msg, error_t error) { 293 307 uint8_t i=0; … … 344 358 post printTable(); 345 359 } 346 347 task void printTable() {348 //TBC349 signal DebugPrint.done();350 }351 360 } -
apps/TSCH/serialio/SerialIOP.nc
r196 r199 27 27 bool allowedToUse; 28 28 bool mode; 29 30 /*-------------------------------- prototypes ----------------------------------------*/ 31 32 uint16_t output_buffer_index_write_increment(); 33 uint16_t output_buffer_index_read_increment(); 29 34 30 35 /*------------------- helper functions ---------------------------*/ -
apps/TSCH/slotengine/SlotEngineP.nc
r196 r199 1 1 #include "CC2420.h" 2 2 #include "TSCH.h" 3 4 //slot states 5 enum { 6 //startup 7 S_SETTING_CHAN, 8 S_STARTING, 9 S_STARTED, 10 //synchronizing 11 S_SYNCHRONIZING, 12 //transmitter 13 S_TXDATA, 14 S_WAIT_RXACK, 15 S_RXACK, 16 //receiver 17 S_RXDATA, 18 S_WAIT_TXACK, 19 S_TXACK, 20 //cooldown 21 S_STOPPING, 22 S_SLEEP 23 }; 3 24 4 25 module SlotEngineP @safe() { … … 29 50 30 51 /*------------------------------ variables ----------------------------------*/ 31 //slot states32 enum {33 //startup34 S_SETTING_CHAN,35 S_STARTING,36 S_STARTED,37 //synchronizing38 S_SYNCHRONIZING,39 //transmitter40 S_TXDATA,41 S_WAIT_RXACK,42 S_RXACK,43 //receiver44 S_RXDATA,45 S_WAIT_TXACK,46 S_TXACK,47 //cooldown48 S_STOPPING,49 S_SLEEP50 };51 52 52 53 uint32_t timeReference; … … 66 67 uint8_t lenval; 67 68 68 task void printDebug(){69 signal DebugPrint.done();70 }71 72 69 /*------------------------------ prototypes ----------------------------------------*/ 73 70 74 71 void toggle_Port35_n_times(uint8_t num_times); 72 task void printDebug(); 75 73 task void startSlotTask(); 76 74 task void receiveTask(); … … 84 82 num_times--; 85 83 } 84 } 85 86 task void printDebug() { 87 //TBC 88 signal DebugPrint.done(); 86 89 } 87 90 … … 399 402 } 400 403 } 401 402 404 event void SubControl.stopDone(error_t error) { 403 405 switch (state) { -
apps/TSCH/testlowertsch/TestLowerTSCHC.nc
r197 r199 22 22 } 23 23 implementation { 24 /*-------------------------------- variables -----------------------------------------*/ 25 24 26 message_t data_pkt; 25 27 message_t adv_pkt; 26 28 bool already_sent; 29 30 /*-------------------------------- interfaces ----------------------------------------*/ 27 31 28 32 //Boot … … 221 225 event void DebugPrintSlotEngine.done() { 222 226 } 227 223 228 //DebugPrintGlobalTime 224 229 event void DebugPrintGlobalTime.done() { -
apps/TSCH/tschqueue/TSCHQueueP.nc
r196 r199 16 16 } 17 17 implementation { 18 /*-------------------------------- variables -----------------------------------------*/ 19 18 20 TSCHQueueEntry_t queue[QUEUELENGTH]; 19 21 message_t* current_msg; … … 21 23 bool busy; 22 24 25 /*-------------------------------- prototypes ----------------------------------------*/ 26 27 error_t putInQueue(message_t* msg); 28 task void cancelAll(); 29 task void sendDoneTaskDATA(); 30 task void sendDoneTaskKA(); 31 task void sendDoneTaskRES(); 32 task void sendDoneTaskADV(); 33 void informRequester(); 23 34 task void printTable(); 24 void informRequester(); 35 36 /*-------------------------------- helper functions ----------------------------------*/ 25 37 26 38 error_t putInQueue(message_t* msg) { … … 78 90 } 79 91 80 task void sendDoneTaskDATA() {92 task void sendDoneTaskDATA() { 81 93 signal SendDATA.sendDone(current_msg,current_error); 82 94 busy=FALSE; 83 95 } 84 96 85 task void sendDoneTaskKA() {97 task void sendDoneTaskKA() { 86 98 signal SendKA.sendDone(current_msg,current_error); 87 99 busy=FALSE; … … 97 109 busy=FALSE; 98 110 } 111 112 void informRequester() { 113 switch(((cc2420_header_t*)current_msg->header)->type){ 114 case AM_TSCH_DATA: 115 if(((cc2420_header_t*)current_msg->header)->length==sizeof(cc2420_header_t)+1) {//KA 116 busy = TRUE; 117 post sendDoneTaskKA(); 118 } else {//DATA 119 busy = TRUE; 120 post sendDoneTaskDATA(); 121 } 122 break; 123 case AM_TSCH_RES: 124 busy = TRUE; 125 post sendDoneTaskRES(); 126 break; 127 case AM_TSCH_ADV: 128 busy = TRUE; 129 post sendDoneTaskADV(); 130 break; 131 case AM_TSCH_ACK: 132 default: 133 call SerialIO.printError(COMPONENT_TSCHQUEUE,ERR_MSG_UNKNOWN_TYPE,(uint16_t)((cc2420_header_t*)current_msg->header)->type,0); 134 return; 135 } 136 } 137 138 task void printTable() { 139 //TBC 140 signal DebugPrint.done(); 141 } 142 143 /*-------------------------------- interfaces ----------------------------------------*/ 99 144 100 145 //SoftwareInit … … 263 308 } 264 309 265 void informRequester() {266 switch(((cc2420_header_t*)current_msg->header)->type){267 case AM_TSCH_DATA:268 if(((cc2420_header_t*)current_msg->header)->length==sizeof(cc2420_header_t)+1) {//KA269 busy = TRUE;270 post sendDoneTaskKA();271 } else {//DATA272 busy = TRUE;273 post sendDoneTaskDATA();274 }275 break;276 case AM_TSCH_RES:277 busy = TRUE;278 post sendDoneTaskRES();279 break;280 case AM_TSCH_ADV:281 busy = TRUE;282 post sendDoneTaskADV();283 break;284 case AM_TSCH_ACK:285 default:286 call SerialIO.printError(COMPONENT_TSCHQUEUE,ERR_MSG_UNKNOWN_TYPE,(uint16_t)((cc2420_header_t*)current_msg->header)->type,0);287 return;288 }289 }290 291 310 //DebugPrint 292 311 command void DebugPrint.print() { … … 294 313 } 295 314 296 task void printTable() {297 //TBC298 signal DebugPrint.done();299 }300 301 315 //GlobalTime 302 316 async event void GlobalTime.newSlot(uint32_t newASN) {
Note: See TracChangeset
for help on using the changeset viewer.
