@@ -18,6 +18,7 @@ | |||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||||
<uses-permission android:name="android.permission.USB_PERMISSION" /> | |||||
<application | <application | ||||
android:name=".MainApplication" | android:name=".MainApplication" | ||||
@@ -186,6 +187,7 @@ | |||||
<category android:name="android.intent.category.LAUNCHER" /> | <category android:name="android.intent.category.LAUNCHER" /> | ||||
</intent-filter> | </intent-filter> | ||||
</receiver> | </receiver> | ||||
</application> | </application> | ||||
</manifest> | </manifest> |
@@ -73,6 +73,7 @@ import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; | |||||
import com.bonait.bnframework.modules.home.adapter.wl_adapter; | import com.bonait.bnframework.modules.home.adapter.wl_adapter; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SerialInter; | import com.bonait.bnframework.modules.home.fragment.mode.SerialInter; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.SerialManage; | import com.bonait.bnframework.modules.home.fragment.mode.SerialManage; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.ShaomaTest; | |||||
import com.bonait.bnframework.modules.home.fragment.mode.add_makegood_control; | import com.bonait.bnframework.modules.home.fragment.mode.add_makegood_control; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.add_manguan_control; | import com.bonait.bnframework.modules.home.fragment.mode.add_manguan_control; | ||||
import com.bonait.bnframework.modules.home.fragment.mode.add_pf_control; | import com.bonait.bnframework.modules.home.fragment.mode.add_pf_control; | ||||
@@ -191,7 +192,10 @@ public class MakeGoodFragment extends BaseFragment { | |||||
initTopBar(); | initTopBar(); | ||||
Initdata(); | Initdata(); | ||||
Run(); | Run(); | ||||
SerialManage.GetInstance().init(new SerialInter() { | |||||
ShaomaTest.Getinstance().Open(activity,this.context); | |||||
/* SerialManage.GetInstance().init(new SerialInter() { | |||||
@Override | @Override | ||||
public void connectMsg(String path, boolean isSucc) { | public void connectMsg(String path, boolean isSucc) { | ||||
activity.runOnUiThread(new Runnable() { | activity.runOnUiThread(new Runnable() { | ||||
@@ -219,7 +223,7 @@ public class MakeGoodFragment extends BaseFragment { | |||||
} | } | ||||
}); | }); | ||||
//扫码串口连接 | //扫码串口连接 | ||||
SerialManage.GetInstance().Open("/dev/ttyS4",9600,true); | |||||
SerialManage.GetInstance().Open("/dev/ttyS4",9600,true);*/ | |||||
} | } | ||||
public List<LinkMode> Fdata = new ArrayList<>(); | public List<LinkMode> Fdata = new ArrayList<>(); | ||||
@@ -5,12 +5,14 @@ import android.serialport.SerialPort; | |||||
import android.util.Log; | import android.util.Log; | ||||
import com.serotonin.modbus4j.serial.SerialMessage; | import com.serotonin.modbus4j.serial.SerialMessage; | ||||
import com.serotonin.modbus4j.sero.util.ArrayUtils; | |||||
import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.lang.reflect.Array; | |||||
import java.util.concurrent.ScheduledFuture; | import java.util.concurrent.ScheduledFuture; | ||||
import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
@@ -99,10 +101,15 @@ public class ShaoMaSave implements Runnable{ | |||||
/*int available = inputStream.available(); | /*int available = inputStream.available(); | ||||
if (available == 0) continue;*/ | if (available == 0) continue;*/ | ||||
if (inputStream == null) continue; | if (inputStream == null) continue; | ||||
byte[] received = new byte[1024]; | |||||
int size = inputStream.read(received); | |||||
if (size>0&&serialInter!=null) | |||||
serialInter.readData(path,received,size); | |||||
byte[] received = new byte[1]; | |||||
String x=""; | |||||
int t = 1; | |||||
while (t>0){ | |||||
t= inputStream.read(received); | |||||
x+=new String(received); | |||||
} | |||||
if (x!="") | |||||
serialInter.readData(path,received,t); | |||||
Thread.sleep(20); | Thread.sleep(20); | ||||
}catch (InterruptedException e){ | }catch (InterruptedException e){ | ||||
Log.e(Tag,"线程异常"+e.toString()); | Log.e(Tag,"线程异常"+e.toString()); | ||||