我正在使用带有 android 的 JAMOD 从 modbus 读取数据。我有一个奴隶和一个大师班。(奴隶在netbeans中运行)
尝试连接 android apk 并收到标题中的错误消息。你能帮我为什么或如何更正我的应用程序吗?
import net.wimpi.modbus.Modbus;
import net.wimpi.modbus.ModbusCoupler;
import net.wimpi.modbus.net.ModbusTCPListener;
import net.wimpi.modbus.procimg.*;
public class Modbus_slave_server {
public static void main(String[] args) {
ModbusTCPListener listener = null;
SimpleProcessImage spi = new SimpleProcessImage();
int port = Modbus.DEFAULT_PORT;
if (Modbus.debug) {
System.out.println("jModbus Modbus TCP Slave");
}
if (args != null && args.length >= 1) {
port = Integer.parseInt(args[0]);
}
try {
//2. Prepare a process image
spi = new SimpleProcessImage();
spi.addInputRegister(new SimpleInputRegister(635)); //érték beállítás
//3. Set the image on the coupler
ModbusCoupler.getReference().setProcessImage(spi);
ModbusCoupler.getReference().setMaster(false);
ModbusCoupler.getReference().setUnitID(1);
//3. create a listener with 3 threads in pool
if (Modbus.debug) {
System.out.println("Listening...");
}
listener = new ModbusTCPListener(1);
listener.setPort(port);
listener.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}//main
}