Decoding protobuf buffer

365 views
Skip to first unread message

MichaelMelamud

unread,
Jan 1, 2013, 10:19:50 AM1/1/13
to Protocol Buffers
Hi,

I have a file that is in protobuf format ,also i have the .proto
schema ,i am working on a embedded platform,so using protobuf as
is ,is a kind of problematic.

I was trying to decode the buffer by myself but no luck for now , i
red this document
https://developers.google.com/protocol-buffers/docs/encoding

But i cannot fully understand how does it work.

any suggestions on how can i decode the data ? any tutorial or
examples?
Also is there an option in the protobuf when preparing the data not to
encode it and leave it as is ?


Thanks
And merry christmas

Michael

Hochhaus, Andrew

unread,
Jan 1, 2013, 11:15:55 AM1/1/13
to MichaelMelamud, Protocol Buffers
Michael,

On Tue, Jan 1, 2013 at 9:19 AM, MichaelMelamud <00m...@gmail.com> wrote:
> i am working on a embedded platform,so using protobuf as
> is ,is a kind of problematic.

Have you considered using "optimize_for = LITE_RUNTIME"?

https://developers.google.com/protocol-buffers/docs/proto

Alternatively, would an existing open source project such as
protobuf-embedded-c meet your needs? (I have never used this, so I
have no idea if it is a good candidate or not -- just the #1 result
for "protobuf embeded".)

http://code.google.com/p/protobuf-embedded-c/

If neither of these work, can you describe the expectations of your
embedded environment in greater detail?

> any suggestions on how can i decode the data?

Have you considered looking at the code in the open source protocol
buffer implementation?

> any tutorial or examples?

The page you linked to is the best resource I know of (and reasonably
complete IMO). If you are going to roll your own, have you considered
using the Coded{Input,Output}Stream interface to minimize the amount
of code you need to write (and maximize compatibility)?

Another idea is to use the google's protobuf implementation to
serialize example messages and then make sure your re-implementation
can deserialize them.

> Also is there an option in the protobuf when preparing the data not to
> encode it and leave it as is ?

What do you mean by leaving the data "as-is"? Some serialization
format (field "tags", value length tracking, number
formatting/endianness, etc) must be agreed upon by the code that
serializes and deserializes the messages.

Maybe you are looking for a way to avoid varint encoding? If so, I
guess you could check out the fixed{32,64} datatype which is "stored
in little-endian byte order" (based on the docs in the URL you
reference).

Goodluck.

-Andy

Hochhaus, Andrew

unread,
Jan 1, 2013, 11:20:08 AM1/1/13
to MichaelMelamud, Protocol Buffers
On Tue, Jan 1, 2013 at 10:15 AM, Hochhaus, Andrew
<ahoc...@samegoal.com> wrote:
>> Also is there an option in the protobuf when preparing the data not to
>> encode it and leave it as is ?

Maybe you are looking for a human readable text encoding of the data?
If so, check out google::protobuf::TextFormat. (However, this isn't
designed to be a very efficient encoding of the data, so it may or may
not meet your use case.)

-Andy

MichaelMelamud

unread,
Jan 1, 2013, 12:40:07 PM1/1/13
to Protocol Buffers
Hi,

Thank you all for your replies, i will defiantly try the protobuf-
embedded tomorrow , it sounds great.
to tell you the truth i managed to compile and run the full protobuf
on my embedded system,but when i decode the messages ,the first
message decodes fine,
but the second message sends me to hard fault handler,its a problem
inside of protobuf,but i don't have the power or the will to debug
it .
so i am looking for an alternative,offcourse the last resort is to
decode it myself .

Anyways thanks again , i will try the protobuf-embedded tomorrow and
update if anything :)



On Jan 1, 6:20 pm, "Hochhaus, Andrew" <ahochh...@samegoal.com> wrote:
> On Tue, Jan 1, 2013 at 10:15 AM, Hochhaus, Andrew
>

adeel yousaf

unread,
Jan 30, 2014, 12:51:06 PM1/30/14
to prot...@googlegroups.com
how u have decodeed first mesage?
neded help
 
Reply all
Reply to author
Forward
0 new messages