[英]nanopb - how to specify encoding of integer in proto file
How do I set a int32
to use a fixed size for encoding?如何设置
int32
以使用固定大小进行编码?
PB_LTYPE_FIXED32 0x04 32-bit integer or floating point.
But what option do I set in the .proto
file to encode a int32
as a PB_LTYPE_FIXED32
as opposed to a PB_LTYPE_VARINT
?但是我在
.proto
文件中设置什么选项来将int32
编码为PB_LTYPE_FIXED32
而不是PB_LTYPE_VARINT
?
In the function encode_basic_field
the fields
structure, which is autogenerated, stores the field type which means that this information is set in .proto
file somehow.在函数
encode_basic_field
中,自动生成的fields
结构存储字段类型,这意味着该信息以某种方式设置在.proto
文件中。
I think you should try "int32_t" instead of int32.我认为您应该尝试“int32_t”而不是 int32。
please check the "nanopb" project, in the file "nanopb_generator.py", there is a dictionary called "datatypes", here is some code:请检查“nanopb”项目,在文件“nanopb_generator.py”中,有一个名为“datatypes”的字典,这里有一些代码:
FieldD.TYPE_FIXED32: ('uint32_t', 'FIXED32', 4, 4),
FieldD.TYPE_SFIXED32: ('int32_t', 'SFIXED32', 4, 4),
because it's my first time to see the "nanopb" project, I'm not 100% sure whether it will work or not.因为这是我第一次看到“nanopb”项目,我不能 100% 确定它是否会工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.