求rxtxcomm在一个web页面循环读取多个串口数据的方法

青蛙20150421 2014-05-15 05:40:22
首先,我用jquery 的ajax方式调用servlet来实现对一个串口的数据实时读写,测试是没问题的。
但是当我在jsp页面用两个ajax分别调用两个不同的servlet(每个servlet都读取不同的com口返回数据)以后,java控制台会很快提示如下错误:
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000001800087dd, pid=6952, tid=7564
#
# JRE version: 6.0_43-b01
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.14-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [rxtxSerial.dll+0x87dd]
#
# An error report file with more information is saved as:
# D:\JAVA\eclipse4\hs_err_pid6952.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
说明:我的每一个servlet在单独测试的时候都可以很好的返回数据,但是两个一起循环的时候就开始出现以上错误了。
我使用的是:eclipse4.2 + jdk1.6+tomcat7+rxtxcomm2.2
我的项目需要在一个web页面上同时显示3个串口的实时数据,请教是哪里出了问题?
兄弟我非常着急,在线等
...全文
670 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qwt0809 2016-04-07
  • 打赏
  • 举报
回复
RXTX是线程不安全的,多线程操作需要加锁
码农不专业 2015-12-24
  • 打赏
  • 举报
回复
楼主问题解决了吗?请问是什么原因导致的,我也遇到这个问题。
青蛙20150421 2014-05-15
  • 打赏
  • 举报
回复
--------------- P R O C E S S --------------- Java Threads: ( => current thread ) 0x00000000083a9800 JavaThread "http-bio-8080-exec-10" daemon [_thread_in_native, id=2108, stack(0x0000000008fe0000,0x00000000090e0000)] 0x00000000083a9000 JavaThread "http-bio-8080-exec-9" daemon [_thread_blocked, id=4512, stack(0x0000000008df0000,0x0000000008ef0000)] 0x00000000083a8000 JavaThread "http-bio-8080-exec-8" daemon [_thread_blocked, id=5388, stack(0x000000000a2f0000,0x000000000a3f0000)] 0x00000000083a7800 JavaThread "http-bio-8080-exec-7" daemon [_thread_blocked, id=7692, stack(0x000000000a1f0000,0x000000000a2f0000)] 0x00000000083a6800 JavaThread "http-bio-8080-exec-6" daemon [_thread_blocked, id=5224, stack(0x000000000a0f0000,0x000000000a1f0000)] 0x00000000083a6000 JavaThread "http-bio-8080-exec-5" daemon [_thread_blocked, id=3964, stack(0x0000000009ef0000,0x0000000009ff0000)] 0x00000000083a5000 JavaThread "http-bio-8080-exec-4" daemon [_thread_blocked, id=5884, stack(0x0000000009df0000,0x0000000009ef0000)] 0x000000000766c800 JavaThread "http-bio-8080-exec-3" daemon [_thread_blocked, id=4032, stack(0x0000000009cf0000,0x0000000009df0000)] 0x00000000076b2000 JavaThread "http-bio-8080-exec-2" daemon [_thread_blocked, id=5872, stack(0x0000000009bf0000,0x0000000009cf0000)] =>0x0000000007e9e000 JavaThread "http-bio-8080-exec-1" daemon [_thread_in_native, id=7564, stack(0x0000000009af0000,0x0000000009bf0000)] 0x0000000007e9d000 JavaThread "ajp-bio-8009-AsyncTimeout" daemon [_thread_blocked, id=6072, stack(0x00000000099f0000,0x0000000009af0000)] 0x00000000079de000 JavaThread "ajp-bio-8009-Acceptor-0" daemon [_thread_in_native, id=7220, stack(0x00000000098f0000,0x00000000099f0000)] 0x00000000079dd800 JavaThread "http-bio-8080-AsyncTimeout" daemon [_thread_blocked, id=5688, stack(0x00000000097f0000,0x00000000098f0000)] 0x0000000007529800 JavaThread "http-bio-8080-Acceptor-0" daemon [_thread_in_native, id=868, stack(0x00000000096f0000,0x00000000097f0000)] 0x00000000081d5800 JavaThread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" daemon [_thread_blocked, id=7124, stack(0x0000000009510000,0x0000000009610000)] 0x00000000079f6800 JavaThread "GC Daemon" daemon [_thread_blocked, id=4452, stack(0x0000000008cf0000,0x0000000008df0000)] 0x0000000006983800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3328, stack(0x0000000006f20000,0x0000000007020000)] 0x000000000697f800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=4520, stack(0x0000000006e20000,0x0000000006f20000)] 0x000000000697d800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=6288, stack(0x0000000006d20000,0x0000000006e20000)] 0x000000000697a000 JavaThread "Attach Listener" daemon [_thread_blocked, id=7956, stack(0x0000000006c20000,0x0000000006d20000)] 0x0000000006975000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=7304, stack(0x0000000006b20000,0x0000000006c20000)] 0x0000000000528800 JavaThread "Finalizer" daemon [_thread_blocked, id=5716, stack(0x0000000006820000,0x0000000006920000)] 0x0000000000526000 JavaThread "Reference Handler" daemon [_thread_blocked, id=7400, stack(0x0000000006720000,0x0000000006820000)] 0x000000000035b800 JavaThread "main" [_thread_in_native, id=7276, stack(0x0000000002440000,0x0000000002540000)] Other Threads: 0x000000000051d800 VMThread [stack: 0x0000000006620000,0x0000000006720000] [id=6156] 0x0000000006997800 WatcherThread [stack: 0x0000000007020000,0x0000000007120000] [id=1924] VM state:not at safepoint (normal execution) VM Mutex/Monitor currently owned by a thread: None Heap PSYoungGen total 70144K, used 30041K [0x00000007d5d60000, 0x00000007df4e0000, 0x0000000800000000) eden space 64768K, 38% used [0x00000007d5d60000,0x00000007d7576768,0x00000007d9ca0000) from space 5376K, 100% used [0x00000007d9ca0000,0x00000007da1e0000,0x00000007da1e0000) to space 12800K, 0% used [0x00000007de860000,0x00000007de860000,0x00000007df4e0000) PSOldGen total 86400K, used 15060K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) object space 86400K, 17% used [0x0000000781800000,0x00000007826b5318,0x0000000786c60000) PSPermGen total 26624K, used 26519K [0x000000077c600000, 0x000000077e000000, 0x0000000781800000) object space 26624K, 99% used [0x000000077c600000,0x000000077dfe5cf8,0x000000077e000000) Code Cache [0x0000000002540000, 0x00000000027b0000, 0x0000000005540000) total_blobs=645 nmethods=333 adapters=265 free_code_cache=48790080 largest_free_block=7168 Dynamic libraries: 0x0000000000400000 - 0x000000000042f000 D:\JAVA\jdk16\bin\javaw.exe 0x0000000077a50000 - 0x0000000077bf9000 C:\Windows\SYSTEM32\ntdll.dll 0x0000000077830000 - 0x000000007794f000 C:\Windows\system32\kernel32.dll 0x000007fefdc00000 - 0x000007fefdc6c000 C:\Windows\system32\KERNELBASE.dll 0x000007fefe4d0000 - 0x000007fefe5ab000 C:\Windows\system32\ADVAPI32.dll 0x000007fefe660000 - 0x000007fefe6ff000 C:\Windows\system32\msvcrt.dll 0x000007fefe410000 - 0x000007fefe42f000 C:\Windows\SYSTEM32\sechost.dll 0x000007feffa20000 - 0x000007feffb4d000 C:\Windows\system32\RPCRT4.dll 0x0000000077950000 - 0x0000000077a4a000 C:\Windows\system32\USER32.dll 0x000007fefe390000 - 0x000007fefe3f7000 C:\Windows\system32\GDI32.dll 0x000007fefe400000 - 0x000007fefe40e000 C:\Windows\system32\LPK.dll 0x000007fefe700000 - 0x000007fefe7c9000 C:\Windows\system32\USP10.dll 0x000007fefebc0000 - 0x000007fefebee000 C:\Windows\system32\IMM32.DLL 0x000007fefe7d0000 - 0x000007fefe8d9000 C:\Windows\system32\MSCTF.dll 0x000000006d8c0000 - 0x000000006e07c000 D:\JAVA\jdk16\jre\bin\server\jvm.dll 0x000007fefc5b0000 - 0x000007fefc5eb000 C:\Windows\system32\WINMM.dll 0x000000006d830000 - 0x000000006d83e000 D:\JAVA\jdk16\jre\bin\verify.dll 0x000000006d450000 - 0x000000006d477000 D:\JAVA\jdk16\jre\bin\java.dll 0x000000006d880000 - 0x000000006d892000 D:\JAVA\jdk16\jre\bin\zip.dll 0x000000006d5f0000 - 0x000000006d5fa000 D:\JAVA\jdk16\jre\bin\management.dll 0x000000006d800000 - 0x000000006d80b000 D:\JAVA\jdk16\jre\bin\sunmscapi.dll 0x000007fefda90000 - 0x000007fefdbfc000 C:\Windows\system32\CRYPT32.dll 0x000007fefda40000 - 0x000007fefda4f000 C:\Windows\system32\MSASN1.dll 0x000000006d6b0000 - 0x000000006d6c7000 D:\JAVA\jdk16\jre\bin\net.dll 0x000007fefe5b0000 - 0x000007fefe5fd000 C:\Windows\system32\WS2_32.dll 0x000007fefe380000 - 0x000007fefe388000 C:\Windows\system32\NSI.dll 0x000007fefd1d0000 - 0x000007fefd225000 C:\Windows\system32\mswsock.dll 0x000007fefd1c0000 - 0x000007fefd1c7000 C:\Windows\System32\wship6.dll 0x000007fefcbd0000 - 0x000007fefcbd7000 C:\Windows\System32\wshtcpip.dll 0x000007fefd230000 - 0x000007fefd247000 C:\Windows\system32\CRYPTSP.dll 0x000007fefcf30000 - 0x000007fefcf77000 C:\Windows\system32\rsaenh.dll 0x000007fefccf0000 - 0x000007fefcd0e000 C:\Windows\system32\USERENV.dll 0x000007fefd9a0000 - 0x000007fefd9af000 C:\Windows\system32\profapi.dll 0x000007fefd8d0000 - 0x000007fefd8df000 C:\Windows\system32\CRYPTBASE.dll 0x000007fefba10000 - 0x000007fefba25000 C:\Windows\system32\NLAapi.dll 0x000007fefa3c0000 - 0x000007fefa3d5000 C:\Windows\system32\napinsp.dll 0x000007fef2a00000 - 0x000007fef2a19000 C:\Windows\system32\pnrpnsp.dll 0x000007fefd050000 - 0x000007fefd0ab000 C:\Windows\system32\DNSAPI.dll 0x000007fefab20000 - 0x000007fefab2b000 C:\Windows\System32\winrnr.dll 0x000007fef70c0000 - 0x000007fef70d0000 C:\Windows\system32\wshbth.dll 0x000007fefb3a0000 - 0x000007fefb3c7000 C:\Windows\system32\IPHLPAPI.DLL 0x000007fefb380000 - 0x000007fefb38b000 C:\Windows\system32\WINNSI.DLL 0x000007fefa370000 - 0x000007fefa378000 C:\Windows\system32\rasadhlp.dll 0x000007fefb230000 - 0x000007fefb283000 C:\Windows\System32\fwpuclnt.dll 0x0000000180000000 - 0x0000000180025000 D:\JAVA\jdk16\jre\bin\rxtxSerial.dll 0x0000000077c10000 - 0x0000000077c17000 C:\Windows\system32\PSAPI.DLL VM Arguments: jvm_args: -Dcatalina.base=D:\JAVA\eclipse4\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 -Dcatalina.home=D:\JAVA\tomcat7 -Dwtp.deploy=D:\JAVA\eclipse4\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps -Djava.endorsed.dirs=D:\JAVA\tomcat7\endorsed -Dfile.encoding=UTF-8 java_command: org.apache.catalina.startup.Bootstrap start Launcher Type: SUN_STANDARD Environment Variables: JAVA_HOME=D:\JAVA\jdk16 CLASSPATH=D:\JAVA\jdk16\bin;.;D:\JAVA\jdk16\lib;D:\JAVA\jdk16\lib\dt.jar;D:\JAVA\jdk16\lib\tools.jar PATH=C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;D:\JAVA\jdk16;.;D:\JAVA\jdk16\bin USERNAME=Administrator OS=Windows_NT PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
青蛙20150421 2014-05-15
  • 打赏
  • 举报
回复
--------------- T H R E A D --------------- Current thread (0x0000000007e9e000): JavaThread "http-bio-8080-exec-1" daemon [_thread_in_native, id=7564, stack(0x0000000009af0000,0x0000000009bf0000)] siginfo: ExceptionCode=0xc0000005, writing address 0x0000000000000100 Registers: RAX=0x0000000000000000, RBX=0x000000000a027de0, RCX=0x0000000000000002, RDX=0x0000000000000000 RSP=0x0000000009bee8e0, RBP=0x0000000009beeb58, RSI=0x000000000729f8d9, RDI=0x0000000009167df0 R8 =0x0000000000000000, R9 =0x0000000000000000, R10=0x0000000000000002, R11=0x0000000000000001 R12=0x0000000009beeb60, R13=0x000000077dfb89b8, R14=0x0000000009beeb60, R15=0x0000000007e9e000 RIP=0x00000001800087dd, EFLAGS=0x0000000000010202 Top of Stack: (sp=0x0000000009bee8e0) 0x0000000009bee8e0: 000000000a027de0 000000000729f8d0 0x0000000009bee8f0: 0000000009beeb58 000007fefe6613d2 0x0000000009bee900: 000000000729f8d0 000000018000aab4 0x0000000009bee910: 0000000007e9e1d0 0000000000000106 0x0000000009bee920: 000000077dfb89b8 0000000009beeb60 0x0000000009bee930: 00000000076fc320 000000000729f8d0 0x0000000009bee940: 0000000009beeb58 000000018000b7fe 0x0000000009bee950: 0000000000000008 000000006d9dd9eb 0x0000000009bee960: 0000000007e9e1d0 000000000729f8d0 0x0000000009bee970: 00000007d7519118 0000000000000000 0x0000000009bee980: 0000701abf459206 000000007fffffdc 0x0000000009bee990: 0000000009beea20 0000000000000042 0x0000000009bee9a0: 0000000007e9e1d0 0000000000000000 0x0000000009bee9b0: 000000000729f8d0 000000018000213d 0x0000000009bee9c0: 0000000007e9e1d0 000000018001c0b0 0x0000000009bee9d0: 0000000000000000 0000000180000000 Instructions: (pc=0x00000001800087dd) 0x00000001800087bd: 00 00 7e 3d 48 8b 87 08 01 00 00 48 89 bb 00 01 0x00000001800087cd: 00 00 48 89 83 08 01 00 00 48 8b 87 08 01 00 00 0x00000001800087dd: 48 89 98 00 01 00 00 48 89 9f 08 01 00 00 48 8b 0x00000001800087ed: c3 48 8b 5c 24 30 48 8b 74 24 38 48 83 c4 20 5f Register to memory mapping: RAX=0x0000000000000000 is an unknown value RBX=0x000000000a027de0 is an unknown value RCX=0x0000000000000002 is an unknown value RDX=0x0000000000000000 is an unknown value RSP=0x0000000009bee8e0 is pointing into the stack for thread: 0x0000000007e9e000 RBP=0x0000000009beeb58 is pointing into the stack for thread: 0x0000000007e9e000 RSI=0x000000000729f8d9 is an unknown value RDI=0x0000000009167df0 is an unknown value R8 =0x0000000000000000 is an unknown value R9 =0x0000000000000000 is an unknown value R10=0x0000000000000002 is an unknown value R11=0x0000000000000001 is an unknown value R12=0x0000000009beeb60 is pointing into the stack for thread: 0x0000000007e9e000 R13=0x000000077dfb89b8 is an oop {constMethod} - klass: {other class} - method: 0x000000077dfb89c0 {method} 'open' '(Ljava/lang/String;)I' in 'gnu/io/RXTXPort' - exceptions: 0x000000077c601ef8 R14=0x0000000009beeb60 is pointing into the stack for thread: 0x0000000007e9e000 R15=0x0000000007e9e000 is a thread Stack: [0x0000000009af0000,0x0000000009bf0000], sp=0x0000000009bee8e0, free space=1018k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [rxtxSerial.dll+0x87dd] Java_gnu_io_RXTXPort_interruptEventLoop+0x130d Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j gnu.io.RXTXPort.open(Ljava/lang/String;)I+0 j gnu.io.RXTXPort.<init>(Ljava/lang/String;)V+125 j gnu.io.RXTXCommDriver.getCommPort(Ljava/lang/String;I)Lgnu/io/CommPort;+78 j gnu.io.CommPortIdentifier.open(Ljava/lang/String;I)Lgnu/io/CommPort;+171 j rision.RisionSerial.initSerial()I+26 j servlets.Testd.doPost(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V+70 j javax.servlet.http.HttpServlet.service(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V+149 j javax.servlet.http.HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V+30 j org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V+446 j org.apache.catalina.core.ApplicationFilterChain.doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V+101 j org.apache.catalina.core.StandardWrapperValve.invoke(Lorg/apache/catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+783 j org.apache.catalina.core.StandardContextValve.invoke(Lorg/apache/catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+166 j org.apache.catalina.authenticator.AuthenticatorBase.invoke(Lorg/apache/catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+449 j org.apache.catalina.core.StandardHostValve.invoke(Lorg/apache/catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+148 j org.apache.catalina.valves.ErrorReportValve.invoke(Lorg/apache/catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+6 j org.apache.catalina.valves.AccessLogValve.invoke(Lorg/apache/catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+6 j org.apache.catalina.core.StandardEngineValve.invoke(Lorg/apache/catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+71 j org.apache.catalina.connector.CoyoteAdapter.service(Lorg/apache/coyote/Request;Lorg/apache/coyote/Response;)V+196 j org.apache.coyote.http11.AbstractHttp11Processor.process(Lorg/apache/tomcat/util/net/SocketWrapper;)Lorg/apache/tomcat/util/net/AbstractEndpoint$Handler$SocketState;+640 j org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Lorg/apache/tomcat/util/net/SocketWrapper;Lorg/apache/tomcat/util/net/SocketStatus;)Lorg/apache/tomcat/util/net/AbstractEndpoint$Handler$SocketState;+214 j org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run()V+130 j java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Ljava/lang/Runnable;)V+66 j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+33 j java.lang.Thread.run()V+11 v ~StubRoutines::call_stub
Defonds 2014-05-15
  • 打赏
  • 举报
回复
D:\JAVA\eclipse4\hs_err_pid6952.log 这里头的相关详细是啥

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧