Telosb 的 Nesc 程序

问题描述

在问我的问题之前,我知道“世界上”仍然只有很少的人会用 nesc 语言编程。我已经搜索了数周,答案是 Telosb 、 Tinyos 和 nesc 编程现在被认为是一种老式技术。无论如何,我现在的问题是:我编写了一个程序来显示来自 Telosb 板载传感器的温度和光值。在我看来,这个程序是正确的,但是,终端输出上只显示温度值。我将附上程序,希望有人可以帮助我找到问题。谢谢你 。再见

configuration TempTestAppC {
}
implementation {
    //General components
    components TempTestC as App;
    components MainC,LedsC;
    components new TimerMilliC();
    App.Boot -> MainC;
    App.Leds -> LedsC;
    App.Timer -> TimerMilliC;
    
    //for writing into serial port 
    components SerialPrintfC;
    //temperature components
    components new SensirionSht11C() as TempSensor;
    App.TempRead -> TempSensor.Temperature;
    //light components
    components new HamamatsuS10871TsrC() as LightSensor;
    App.LightRead -> LightSensor.Light;
    
}



    #iclude <Timer.h>
#iclude <stdio.h>
#iclude <string.h>
module TempTestC {
    
    uses {
    //General Interfaces
    interface Boot;
    interface Timer<Tmilli>;
    interface Leds;
    }
    //Read
    interface Read<uint16_t> as TempRead;
    
}
implementation
    {
    event void Boot.booted() {
    
        call Timer.startPeriodic(1000);
        call Leds.led1On();
    
    }
    event void Timer.fired() {

        if(call TempRead.read() == SUCCESS) {
            call Leds.led2Toggle;
        }
        else {
            call Leds.led0Toggle();
            }
    
    }
    event void TempRead.readDone(error_t result,uint16_t val) {        
        if(result == SUCCESS)
 {  
        //Now you have read sensor value
        printf("the current temperature is: %d",val);
        
        }
        else
         { 
         //there is a problem in reading sensor
         printf("reading error of sensor");
         }
    }
    }


  [1]: https://i.stack.imgur.com/KkGsk.png

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)