| 
          【庆祝】我终于成功烧写了第一个TinyOS程序! | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
            
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
            
              临时开启串口/dev/ttyUSB0的权限,重启虚拟机后失效:sudo chown oct1158 /dev/ttyUSB0 编译命令:make telosb 烧写命令:tos-bsl --telosb -c /dev/ttyUSB0 -r -e -I -p build/telosb/main.ihex.out 烧写前,一定要把串口插入到虚拟机里面:  勾选FTDI FT232R USB UART [0600]              
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
             
              程序文件列表: 【BlinkAppC.nc】 configuration BlinkAppC { } implementation {     components MainC, BlinkC, LedsC;     components new TimerMilliC() as Timer0;     components new TimerMilliC() as Timer1;     components new TimerMilliC() as Timer2;
      BlinkC -> MainC.Boot;     BlinkC.Timer0 -> Timer0;     BlinkC.Timer1 -> Timer1;     BlinkC.Timer2 -> Timer2;     BlinkC.Leds -> LedsC; } 【BlinkC.nc】 module BlinkC @safe() {     uses interface Timer<TMilli> as Timer0;     uses interface Timer<TMilli> as Timer1;     uses interface Timer<TMilli> as Timer2;     uses interface Leds;     uses interface Boot; } implementation {     event void Boot.booted()     {         call Timer0.startPeriodic(250);         call Timer1.startPeriodic(500);         call Timer2.startPeriodic(1000);     }
      event void Timer0.fired()     {         dbg("BlinkC", "Timer 0 fired @ %s.\n", sim_time_string());         call Leds.led0Toggle();     }
      event void Timer1.fired()     {         dbg("BlinkC", "Timer 1 fired @ %s.\n", sim_time_string());         call Leds.led1Toggle();     }
      event void Timer2.fired()     {         dbg("BlinkC", "Timer 2 fired @ %s.\n", sim_time_string());         call Leds.led2Toggle();     } } 【Makefile】 COMPONENT = BlinkAppC include $(MAKERULES)              
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
            
              所用虚拟机软件:  以及Linux系统:               
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
             
              【总的步骤】 1.给串口添加临时权限(重启系统或拔出USB线后失效) sudo chown oct1158 /dev/ttyUSB0 其中oct1158为用户名 2.编译和烧写 make telosb install bsl,/dev/ttyUSB0 (切记逗号那里绝不能有任何空格,否则生成的tos-bsl命令的-c后面会因缺少/dev/ttyUSB0而出错!)             
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
            
                            临时开启串口/dev/ttyUSB0的权限,重启虚拟机后失效:sudo chown oct1158 /dev/ttyUSB0 编译命令:make telosb 烧写命令:tos-bsl -...  
			  其中main.ihex.out是main.ihex的复制品。              
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
            
                其实这两个文件是完全相同的。              
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
            
                            临时开启串口/dev/ttyUSB0的权限,重启虚拟机后失效:sudo chown oct1158 /dev/ttyUSB0 编译命令:make telosb 烧写命令:tos-bsl -...  
			  输入命令时,请注意-I是大写的i,不是小写的L!              
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
             
              如果电脑只接了一个节点的话,那么只需要输入make telosb install就行了              
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
            
              如果想要每次开机或插入串口线时都自动设置权限为当前用户,不再执行繁琐的chmod或chown命令,请参考: https://zh.arslanbar.net/post.php?t=24301             
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
             
              【常用命令】 查看设备名:motelist 烧写但不编译:make telosb reinstall 编译并烧写:make telosb install 编译并烧写,指定节点ID为2,程序中可通过TOS_NODE_ID宏获得:make telosb install,2 编译并烧写,指定节点路径:make telosb install bsl,/dev/ttyUSB0              
                       | 
        
                
          
            
                         一派护法 十九级              | 
          
            
            
             
              只编译不烧写:make telosb              
                       |