微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Telosb 的 Nesc 程序

如何解决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 举报,一经查实,本站将立刻删除。