Giter VIP home page Giter VIP logo

Comments (3)

Dwhy avatar Dwhy commented on September 24, 2024

实现AbsStickPackageHelper接口发送多次能收到一次回复

serialHelper.setStickPackageHelper(new AbsStickPackageHelper() {
@OverRide
public byte[] execute(InputStream inputStream) {
byte[] buffer = new byte[1024];
try {
int size= inputStream.read(buffer);
byte[] data=new byte[size];
System.arraycopy(buffer,0,data,0,size);
Log.i(TAG, "CacheThread: 接收:" + MessageUtils.getInstance().bytesToHexString(data));
} catch (IOException e) {
Log.e(TAG, "run: 数据读取异常:" +e.toString());
}
return new byte[0];
}
});

from android-serialport.

SimonTse avatar SimonTse commented on September 24, 2024

导入包然后复制demo里面的代码,发送后收不到回应,没有任何回应,请问这是什么情况

请问下您解决了这个问题吗?我这里也遇到了能正常打开串口并控制硬件开关,但是硬件返回的数据我这里收不到任何消息。如果解决了,麻烦告知一下,多谢!

from android-serialport.

xmaihh avatar xmaihh commented on September 24, 2024
@Override
    public byte[] execute(InputStream is) {
        try {
            int available = is.available();
            if (available > 0) {
                byte[] buffer = new byte[1024];
                int size = is.read(buffer);
                if (size > 0) {
                    return buffer;
                }
            } else {
                SystemClock.sleep(50);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

from android-serialport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.