How to fix an error : 'Could not load library 'toscomm': no toscomm in java.library.path'?
How to fix an error : 'Could not load library 'toscomm': no toscomm in java.library.path'?
我正在熟悉 Tiny OS 环境,目前我在第 4 课 "Mote-PC serial communication and SerialForwarder"
我被困在必须监听串行端口以获取任何传入数据的部分。我正在尝试实现一个简单的示例,我需要使用 TestSerial 脚本来侦听任何传入消息,但是当我 运行
java TestSerial -comm serial@/dev/ttyUSB0:iris
我的输出看起来像这样:
Error loading the TinyOS JNI libraries the conventional way!
Attempting to load library 'toscomm'
Could not load library 'toscomm': no toscomm in java.library.path
----------
java.lang.UnsatisfiedLinkError: no toscomm in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at net.tinyos.util.TOSLibraryLoader.load(TOSLibraryLoader.java:85)
at net.tinyos.comm.TOSCommJNI.<clinit>(TOSCommJNI.java:14)
at net.tinyos.comm.NativeSerial.getTOSCommMap(NativeSerial.java:207)
at net.tinyos.comm.TOSSerial.<init>(TOSSerial.java:277)
at net.tinyos.packet.SerialByteSource.openStreams(SerialByteSource.java:67)
at net.tinyos.packet.StreamByteSource.open(StreamByteSource.java:61)
at net.tinyos.packet.Packetizer.openSource(Packetizer.java:149)
at net.tinyos.packet.AbstractSource.open(AbstractSource.java:78)
at net.tinyos.packet.Packetizer.open(Packetizer.java:142)
at net.tinyos.packet.PhoenixSource.run(PhoenixSource.java:178)
----------
In order to load the library 'toscomm' Java tries to locate the file 'libtoscomm.so' in one of the following paths:
/usr/java/packages/lib/i386:/lib:/usr/lib
The operating system is 'Linux' (i386)
Trying to locate the file 'linux_x86_toscomm.lib' in the classpath
Temporary file created: '/tmp/toscomm3780740783398787473.lib'
Library copied successfully. Let's load it.
Library loaded successfully
serial@/dev/ttyUSB0:57600: resynchronising
Sending packet 0
Sending packet 1
而不是
Sending packet 1
Received packet sequence number 4
Sending packet 2
Received packet sequence number 5
如教程中所述
我担心我在 运行 这个脚本时收到的警告,尤其是这个
Attempting to load library 'toscomm'
Could not load library 'toscomm': no toscomm in java.library.path
根据教程,这个错误可以通过 运行ning
解决
sudo tos-install-jni,
然而,当我输入这个时,我得到了 tos command not found 的错误。
我试图转到 tinyos-2.x/tools/tinyos/java.
目录并输入 sudo make
和 sudo make install
,尽管如此也没有用,也给我以下错误:
make[1]: Entering directory '/home/wsn/tinyos-main/tools'
/bin/sh ./config.status --recheck
running CONFIG_SHELL=/bin/sh /bin/sh ./configure --no-create --no-recursion
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for ranlib... ranlib
checking for a Python3 interpreter with version >= 3.0... python3
checking for python3... /bin/python3
checking for python3 version...
checking for python3 platform... linux
checking for python3 script directory... ${prefix}/lib/python3.4/site-packages
checking for python3 extension module directory... /lib/python/site-packages
checking for a Python interpreter with version >= 2.5... python2
checking for python2... /bin/python2
checking for python2 version... 2.7
checking for python2 platform... linux2
checking for python2 script directory... ${prefix}/lib/python2.7/site-packages
checking for python2 extension module directory... (cached) /lib/python/site-packages
checking for perl... /bin/perl
checking for python2... /bin/python2
checking for python3... /bin/python3
checking for python2.7-config... /bin/python2.7-config
checking for dot... no
configure: I can't find dot. dot is required for documentation.
checking for nescc... /bin/nescc
checking for cygwin... no
checking for JDK location... configure: error: java not found
Makefile:377: recipe for target 'config.status' failed
make[1]: *** [config.status] Error 1
make[1]: Leaving directory '/home/wsn/tinyos-main/tools'
Makefile:374: recipe for target '../../config.status' failed
make: *** [../../config.status] Error 2
当我尝试 运行 BaseStation 脚本的相同命令时,程序给出了相同的警告并且此时被冻结:
serial@/dev/ttyUSB0:57600: resynchronising
所以我什至没有看到任何发送或接收的数据包!
我不确定这里有什么问题,请帮助。
我正在使用带有 Fedora 的虚拟机 OS
我正在尝试 运行 mib520 平台上的程序,我使用 iris motes
我的java版本
openjdk 版本“1.8.0_31”
OpenJDK 运行时环境(build 1.8.0_31-b13)
OpenJDK 服务器 VM(内部版本 25.31-b07,混合模式)
我不认为你的问题出在 toscomm 上,只要库最终成功加载,你就不应该遇到任何问题。每次我使用串口时,我总是遇到同样的异常,就像你看到的那样,但从来没有费心去修复它,因为它并没有真正妨碍串口的操作。
最后,我通过将 libtoscomm
从 {TOS_ROOT}/tools/tinyos/java/serial/
目录复制到 TinyOS 正在寻找库的目录之一来摆脱异常。在你的情况下你会放一个目录 /usr/java/packages/lib/i386
、 /lib
或 /usr/lib
.
之一中的 libtoscomm
文件的副本
您可以尝试这样做,看看是否能为您解决异常问题。
我怀疑可能导致您的问题的是您没有将 TestSerialAppC 加载到您的 mote 上并连接到串行端口。你确定mote连上串口了吗?
我在 mote 上加载了 运行 应用程序并得到了下面的输出,所以问题不在于 TestSerialAppC
serial@/dev/tty.usbserial-FTYRYAHT:115200: resynchronising
Sending packet 0
Received packet sequence number 3
Sending packet 1
Received packet sequence number 4
Sending packet 2
我正在熟悉 Tiny OS 环境,目前我在第 4 课 "Mote-PC serial communication and SerialForwarder" 我被困在必须监听串行端口以获取任何传入数据的部分。我正在尝试实现一个简单的示例,我需要使用 TestSerial 脚本来侦听任何传入消息,但是当我 运行
java TestSerial -comm serial@/dev/ttyUSB0:iris
我的输出看起来像这样:
Error loading the TinyOS JNI libraries the conventional way!
Attempting to load library 'toscomm'
Could not load library 'toscomm': no toscomm in java.library.path
----------
java.lang.UnsatisfiedLinkError: no toscomm in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at net.tinyos.util.TOSLibraryLoader.load(TOSLibraryLoader.java:85)
at net.tinyos.comm.TOSCommJNI.<clinit>(TOSCommJNI.java:14)
at net.tinyos.comm.NativeSerial.getTOSCommMap(NativeSerial.java:207)
at net.tinyos.comm.TOSSerial.<init>(TOSSerial.java:277)
at net.tinyos.packet.SerialByteSource.openStreams(SerialByteSource.java:67)
at net.tinyos.packet.StreamByteSource.open(StreamByteSource.java:61)
at net.tinyos.packet.Packetizer.openSource(Packetizer.java:149)
at net.tinyos.packet.AbstractSource.open(AbstractSource.java:78)
at net.tinyos.packet.Packetizer.open(Packetizer.java:142)
at net.tinyos.packet.PhoenixSource.run(PhoenixSource.java:178)
----------
In order to load the library 'toscomm' Java tries to locate the file 'libtoscomm.so' in one of the following paths:
/usr/java/packages/lib/i386:/lib:/usr/lib
The operating system is 'Linux' (i386)
Trying to locate the file 'linux_x86_toscomm.lib' in the classpath
Temporary file created: '/tmp/toscomm3780740783398787473.lib'
Library copied successfully. Let's load it.
Library loaded successfully
serial@/dev/ttyUSB0:57600: resynchronising
Sending packet 0
Sending packet 1
而不是
Sending packet 1
Received packet sequence number 4
Sending packet 2
Received packet sequence number 5
如教程中所述
我担心我在 运行 这个脚本时收到的警告,尤其是这个
Attempting to load library 'toscomm'
Could not load library 'toscomm': no toscomm in java.library.path
根据教程,这个错误可以通过 运行ning
解决sudo tos-install-jni,
然而,当我输入这个时,我得到了 tos command not found 的错误。
我试图转到 tinyos-2.x/tools/tinyos/java.
目录并输入 sudo make
和 sudo make install
,尽管如此也没有用,也给我以下错误:
make[1]: Entering directory '/home/wsn/tinyos-main/tools'
/bin/sh ./config.status --recheck
running CONFIG_SHELL=/bin/sh /bin/sh ./configure --no-create --no-recursion
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for ranlib... ranlib
checking for a Python3 interpreter with version >= 3.0... python3
checking for python3... /bin/python3
checking for python3 version...
checking for python3 platform... linux
checking for python3 script directory... ${prefix}/lib/python3.4/site-packages
checking for python3 extension module directory... /lib/python/site-packages
checking for a Python interpreter with version >= 2.5... python2
checking for python2... /bin/python2
checking for python2 version... 2.7
checking for python2 platform... linux2
checking for python2 script directory... ${prefix}/lib/python2.7/site-packages
checking for python2 extension module directory... (cached) /lib/python/site-packages
checking for perl... /bin/perl
checking for python2... /bin/python2
checking for python3... /bin/python3
checking for python2.7-config... /bin/python2.7-config
checking for dot... no
configure: I can't find dot. dot is required for documentation.
checking for nescc... /bin/nescc
checking for cygwin... no
checking for JDK location... configure: error: java not found
Makefile:377: recipe for target 'config.status' failed
make[1]: *** [config.status] Error 1
make[1]: Leaving directory '/home/wsn/tinyos-main/tools'
Makefile:374: recipe for target '../../config.status' failed
make: *** [../../config.status] Error 2
当我尝试 运行 BaseStation 脚本的相同命令时,程序给出了相同的警告并且此时被冻结:
serial@/dev/ttyUSB0:57600: resynchronising
所以我什至没有看到任何发送或接收的数据包!
我不确定这里有什么问题,请帮助。
我正在使用带有 Fedora 的虚拟机 OS
我正在尝试 运行 mib520 平台上的程序,我使用 iris motes
我的java版本
openjdk 版本“1.8.0_31” OpenJDK 运行时环境(build 1.8.0_31-b13) OpenJDK 服务器 VM(内部版本 25.31-b07,混合模式)
我不认为你的问题出在 toscomm 上,只要库最终成功加载,你就不应该遇到任何问题。每次我使用串口时,我总是遇到同样的异常,就像你看到的那样,但从来没有费心去修复它,因为它并没有真正妨碍串口的操作。
最后,我通过将 libtoscomm
从 {TOS_ROOT}/tools/tinyos/java/serial/
目录复制到 TinyOS 正在寻找库的目录之一来摆脱异常。在你的情况下你会放一个目录 /usr/java/packages/lib/i386
、 /lib
或 /usr/lib
.
libtoscomm
文件的副本
您可以尝试这样做,看看是否能为您解决异常问题。
我怀疑可能导致您的问题的是您没有将 TestSerialAppC 加载到您的 mote 上并连接到串行端口。你确定mote连上串口了吗?
我在 mote 上加载了 运行 应用程序并得到了下面的输出,所以问题不在于 TestSerialAppC
serial@/dev/tty.usbserial-FTYRYAHT:115200: resynchronising
Sending packet 0
Received packet sequence number 3
Sending packet 1
Received packet sequence number 4
Sending packet 2