模块不通过UART接收数据,TinyOS Progeamming [英] Module does not receive data through UART, TinyOS Progeamming

查看:36
本文介绍了模块不通过UART接收数据,TinyOS Progeamming的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

模块无法通过UART接收数据,求助TinyOS

Module does not receive data through UART, help with TinyOS

Postby Telosb » 2014 年 7 月 15 日星期二 6:47

Postby Telosb » Tue Jul 15, 2014 6:47

亲爱的会员,

我是 tinyos 编程的新手.我正在与 KMoteB 合作:

i am new to the tinyos programming. I am working with the KMoteB from:

http://www.tinyosmall.com/product_p/100-101.htm

我使用 YETI2 插件和 TinyOS 编译器.

I use the YETI2 Plugin and the TinyOS compiler.

问题是,如果我通过 printf 通过串行接口将数据发送到计算机,我就可以按发送的方式接收它.另一方面,PC-to-Mote 通信不起作用.RX LED 亮起,但数据,例如通过 ubuntu 发送的 'u' 不会触发接收事件.

The problem is, that if i send data via printf through the Serial Interface to the computer, i am able to receive it as sended. On the other hand the PC-to-Mote Communication does not work. The RX LED light up, but the data, for example the 'u' send through ubuntu does not trigger the receive event.

    event message_t* UartReceive.receive(message_t* bufPtr, void* payload, uint8_t len)
    {
        call Leds.led2On();
        printf("Receive\n");
        printfflush();
        return bufPtr;
    }

我正在尝试实施此代码:

I am trying to implement this Code:

http://embedntks.com/tinyos-uart-sending-raw-data/

有人知道问题出在哪里吗?

Does anyone know where the problem might be?

推荐答案

如何将数据从 PC 发送到节点?根据您的描述,我假设您只是使用例如 minicom 应用程序发送原始字节.这种方法行不通.TinyOS 将只接收包含头部、有效载荷和页脚的整个数据包.要发送此类,您需要在 PC 端编写 Java 应用程序.查看本教程中的Mote-PC 通信"一章:http://csl.stanford.edu/~pal/pubs/tos-programming-web.pdf.

How do you send a data from a PC to a mote? From your description I assume you just send raw bytes using, for instance, the minicom application. This approach won't work. TinyOS will receive only whole packets containing header, payload and footer. To send such, you need to write a Java application on a PC side. Have a look at the chapter "Mote-PC communication" in this tutorial: http://csl.stanford.edu/~pal/pubs/tos-programming-web.pdf.

另一个问题是您将 Receive 接口与 printf 函数一起使用.上述教程指出从 PC 发送到节点的数据包由节点确认".当然,他们也使用串行通信.这可能会导致这样的问题:TinyOS PrintfClient 必须接收和处理 printf 数据,而您的 java 应用程序必须接收和处理确认.根据我的经验,如果您在应用程序中使用 printf,则无法使用串行通信堆栈,因为 PrintfC 模块拥有并使用它.您可以在接收事件发生时将自定义数据包发送到 PC 并由 Java 应用程序处理它们.

Another issue is that you use Receive interface together with printf function. The aforementioned tutorial states that "packets sent from a PC to a mote are acknowledged by the mote". They're acknowledged, of course, using the serial communication too. This may lead to such problem: the TinyOS PrintfClient has to receive and process printf data whereas your java application has to receive and process acknowledgements. From my experience, if you use printf in your application, you can't use the serial communication stack because the PrintfC module owns and uses it. You can send your custom packets to a PC when a receive event occurs and process them by a Java application.

这篇关于模块不通过UART接收数据,TinyOS Progeamming的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆