Protobuf illegal Wire type

protobuf.min.js:63 Uncaught Error: Illegal wire type for field Message.Field .Data_new.vert: 5 (2 expected)

I get this message when I try to decode my binary file with protobuf.

vert.proto:

message Vertice_new{
    repeated float values = 1 [packed = true];
}
message Data_new{
    repeated Vertice_new vert = 1;
}

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.

for references here my cpp code:

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);
}

Answers:

Answer

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.

Answer

It looks like you're serializing the field as if it's not packed. Are you using an older version of the proto to serialize your data?

Wire type 5 is a 32-bit fixed-width field (fixed32, sfixed32, or float), which would match repeated float values = 1. Wire type 2 is a length-delimited field (string, bytes, message, or packed repeated field), which matches what's in the proto you posted (repeated float values = 1 [packed = true]).

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.