Java를 사용하여 직렬 포트와 통신하는 프로젝트를 진행 중입니다. 다음 코드를 테스트하려면 장치를 직렬 포트에 연결해야합니까?리눅스 플랫폼 용 직렬 포트 액세스 코드
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
while (ports.hasMoreElements()) {
CommPortIdentifier port = (CommPortIdentifier) ports.nextElement();
String type;
switch (port.getPortType()) {
case CommPortIdentifier.PORT_PARALLEL:
type = "Parallel";
break;
case CommPortIdentifier.PORT_SERIAL:
type = "Serial";
break;
default: /// Shouldn't happen
type = "Unknown";
break;
}
System.out.println(port.getName() + ": " + type);
}
이 코드를 작성하는 데 필요한 모든 해결책. 현재 다음과 같이 나는
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.comm.SunrayInfo.isSessionActive()Z
at com.sun.comm.SunrayInfo.isSessionActive(Native Method)
at com.sun.comm.Portmapping.registerCommPorts(Portmapping.java:155)
at com.sun.comm.Portmapping.refreshPortDatabase(Portmapping.java:100)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:138)
at PortTest.main(PortTest.java:9)
Java Result: 1
. 직렬 포트에 어떤 장치를 연결하지 않고도 (. 오류를 받고 있어요 나는 JRE와 통신을 구성했습니다. 나는 그것을 할 this 블로그를 따랐습니다.
http://www.agaveblue.org/howtos/Comm_How-To.shtml 시스템을 구성하려면이 게시물을 따르고 있습니다. – Joe
나는 시리얼 포트에 대한 연결과 혼동을 느낍니다. 현재 시리얼 포트에 장치가 연결되어 있지 않습니다. 그 때문에 그것 때문입니다. 리눅스에 가상 직렬 포트를 만들 수 있습니까? 나는 fedora OS를 사용하고 있습니다. – Joe
끔찍한 구식이지만 최신 리눅스 버전을 다운로드했다면 적어도 올바른 파일을 가지고있을 것입니다. 오류가 발생하면 java가'.so' (네이티브 라이브러리) 파일을 찾을 수 없다는 것을 의미합니다. 'System.out.println (System.getProperty ("java.library.path"));로''.so' 파일이 그 중 하나에 있어야합니다. –