dathlin / HslCommunication

A very popular industrial Internet of Things communication plug-in. Using this dll can be very convenient, stable, and fast to obtain data from PLC equipment of multiple brands, and also supports redis, mqtt, websocket, etc., which can let your data on the network Free transmission, reducing enterprise development costs.
http://www.hslcommunication.cn
1.56k stars 612 forks source link

采集AB CIP一组数据,调用API进行解析时,布尔类型数据解析异常 #35

Open sjdGitHub opened 1 year ago

sjdGitHub commented 1 year ago

以下图中程序使用java程序编写,操作如下: 先在plc中准备有一组数据,地址分别有"B[0].A","B[0].B", "B[0].C","B[0].D","B[0].E", "ZZ.B",以B打头的都是布尔类型,ZZ.B是plc中的int类型数值为66,"B[0].A","B[0].B"这两个布尔量为true,其他为false;如下图编写程序批量进行读取,会发现布尔类型读到的全为true,但是感觉返回的byte数据中的数据也并没有什么问题,第二张图中我把false的布尔量点位放到了第一个位置,这里相当于调换了一下位置,发现解析出来的布尔量又全部变成了false。 L~ }$SV 9`U_2WYH }JE0Z1 点位调换顺序: _M$ZHMHDWZEVK5(7F404SWC

dathlin commented 1 year ago

在这里的 TransBool 的API 方法里,index 的偏移单位是 bit 所以,你这里需要写 0, 8, 16, 24, 32 而不是 0, 1, 2, 3, 4