GWT で com ポートを操作する方法。
comm.java comポートに書き込むための関数です
package com.hell.server;
import jssc.SerialPort;
import jssc.SerialPortException;
public class comm {
public String writeHelloString(String portName) {
SerialPort serialPort = new SerialPort("COM5");
try {
serialPort.openPort();
serialPort.setParams(SerialPort.BAUDRATE_9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
serialPort.writeBytes(portName.getBytes());
@SuppressWarnings("unused")
byte[] buffer = serialPort.readBytes(10);
serialPort.closePort();
}
catch (SerialPortException ex) {
// System.out.println(ex);
}
return "dsada";
}
}
サーバーの機能。
public String greetServer(String input) throws IllegalArgumentException {
comm A = new comm();
A.writeHelloString("$KE");
return input;
}
GWT クライアントからサーバーへのインターフェース:
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}
あたりです???????!!!エラーが多くて動かない…
コンソールからのエラー:
Jun 29, 2012 10:21:59 AM com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String com.hell.client.GreetingService.greetServer(java.lang.String) throws java.lang.IllegalArgumentException' threw an unexpected exception: java.lang.NoClassDefFoundError: jssc/SerialPortException
......
Caused by: java.lang.NoClassDefFoundError: jssc/SerialPortException
at com.hell.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
... 34 more
Caused by: java.lang.ClassNotFoundException: jssc.SerialPortException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 41 more