Hello all,
 
I'm trying to exchange messages between c++ and java and vice-versa without 
success.
 
I've defined two messages (1 to be sent from c++ to java and another to be 
sent the other way around) with union types (see attached .proto).
 
The c++ code is as follows:

*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_pNamedPipeSocket->write(buf, message.ByteSize()); 
m_pNamedPipeSocket->flush();*
 
The java code is as follows:
*int bytes = 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;
}*
** 
The communication is made by pipes (QLocalSocket on c++, FileInputStream on 
java side)
C++ sends 33 bytes and java received them all but blows with an exception 
*InvalidProtocolBufferException: 
Protocol message contained an invalid tag (zero).*
 
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/-/i3X8hX-sTMcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to