Hello Experts,
I am new to this Protocol buffer techinque.I am trying to use PB in my
project because my project is critical to the data transfer rate(Battery
power).
So I am trying to use PB to serialize data (in binary mode) to reduce the
data size before transferring this data to the other application.
But I was not successful in seeing the reduction in size even after
serializing with API's SerializeToString() OR SerializeToArray().
let's say ,my string is like the below which I am sending on evey 100
millisecond to other application,
<attribute msgCommand="update" type="uid64" uid64="123445667898"
datatype="8" rawdata="FFF1" default="65297" />
Previously it was sending in text mode and now i am trying with ProtoBuff
to serailize this to send,but I could not see any diffrence in size
reduction of this string
after serilaizng with PB.please see my code and let me know where i am
doing the mistake,
-------
proto
--------
message AMessage
{
optional string str1=1;
}
-------------------------------------------------------------------------------------
Code i have done to serailize the above string to reduce the size (binary
format)
-----------------------------------------------------------------------------------------
AMessage A_msg;
A_msg.set_str1(m_txBuff); // m_txBuff -contains the above
mentioned string
std::string encode_string;
// ----tried with SerializeToString,but was not successful --------//
A_msg.SerializeToString(&encode_string);
// ----------tried with SerializeToArray ,it was also not
successful-----//
int size_bytes = A_msg.ByteSize();
void *buffer_bytes = malloc(size_bytes);
A_msg.SerializeToArray(buffer_bytes, size_bytes);
//sending the data send
infomq_cmd_publish((unsigned
char*)encode_string.c_str(),encode_string.size(),0);
Anything i need to do extra for making this serailization in binary format
for reducing the size on serialization ?
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.