Browse Source

cypf

茶饮配方
lyw 9 months ago
parent
commit
cdcee5e2fd
3 changed files with 19 additions and 6 deletions
  1. +2
    -0
      app/src/main/AndroidManifest.xml
  2. +6
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  3. +11
    -4
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ShaoMaSave.java

+ 2
- 0
app/src/main/AndroidManifest.xml View File

@@ -18,6 +18,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.USB_PERMISSION" />

<application
android:name=".MainApplication"
@@ -186,6 +187,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>

</application>

</manifest>

+ 6
- 2
app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java View File

@@ -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.fragment.mode.SerialInter;
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_manguan_control;
import com.bonait.bnframework.modules.home.fragment.mode.add_pf_control;
@@ -191,7 +192,10 @@ public class MakeGoodFragment extends BaseFragment {
initTopBar();
Initdata();
Run();
SerialManage.GetInstance().init(new SerialInter() {


ShaomaTest.Getinstance().Open(activity,this.context);
/* SerialManage.GetInstance().init(new SerialInter() {
@Override
public void connectMsg(String path, boolean isSucc) {
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<>();


+ 11
- 4
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ShaoMaSave.java View File

@@ -5,12 +5,14 @@ import android.serialport.SerialPort;
import android.util.Log;

import com.serotonin.modbus4j.serial.SerialMessage;
import com.serotonin.modbus4j.sero.util.ArrayUtils;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

@@ -99,10 +101,15 @@ public class ShaoMaSave implements Runnable{
/*int available = inputStream.available();
if (available == 0) 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);
}catch (InterruptedException e){
Log.e(Tag,"线程异常"+e.toString());


Loading…
Cancel
Save