Protobuf非法电线类型 [英] Protobuf illegal Wire type
问题描述
protobuf.min.js:63未捕获错误:字段的非法线类型
Message.Field .Data_new.vert:5(预期为2)
protobuf.min.js:63 Uncaught Error: Illegal wire type for field Message.Field .Data_new.vert: 5 (2 expected)
当我尝试使用protobuf解码我的二进制文件时,我收到此消息。
I get this message when I try to decode my binary file with protobuf.
vert.proto: / p>
vert.proto:
message Vertice_new{
repeated float values = 1 [packed = true];
}
message Data_new{
repeated Vertice_new vert = 1;
}
并且在cpp中我只是把很多原始数据以x,y,z,压力,应变...等等都是浮动的,当我尝试解码它在JavaScript这边我得到这个奇怪的消息,它是工作正常,直到我们改变输入数据,现在我don不知道在哪里寻找修复。
and in cpp i just put in a lot of raw data in the form of x,y,z,stress,strain ... and so on which are all floats and when I try to decode it on javascript side I get this weird message, it was working fine until we changed the input data, and now I don't know where to look for the fixing.
我的cpp代码参考:
Data_new data_new;
for ... loopparameter is i ; {
vert->add_values(nodes[i].pos.x + diffs[i].pos.x);
vert->add_values(nodes[i].pos.y + diffs[i].pos.y);
vert->add_values(nodes[i].pos.z + diffs[i].pos.z);
vert->add_values(nodes[i].directStress.x);
vert->add_values(nodes[i].directStress.z);
vert->add_values(nodes[i].directStrain.x);
vert->add_values(nodes[i].directStrain.z);
}
推荐答案
!问题出在代码我发布!我只设置一个Ostream来写入二进制数据,而是我需要实际上的状态,我想要写入的文件是二进制。非常感谢大家的帮助和建议。
So finally I figured it out! The problem was outside the code I posted ! I only set up an Ostream to write the binary data into, but instead I needed to actually state, that the file I want to write in is binary. So thank you all for your help and advice.
这篇关于Protobuf非法电线类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!