Closed GoogleCodeExporter closed 9 years ago
This issue was updated by revision 388d4de833cf.
Original comment by Petteri.Aimonen
on 26 Sep 2013 at 7:25
Petteri, I have a question. I have a case where a maximum size is not
generated by the tool, but the size is deterministic. The message in question
is
message xmit {
required MessageHeader header = 1;
required bytes data = 2 [(nanopb).max_size = 128];
}
Which references
message MessageInfo {
required fixed32 msg_id = 1;
optional fixed32 interface_id = 2;
}
message MessageResponseInfo {
required fixed64 interface_id = 1;
required fixed32 seq = 2;
required fixed32 msg_id = 3;
}
message MessageHeader {
required MessageInfo info = 1;
optional MessageResponseInfo response_info = 2;
optional MessageResponse response = 3;
}
message MessageResponse {
required MessageStatus status = 1;
required fixed32 seq = 2;
}
If I omit MessageHeader from xmit, a maximum size is generated for xmit.
Is this expected?
Original comment by allen.m...@gmail.com
on 23 Oct 2013 at 1:41
What is the definition of MessageStatus?
Original comment by Petteri.Aimonen
on 23 Oct 2013 at 5:59
/* Enum definitions */
typedef enum _MessageStatus {
MessageStatus_FAIL = 0,
MessageStatus_OK = 1
} MessageStatus;
Original comment by allen.m...@gmail.com
on 23 Oct 2013 at 4:19
Hmm, I cannot seem to be able to reproduce this problem. If I compile the
attached messages.proto, I get the following defines:
#define xmit_size 179
#define MessageInfo_size 10
#define MessageResponseInfo_size 19
#define MessageHeader_size 46
#define MessageResponse_size 11
which seems to have all the messages?
Original comment by Petteri.Aimonen
on 23 Oct 2013 at 5:13
Attachments:
One additional piece of information, xmit and the Message definitions live in
different .proto files. The Message definitions are included in the file that
defines xmit.
Original comment by allen.m...@gmail.com
on 23 Oct 2013 at 5:15
Ah.
Unfortunately I don't know a good way to handle that, because the generator has
to know the size of the submessage so that it can calculate the size of the
total message. And currently each file is processed separately.
I guess the generator could emit C code like this:
#define xmit_size (133 + MessageHeader_size)
Original comment by Petteri.Aimonen
on 23 Oct 2013 at 5:20
I think that would be reasonable. Thanks for the fast response.
Original comment by allen.m...@gmail.com
on 23 Oct 2013 at 5:29
Should work now in revision 49bd3f35a0b6db0fa47d2e6e8fe9ddfb1bbcd58b
Original comment by Petteri.Aimonen
on 23 Oct 2013 at 6:02
Fix released in nanopb-0.2.4.
Original comment by Petteri.Aimonen
on 7 Nov 2013 at 2:56
Original issue reported on code.google.com by
Petteri.Aimonen
on 25 Sep 2013 at 6:02