John Lee
John Lee
我这里需要适配长边/短边(旋转屏幕后控件的大小不会发生变化),而不是适配当前宽度/高度。所以自己建了个repo,拉了你的工具类修改了下,不知道大佬你介不介意(当然是有放引用来源)。 ```java /** * 针对屏幕“较短边”进行适配,重写{@link Activity#getResources()} 方法,调用此方法后返回 * * @param resources 填入super.getResources() * @param designShortSize 参考UI图的较短边尺寸 */ public static Resources adaptShorter(Resources resources, int designShortSize) { return adaptShorter(resources, designShortSize, false); }...
不清楚,没设备。 这项目只是fork了Google原来的DEMO回来,简单改了下,方便自己用。并没有进行兼容性测试。 你可以试下检查一下Android板子出来的串口的电平类型是哪种,是ttl还是232电平的,连接的串口设备又是什么电平。
@yutils 在每次`inputStream.read()`之前,先判断一下`inputStream.available()`,有数据才读一次,例如[这样](https://github.com/licheedev/SerialWorker/blob/d549efb0f62faf4c2edb7515f31a94dab3fce1a0/serialworker/src/main/java/com/licheedev/serialworker/worker/BaseSerialWorker.java?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L188) ``` while (mRunning) { try { if (mInputStream.available() > 0) { len = mInputStream.read(mRecvBuffer); if (len > 0) { receiver.onReceive(validData, mRecvBuffer, 0, len); } } else { //...
> I have the same problem, @xunhuangj 注释掉这一行 > https://github.com/licheedev/Android-SerialPort-API/blob/master/serialport/build.gradle#L40 或者把这个是否上传改为false > https://github.com/licheedev/Android-SerialPort-API/blob/master/serialport/bintray.gradle#L10
@alirazaseptems https://github.com/licheedev/SerialportApiSample i just wrote a simple demo.i hope that will help you.
oh, forget the terrible code on Android-SerialPort-Tool,i wrote it just for finding out which serialport is avaiable. in fact, the major code from https://github.com/licheedev/SerialportApiSample is in java,like this [SerialWorker.java](https://github.com/licheedev/SerialportApiSample/blob/master/app/src/main/java/com/licheedev/serialportapisample/serial/SerialWorker.java) now...
@alirazaseptems ok, i copy the `Android-SerialPort-Tool` repo https://github.com/licheedev/Android-SerialPort-Tool_Copy i change the code like this [SerialPortManager.java](https://github.com/licheedev/Android-SerialPort-Tool_Copy/blob/master/app/src/main/java/com/licheedev/serialtool/comn/SerialPortManager.java) now you can get the response from the callback directly ```java SerialPortManager.instance().sendCommand(text, new Callback() {...
> 想问下 日后像升级这能开多一个新库吗 别把之前的删除 > 我之前一直用着 'com.github.licheedev.Android-SerialPort-API:serialport:1.0.1' > 觉得蛮好的 哈哈 @roshenLiang 其实也没删,我改版本之前建了个分支 https://github.com/licheedev/Android-SerialPort-API/tree/1.x.x Jitpack上构建的老版本还在 https://jitpack.io/#licheedev/Android-SerialPort-API
Use something like EventBus? > https://github.com/licheedev/SerialWorker/blob/404fa579c5e79ac51ff389b8c923e38a02aeec4b/app/src/main/java/com/licheedev/serialworkerdemo/serial/SerialManager.java#L94
Just create multi SerialPort instances, and make sure each SerialPort reads data on a separate thread. Encapsulate your `SerialPort creatation、reading and writing` code into a `Worker` class like this: >...