80 likes | 230 Views
專 題 實 作 Location-Aware Routing. 指導老師:石貴平 & 張志勇. 報告者 : 陳建隆. 指導助教:張勝文. 組員 : 詹翔任 陳廷祥. 2005_9_6. 關於這次專題實作. 本組總共完成了五個 applications , 分別為 App0 、 App1 、 App2 、 App3 與 App4 , 它們都是根據 SenseLightToLog 修改而得。 由於並沒有足夠的 MICA2 可以實作,而且也不知道這五個 applications 是否正確,所以,以下將用流程圖來做說明。.
E N D
專 題 實 作Location-Aware Routing 指導老師:石貴平 & 張志勇 報告者: 陳建隆 指導助教:張勝文 組員: 詹翔任陳廷祥 2005_9_6
關於這次專題實作 • 本組總共完成了五個applications,分別為App0、App1、App2、App3與App4,它們都是根據SenseLightToLog修改而得。 • 由於並沒有足夠的MICA2可以實作,而且也不知道這五個applications是否正確,所以,以下將用流程圖來做說明。
java net.tinyos.tools.BcastInject P C Mote 4 Mote 3 Mote 0 Mote 2 Mote 1 start_sensing 16 100 MICA2 Addr=22 MICA2 Addr=23 MICA2 Addr=20 MICA2 Addr=24 MICA2 Addr=21 serial port Programmed withApp4 Programmed withApp3 Programmed withApp0 Programmed withApp2 Programmed withApp1 然後將封包廣播出去 call SendCmdMsg.send( TOS_BCAST_ADDR, sizeof(struct SimpleCmdMsg), msg ); Mote 4 收到封包後開始sensing 資料並存到EEPROM但不會再把封包傳送出去 由於這三個封包是相同的所以當Mote 4收到第一個封包後會把seqno記錄下來 lastSeqno = bmsg->seqno; Mote 0 收到封包後開始sensing 資料並存到EEPROM MICA2 Addr=19 當依序再收到第二、三個封包時會根據 Mote 1,2,3 收到封包後開始sensing 資料並存到EEPROM Programming Board if( bmsg->seqno == lastSeqno ) Programmed withTOSBase 來判斷是否是已處理過的封包 Mote 1,2,3指定Addr將封包送給Mote 4 但此三個封包的來源Addr都會被記錄下來 call SendCmdMsg.send( Mote_4, sizeof(struct SimpleCmdMsg), msg ); moteAddr[ k ] = data->source; k++; 封包從serial port透過RS232送到TOSBase 封包從TOSBase透過radio送給Mote 0
java net.tinyos.tools.BcastInject P C Mote 0 Mote 1 Mote 2 Mote 4 Mote 3 read_log 24 MICA2 Addr=24 MICA2 Addr=22 MICA2 Addr=23 MICA2 Addr=20 MICA2 Addr=21 serial port Mote 0 收到封包後開始處理時 根據 Programmed withApp3 Programmed withApp2 Programmed withApp1 Programmed withApp0 Programmed withApp4 與之前一樣 Mote 4只會收到這三個相同封包的其中一個 然後將封包廣播出去 call SendCmdMsg.send( TOS_BCAST_ADDR, sizeof(struct SimpleCmdMsg), msg ); 由於 24 != 20 MICA2 Addr=19 所以Mote 4會執行read_log 所以不會執行read_log 然後將EEPROM中的16筆資料放進新的封包中準備送出 switch (cmd->action){ …… Programming Board 24 != 20 Programmed withTOSBase case READ_LOG: 而且由於 24 == 24 Mote 1,2,3收到封包後由於 if(cmd->args.rl_args.destaddr == Mote 1,2,3指定Addr將封包送給Mote 4 TOS_LOCAL_ADDRESS ) 24 != 21 所以都不會執行read_log 24 != 22 call LoggerRead.readNext( … ); …… call SendCmdMsg.send( Mote_4, sizeof(struct SimpleCmdMsg), msg ); 24 != 23 } 封包從serial port透過RS232送到TOSBase 封包從TOSBase透過radio送給Mote 0
P C Mote 1 Mote 0 Mote 2 Mote 3 Mote 4 MICA2 Addr=23 MICA2 Addr=20 MICA2 Addr=24 MICA2 Addr=21 MICA2 Addr=22 serial port Mote 0收到封包後 Programmed withApp0 Programmed withApp1 Programmed withApp4 Programmed withApp2 Programmed withApp3 也不做任何處理 call SendLogMsg.send(19, sizeof(struct LogMsg), msg); 最後在Cygwin顯示出從Mote 4的EEPROM所讀到的16筆資料 直接把封包傳給TOSBase 然後顯示三個Leds燈 然後也顯示三個Leds燈 以表示封包是經由Mote 1傳送 在將新的封包送出之前Mote 4會根據 call Leds.yellowOn(); call Leds.redOn(); call Leds.greenOn(); Mote 1,2,3以Addr值愈低者表示離Mote 0愈近 shortAddr = moteAddr[0] ; for(n = 1 ; n < 3; n++){ if( (moteAddr[n] != 0) && (shortAddr >moteAddr[n]) ) shortAddr = moteAddr[n] ; Mote 1收到封包後 MICA2 Addr=19 由於moteAddr[n]的初始值為0 } …… 不做任何處理 故 0 必須排除 來選擇最短路徑 直接將封包傳給Mote 0 Programming Board Programmed withTOSBase call SendLogMsg.send(MOTE_0, sizeof(struct LogMsg), msg); 由於Mote 1離Mote 0較近所以將封包傳給Mote 1 call SendLogMsg.send(shortAddr, sizeof(struct LogMsg), &log_msg); 封包透過RS232直接從TOSBase送到serial port
Download program into mica2 with address MIB510=/dev/ttyS<n> make mica2 install.<mote_addr> <n>: COM(n+1) Mote address may be any value EXCEPT two reserved values TOS_BCAST_ADDR ( 0xffff ):to broadcast to all nodes TOS_UART_ADDR ( 0x007e ):to send to the serial port Back
seqno 每執行”net.tinyos.tools.BcastInject”一次即累加一次 seqno 可到”tools/java/bcast.properties”重新設定此值 Back