On 30 June 2014 00:41, Nayab Rasul <rasulnra...@gmail.com> wrote:

> I am using zeromq with protobuf to send/recieve messages but code was
> crashing on receiver end while *ParseFromString *with Segmentation fault
> error.
>
> Scan is my message and i has float data types as repeated filed.
>
>
> *sender.cpp   // part of code sending*
>
> *Scan proto_ls_msg;*
>
> *proto_ls_msg.set_angle_min(0.0);*
>
> *proto_ls_msg.set_angle_max(180.5);*
>
> *std::string ls_msg_str;*
>
> *proto_ls_msg.SerializeToString(&ls_msg_str);*
>
> *zmq::message_t request (ls_msg_str.size());*
>
> *memcpy (request.data(), ls_msg_str.c_str(),ls_msg_str.size());*
>
> *socket.send (request);*
>
>
> *collector.cpp **// part of code recieving*
>
> *zmq::message_t recieved;*
>
> *socket.recv (&recieved);*
>
> *std::string ls_msg_str((char*)recieved.data(),recieved.size()); *
>
> *Scan *pb_laser_msg_rcv;*
>
> *pb_laser_msg_rcv->ParseFromString(ls_msg_str); // <--  Segmentation fault
> here*
>

no wonder, pb_laser_msg_rcv is an uninitizliaed pointer.

Do

Scan *b_laser_msg_rcv = new Scan();
pb_laser_msg_rcv->...

(or allocate it on the stack or elsewhere).


> Is there any example code for sending/recieving with repeated float fields.
>
> thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to