1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
      TinyOS無(wú)線傳感器網(wǎng)絡(luò)串口通信和無(wú)線通信是怎樣的

      今天就跟大家聊聊有關(guān)  TinyOS無(wú)線傳感器網(wǎng)絡(luò)串口通信和無(wú)線通信是怎樣的,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

      創(chuàng)新互聯(lián)公司自2013年創(chuàng)立以來(lái),先為施甸等服務(wù)建站,施甸等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為施甸企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

      我作為TinyOS入門新手,在學(xué)習(xí)串口通信和無(wú)線通信時(shí)遇到不少問題。下面主要是給出一個(gè)自己寫的示例程序。無(wú)線傳感器節(jié)點(diǎn)收到其他節(jié)點(diǎn)的數(shù)據(jù)通過串口發(fā)送給PC,PC通過串口發(fā)送指令到節(jié)點(diǎn),節(jié)點(diǎn)再通過無(wú)線廣播PC發(fā)送的指令。

      項(xiàng)目包含3個(gè)文件:Makefile、SerialC.nc、SerialAppC.nc。

      Makefile

      COMPONENT=SerialAppC
      include $(MAKERULES)

      SerialAppC.nc

      configuration SerialAppC
      {
      }
      
      implementation
      {
       	components MainC, SerialC, LedsC, ActiveMessageC;
      	components  PlatformSerialC;
      	components SerialC as App;
      	components new TimerMilliC() as Timer0;
      	components new AMSenderC(6);
        	components new AMReceiverC(6);
      	
       	App -> MainC.Boot;
       	App.Leds -> LedsC;
      	App.Timer0->Timer0;
      
      	App.StdControl->PlatformSerialC.StdControl;
      	App.UartStream->PlatformSerialC.UartStream;
      	
      	App.RadioSend -> AMSenderC;
      	 App.RadioPacket -> AMSenderC;
        	App.RadioAMPacket -> AMSenderC;
        	App.RadioControl -> ActiveMessageC;
        	App.RadioReceive -> AMReceiverC;
      }

      SerialC.nc

      module SerialC 
      {
       	uses interface Leds;
       	uses interface Boot;
       	uses interface Timer as  Timer0;
      	
      	uses interface Packet as RadioPacket;
       	uses interface AMPacket as RadioAMPacket;
       	uses interface AMSend as RadioSend;
        	uses interface Receive as RadioReceive;
        	uses interface SplitControl as RadioControl;
      	uses interface StdControl;
      	uses interface UartStream;
      }
      implementation
      {
      	uint32_t  count=0;
      	uint8_t buff[2];
      	bool radiobusy=FALSE;
      	bool serialbusy=FALSE;
      	message_t pkt;
      	typedef nx_struct RadioMsg
      	{
      		nx_uint16_t nodeid;
      		nx_uint16_t count;
      	}RadioMsg;
      	void setLeds(uint16_t val)
      	{
          		if (val & 0x01)
            			call Leds.led0On();
          		else 
            			call Leds.led0Off();
          		if (val & 0x02)
           			 call Leds.led1On();
          		else
            			call Leds.led1Off();
          		if (val & 0x04)
            			call Leds.led2On();
          		else
            			call Leds.led2Off();
        	}
        	event void Boot.booted()
        	{
        		call RadioControl.start();
      		call StdControl.start();
        	}
          	event void Timer0.fired(){}
          	
      	async event void UartStream.sendDone(uint8_t *buf,uint16_t len,error_t error)
      	{
      		serialbusy=FALSE;
      	}
      	async event void UartStream.receivedByte(uint8_t byte)
      	{
      		call Leds.led2Toggle();
      		setLeds(byte);
      		if(!radiobusy)
      		{
      			RadioMsg* btrpkt=(RadioMsg*)(call RadioPacket.getPayload(&pkt,sizeof(RadioMsg)));
      			btrpkt->nodeid=TOS_NODE_ID;
      			btrpkt->count=byte;
      			if(call RadioSend.send(AM_BROADCAST_ADDR,&pkt,sizeof(RadioMsg))==SUCCESS)
      				radiobusy=TRUE;
      		}
      	}
      	async event void UartStream.receiveDone(uint8_t *buf,uint16_t len,error_t error)
      	{
      		
      	}
      	event void RadioControl.startDone(error_t err)
      	{
      
      	}
      	event void RadioControl.stopDone(error_t err)
      	{
      	
      	}
      	event void RadioSend.sendDone(message_t* msg,error_t error)
      	{
      		if(&pkt==msg)
      			radiobusy=FALSE;
      	}
      	event message_t*  RadioReceive.receive(message_t* msg,void *payload,uint8_t len)
      	{
      		call Leds.led1Toggle();
      		if(len==sizeof(RadioMsg))
      		{
      			RadioMsg* btrpkt =(RadioMsg*)payload;
      			buff[0]=btrpkt->nodeid;
      			buff[1]=btrpkt->count;
      			
      		}
      		if(!serialbusy)
      		{
      			serialbusy=TRUE;
      			call UartStream.send(buff, sizeof(buff) );		
      		}
      		return msg;
      	}
      }

      看完上述內(nèi)容,你們對(duì)  TinyOS無(wú)線傳感器網(wǎng)絡(luò)串口通信和無(wú)線通信是怎樣的有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。


      本文名稱:TinyOS無(wú)線傳感器網(wǎng)絡(luò)串口通信和無(wú)線通信是怎樣的
      本文來(lái)源:http://www.ef60e0e.cn/article/gigogh.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        穆棱市| 昌黎县| 蓝田县| 宜州市| 遂川县| 恩平市| 读书| 鄂托克前旗| 彩票| 香港| 东源县| 南乐县| 日喀则市| 育儿| 本溪| 南丹县| 洛隆县| 英德市| 湟中县| 锡林浩特市| 五台县| 泉州市| 谷城县| 琼海市| 淮阳县| 长沙市| 辽中县| 长兴县| 体育| 宁远县| 茶陵县| 小金县| 阿拉尔市| 淮滨县| 周口市| 元氏县| 安福县| 金昌市| 通州市| 嘉峪关市| 清原|