zhangzengfei
2023-08-11 fc2160552167a4fdfe5cc582f9533b455674983e
修复长度大于1的读取结果
1个文件已修改
11 ■■■■ 已修改文件
collector/plc4x.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
collector/plc4x.go
@@ -1,6 +1,7 @@
package collector
import (
    "errors"
    "fmt"
    plc4go "github.com/apache/plc4x/plc4go/pkg/api"
@@ -92,11 +93,17 @@
    // 判断响应码是否正确
    if readResult.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK {
        fmt.Printf("error an non-ok return code: %s", readResult.GetResponse().GetResponseCode("tag").GetName())
        return nil, nil
        return nil, errors.New("error  code: " + readResult.GetResponse().GetResponseCode("tag").GetName())
    }
    value := readResult.GetResponse().GetValue("tag")
    return value.GetRaw(), err
    var result []byte
    for _, val := range value.GetList() {
        result = append(result, val.GetRaw()...)
    }
    return result, nil
}