Android'de rs485 bağlantısını denedim. Ben mod kütüphane jamod, android4j ...Android Studio Modbus rs485 seri bağlantısı MacosX
kullandı ama hepsi çalışmıyor.
İlk Dene:
Ben kodlarını deneyin ModbusFactory fabrika = new ModbusFactory(); SerialParameters params = yeni SerialParameters(); params.setCommPortId (path_serial); params.setBaudRate (Baud_Rate); params.setDataBits (8); params.setStopBits (1); params.setParity (0); ModbusMaster master = fabrika.createRtuMaster (params); master.setTimeout (1000); master.setRetries (0); long start = System.currentTimeMillis();
String portname = "/dev/ttyS3"; int baud = 57600; //check params // open the serial communications port SerialParameters params = new SerialParameters(); params.setPortName(portname); params.setBaudRate(Baud_Rate); params.setDatabits(8); params.setParity("None"); params.setStopbits(1); params.setEncoding(Modbus.SERIAL_ENCODING_RTU); params.setEcho(false); con = new SerialConnection(params); try { con.open(); } catch (Exception ex) { }
tüm :( Ben hata yapabilir çalışmıyor
SerialConnection con = null; // the connection
ModbusSerialTransaction trans = null; // the transaction
//ReadInputRegistersRequest req = null; // the request
ReadHoldingRegistersRequest req = null;
ReadHoldingRegistersResponse res = null;
//ReadInputRegistersResponse res = null; // the response
String portname = null; // the name of the serial port to be used
int unitid = 0; // the unit identifier we will be talking to
int ref = 0; // the reference, where to start reading from
int count = 0; // the count of IR's to read
int repeat = 1; // a loop for repeating the transaction
try {
portname = path_serial;
//System.setProperty("gnu.io.rxtx.SerialPorts", portname);
unitid = 2;
ref = 0;
count = 4;
} catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
}
// 2. Set master identifier
// ModbusCoupler.createModbusCoupler(null);
ModbusCoupler.getReference().setUnitID(1);
// 3. Setup serial parameters
SerialParameters params = new SerialParameters();
params.setPortName(portname);
params.setBaudRate(Baud_Rate);
params.setDatabits(8);
params.setParity("None");
params.setStopbits(1);
params.setEncoding("rtu");
params.setEcho(false);
// 4. Open the connection
con = new SerialConnection(params);
try {
con.isOpen();
// con.open();
}catch (Exception ex) {
}
con.close();
daha denemek denemek
İkinci Çalışmıyor
try {
master.init();
} catch (ModbusInitException e) {
System.out.println("Modbus Master Init Error: " + e.getMessage());
return;
}
try {
byte [] RIR,RHR,RDI,RCR;
int slaveId=1;
int startOffset=0;
int numberOfRegisters=10;
int numberOfBits=10;
ReadHoldingRegistersRequest reqRHR = new ReadHoldingRegistersRequest(slaveId, startOffset, numberOfRegisters);
ReadHoldingRegistersResponse resRHR = (ReadHoldingRegistersResponse) master.send(reqRHR);
RHR=resRHR.getData();
System.out.println("HoldingRegister :" + RHR);
//System.out.println("Reg. 1001 Value:" + master.getValue(7, RegisterRange.HOLDING_REGISTER, 1000, DataType.FOUR_BYTE_FLOAT_SWAPPED));
// more like the above until all required register values are read.
// ..
} catch (ModbusTransportException e) {
e.printStackTrace();
} finally {
master.destroy();
}
...? RXTX dalvikvm yük kütüphanesi java.lang.UnsatisfiedLinkError: rxtxSerial yüklenemedi: LogCat hata Neden Olduğu findLibrary
Ben ... Eclipse kullanan gerek anlamıyorum boş döndü?
Platform: Android Studio Java: 1.7.0_79-b15
Uygulama Bildirim: İNTERNET ACCESS_WIFI_STATE ACCESS_NETWORK_STATE WRITE_SETTINGS
minSdkVersion'ın = "8" targetSdkVersion = "18 aynı olsun hata tümü:
03-24 07:37:55.635 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources
03-24 07:37:55.645 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.pruneResourceCache
03-24 07:37:55.695 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.695 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.UserHandle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.695 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.695 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.695 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.695 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.app.TaskStackBuilder', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.705 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.app.TaskStackBuilder', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.715 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.725 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.UserHandle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.725 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.UserHandle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.725 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.725 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.725 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.transition.TransitionManager', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.735 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.745 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.UserHandle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.745 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.UserHandle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.755 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.755 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.755 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.UserHandle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:37:55.755 4681-4681/com.example.jealian.modbustest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.jealian.modbustest.MainActivity.access$super
03-24 07:38:28.915 4681-4681/com.example.jealian.modbustest E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.ghgande.j2mod.modbus.net.SerialConnection.open(SerialConnection.java:119)
at com.example.jealian.modbustest.MainActivity.onCreate(MainActivity.java:65)
at android.app.Activity.performCreate(Activity.java:4492)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load rxtxSerial: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
at com.ghgande.j2mod.modbus.net.SerialConnection.open(SerialConnection.java:119)
at com.example.jealian.modbustest.MainActivity.onCreate(MainActivity.java:65)
at android.app.Activity.performCreate(Activity.java:4492)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Bu sorunun kimsenin bilgisi yok mu? – Jealian
Modbus RS485 portunu android yapan hiç kimse oldu mu? Lütfen yardım edin:/ – Jealian
Sanırım sorunun ne olduğunu biliyorum. Sorunu bulduğumda yazacağım .. Kimsenin anlamadığını düşünüyorum :) – Jealian