| | |
| | | case PLCDataTypeEnum.String: |
| | | { |
| | | string dpos = IncrementCode(Pos); |
| | | Result<byte[]> result1 = _client.ReadString(Pos, 1); |
| | | Result<byte[]> result1 = _client.ReadString(Pos, 2); |
| | | if (result1.IsSucceed) |
| | | { |
| | | Result<byte[]> result2 = _client.ReadString(dpos, (ushort)(result1.Value[0])); |
| | | //wxw改 |
| | | if ((ushort)(result1.Value[1]) > (ushort)(result1.Value[0])) |
| | | { |
| | | break; |
| | | } |
| | | ushort let = (ushort)(result1.Value[1]);//(ushort)(result1.Value[0]) 备注:result1.Value[0]取的是设置的最大长度,result1.Value[0]取的是实际值长度 |
| | | |
| | | Result<byte[]> result2 = _client.ReadString(dpos, let); |
| | | Result<string> result3 = new Result<string>(result2); |
| | | if (result3.IsSucceed) |
| | | { |
| | | result3.Value = Encoding.ASCII.GetString(result2.Value, 0, result1.Value[0]).Replace("\0", ""); |
| | | result3.Value = Encoding.ASCII.GetString(result2.Value, 0, let).Replace("\0", ""); |
| | | result = result3; |
| | | } |
| | | } |