How to use protoc --decode option?

10,619 views
Skip to first unread message

Ravi

unread,
Jul 5, 2011, 7:30:10 AM7/5/11
to Protocol Buffers
Hi,

I am trying to convert a protobuf stream in to a readable format. I
got following exception.

protobuf.txt:2:1: Invalid control characters encountered in text.
protobuf.txt:2:2: Expected top-level statement (e.g. "message").
protobuf.txt:2:9: Invalid control characters encountered in text.


Steps i tried:
1) Built the protobuf message object and saved the output to a file
(protobuf.txt). (tried in java)
2) Used the decode option in command line. The arguments are
protoc --proto_path=<proto path> <proto file name> --
decode=<fully qualified message name> <a text file path which contains
the protobuf payload>

protoc --proto_path=D:\Work\ProtoBuf\workspace2_4_0_a\TesteLVIS\src\com
\proto D:\Work\ProtoBuf\workspace2_4_0_a\TesteLVIS\src\com\proto
\TestSameName.proto --decode=com.ebay.test.Book D:\Work\ProtoBuf
\workspace2_4_0_a\TesteLVIS\src\com\proto\protobuf.txt

Please let me know what i am doing wrong here?
is it something related to file encoding? If so how do i resolve it?





Pherl Liu

unread,
Jul 5, 2011, 10:06:08 AM7/5/11
to Ravi, Protocol Buffers
The protoc reads the input from STDIN. If you pass the payload file name as parameter, protoc will treat that file as a ".proto" file. You should pipe the payload to protoc instead.






--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.


Ravi

unread,
Jul 5, 2011, 10:12:46 AM7/5/11
to Protocol Buffers
Hi,

I tried that also. I pasted the payload directly in the command prompt
when it asked.
I got following error.

"Failed to parse input."

Thanks,
Ravikumar K

On Jul 5, 7:06 pm, Pherl Liu <liuj...@google.com> wrote:
> The protoc reads the input from STDIN. If you pass the payload file name as
> parameter, protoc will treat that file as a ".proto" file. You should pipe
> the payload to protoc instead.
>

Pherl Liu

unread,
Jul 5, 2011, 10:41:29 AM7/5/11
to Ravi, Protocol Buffers
Can you try:

protoc [various options]  < payload.txt

So that the content will be read as STDIN to protoc.
Reply all
Reply to author
Forward
0 new messages