protobuf.js 版本:^6.2.1
缓冲
083515604859581840220a0d6048595815bdf426422a0a0d7047595815bdf426
代码:
protobuf.load("PulseFlagData.proto", function(err, root) {
if (err) {
callback(err);
}
var pulse = root.lookup("PulseFlagData");
callback(null, pulse.decode(parsed_data.payload));
});
.proto 文件:
syntax = "proto3";
message PulseFlagSample {
required fixed32 timestamp = 1;
required uint32 input = 2;
required bool flag = 3;
}
message PulseFlagData {
required uint32 config_version = 1;
required fixed32 device_time = 2;
required PulseFlagSample current = 3;
optional PulseFlagSample last_hour = 4;
}
错误:
/home/deck/NetBeansProjects/lora/node_modules/protobufjs/src/reader.js:390 throw indexOutOfRange(this, length); ^
RangeError: index out of range: 23 + 10 > 32 at RangeError (native) at indexOutOfRange (/home/deck/NetBeansProjects/lora/node_modules/protobufjs/src/reader.js:13:12) at BufferReader.skip (/home /deck/NetBeansProjects/lora/node_modules/protobufjs/src/reader.js:390:19) 在 BufferReader.ReaderPrototype.skipType (/home/deck/NetBeansProjects/lora/node_modules/protobufjs/src/reader.js:410:18 ) 在 Type._PulseFlagSample$decode [as decode] (eval at eof (/home/deck/NetBeansProjects/lora/node_modules/protobufjs/node_modules/@protobufjs/codegen/index.js:102:25), :19:7)在 Type.decode_setup [as decode] (/home/deck/NetBeansProjects/lora/node_modules/protobufjs/src/type.js:370:7) at Type._PulseFlagData$decode [as decode] (eval at eof (/home/甲板/NetBeansProjects/lora/node_modules/protobufjs/node_modules/@protobufjs/codegen/index.js:102:25), :16:27) 在 Type.decode_setup [as decode] (/home/deck/NetBeansProjects/lora/node_modules/protobufjs/src/type.js:370:7) at /home/deck/NetBeansProjects/ lora/server.js:42:50 完成 (/home/deck/NetBeansProjects/lora/node_modules/protobufjs/src/root.js:84:9)