简体   繁体   English

使用java从Tiny OS中的串口读取数据

[英]using java to read data from serial port in Tiny OS

I am going through Tiny OS tutorial lesson number 4 "Mote-PC serial communication and SerialForwarder" and I am stuck on the line where it says "Once you have installed TestSerial, you need to run the corresponding Java application that communicates with it over the serial port. This is built when you build the TinyOS application. From in the application directory, type我正在学习 Tiny OS 教程第 4 课“Mote-PC 串行通信和 SerialForwarder”,我被困在它说“一旦你安装了 TestSerial,你需要运行相应的 Java 应用程序,通过串行端口。这是在构建 TinyOS 应用程序时构建的。在应用程序目录中,键入

$ java TestSerial

However when I type this, I face the following error但是当我输入这个时,我面临以下错误

Error: Could not find or load main class TestSerial

I tried several things to fix this issue, but none helped.我尝试了几种方法来解决此问题,但没有任何帮助。

Solutions that I tried:我尝试过的解决方案:

  1. set CLASSPATH to the directory that I am currently in, which is将 CLASSPATH 设置为我当前所在的目录,即

export CLASSPATH=.:/home/wsn/tinyos-main/apps/tests/TestSerial export CLASSPATH=.:/home/wsn/tinyos-main/apps/tests/TestSerial

2)set CLASSPATH to the directory where tinyos.jar is located 2)将CLASSPATH设置为tinyos.jar所在的目录

export CLASSPATH=.:/home/wsn/tinyos-main/support/sdk/java/tinyos.jar export CLASSPATH=.:/home/wsn/tinyos-main/support/sdk/java/tinyos.jar

3)run command using java -cp . TestSerial 3)使用java -cp . TestSerial运行命令java -cp . TestSerial java -cp . TestSerial

however I keep having the same error但是我一直有同样的错误

Is there any other better way to fix it?有没有其他更好的方法来修复它?

I am using Virtual Machine with Fedora OS我在 Fedora OS 中使用虚拟机
I am trying to run the program on mib520 platform and I use iris motes我正在尝试在 mib520 平台上运行该程序,并且我使用的是 iris motes

my java version我的java版本

openjdk version "1.8.0_31" openjdk 版本“1.8.0_31”
OpenJDK Runtime Environment (build 1.8.0_31-b13) OpenJDK 运行时环境(构建 1.8.0_31-b13)
OpenJDK Server VM (build 25.31-b07, mixed mode) OpenJDK Server VM(构建 25.31-b07,混合模式)

You must have skipped the step when you had to run the make command.当您必须运行 make 命令时,您一定跳过了该步骤。

Navigate to the apps/tests/TestSerial folder and type make [platform] (such as make telosb, make iris etc), the makefile that will be run will be the makefile in the TestSerial folder which is defined as follows:导航到 apps/tests/TestSerial 文件夹并键入make [platform] (例如 make telosb、make iris 等),将运行的 makefile 将是 TestSerial 文件夹中的 makefile,其定义如下:

COMPONENT=TestSerialAppC
TOSMAKE_PRE_EXE_DEPS += TestSerial.class
TOSMAKE_CLEAN_EXTRA = *.class TestSerialMsg.java

TestSerial.class: $(wildcard *.java) TestSerialMsg.java
    javac -target 1.4 -source 1.4 *.java

TestSerialMsg.java:
    nescc-mig java $(CFLAGS) -java-classname=TestSerialMsg TestSerial.h test_serial_msg -o $@


TINYOS_ROOT_DIR?=../../..
include $(TINYOS_ROOT_DIR)/Makefile.include

So the makefile compiles TestSerial.java.所以makefile 编译TestSerial.java。 After this you can proceed to installing the application and then running the TestSerial application.在此之后,您可以继续安装应用程序,然后运行 ​​TestSerial 应用程序。

So step by step on a iris mote for example you would因此,例如,在虹膜微粒上一步一步地进行

  1. Navigate to the apps/tests/TestSerial Folder导航到apps/tests/TestSerial文件夹

  2. Make the application by typing make iris通过键入make irismake iris应用程序

  3. Connect your mote and then type motelist .连接您的motelist ,然后输入motelist This command will list all connected motes.此命令将列出所有连接的节点。 The name of your mote should be listed under the "Device" section.您的节点名称应列在“设备”部分下。 Note this for use in the next two steps.请注意这一点,以便在接下来的两个步骤中使用。

  4. Install your application by typing the command make iris install.1 bsl, [DEVICE NAME] .通过键入命令make iris install.1 bsl, [DEVICE NAME]来安装您的应用程序。 This will make and upload your program to your device.这将制作您的程序并将其上传到您的设备。

  5. Run the TestSerial application by running java TestSerial -comm serial@[DEVICE NAME]:iris通过运行java TestSerial -comm serial@[DEVICE NAME]:iris来运行 TestSerial 应用程序

If you use another platform such as telosb then just replace all occurances of iris in the commands above with telosb.如果您使用其他平台,例如 telosb,则只需将上述命令中出现的所有 iris 替换为 telosb。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM