Quarta-feira, 5 de Dezembro de 2012 15:37:40 UTC, valadas escreveu: > > Hello I'm trying to use protobuf 2.4.1 to exchange messages between c++ > and java. > > I have defined a .proto file (attached) with two union messages ,one to be > sent from java to c++ and other the other way around. > > I started testing the c++ but I'm not able to receive the message in the > java side (I got an exception about a zero tag) > > The C++\QT code is as follows: > > > *char buf[4096];* > *operational_gui::OperationalMessage message; * > *message.set_type(operational_gui::OperationalMessage::OWNPOSITIONREPORT); > * > * message.mutable_oprep()->set_latitude(38.5); * > * message.mutable_oprep()->set_longitude(-9.8); * > * message.mutable_oprep()->set_heading(25); * > * message.mutable_oprep()->set_validity(0);* > * * > > *message.SerializeToArray(buf, message.ByteSize()); * > *m_pSocket->write(buf, message.ByteSize()); * > *m_pSocket->flush();* > > the m_pSocket is a QLocalSocket > > on the java I have the following code: > > *FileinputStream pipe = new FileinputStream(pipeName);* > *char buffer = new char[4096];* > ** > *pipe.read(buffer);* > * > MessagesProtos.OperationalMessage message = > MessagesProtos.OperationalMessage.parseFrom(buffer); > > switch(message.getType()){ > case OWNPOSITIONREPORT:* > * System.out.println("Response is OwnPositionReport");* > * break;* > * case FRIENDPOSITIONREPORT:* > * System.out.println("Response is FriendPositionReport");* > * break;* > * case COMMSTATUSREPORT:* > * System.out.println("Response is CommStatusReport");* > * break;* > * }* > * * > > But parseFrom always give an exception stating *"Protocol message > contained an invalid tag (zero)"* > > The buffer sent is the same that is received on java (33 bytes, see > attachment) > > Any hints ? > > Thanks in advance >
-- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/Nzw_qre5wr4J. To post to this group, send email to protobuf@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.