Giter Club home page Giter Club logo

Comments (3)

xingshuangs avatar xingshuangs commented on June 15, 2024

v1.2.7中string是不可以写count,只有byte支持,下一个版本支持string添加count
github中master是最新版,比v1.2.7新,如果你想使用可以自行拉最新代码,打包

from iot-communication.

lovely-xin avatar lovely-xin commented on June 15, 2024

感谢,现在又发现了一个新的问题,writeString写入到PLC后,1200PLC无法处理此字符串,PLC定义string[60]。我看了下代码
public void writeString(String address, String data) { if (data.length() > 253) { throw new IllegalArgumentException("data字符串参数过长,超过253"); } byte[] dataBytes = data.getBytes(StandardCharsets.US_ASCII); byte[] tmp = new byte[2 + dataBytes.length]; tmp[0] = (byte) 0xFE; //这里长度是254 tmp[1] = ByteUtil.toByte(dataBytes.length); System.arraycopy(dataBytes, 0, tmp, 2, dataBytes.length); this.writeByte(address, tmp); }
是不是PLC string的长度要定义要在254以上才可以使用?

from iot-communication.

xingshuangs avatar xingshuangs commented on June 15, 2024

String提供了最大256个字节,前两个字节分别表示字节中最大的字符数和当前的字符数
一般我遇到的都是string类型,它总字节大小是256,对应最大字符数254
如果是string[60],它总字节大小是62,对应最大字符数60
我这个库确实没法支持string[60]这种情况,需要优化下
image

from iot-communication.

Related Issues (15)

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.