Hi guys,

i am trying to serialize a message to an array and deserialize it on
the other end.
unforntunately it seems not everything gets serialized:

this is my  proto file:

------------------------------------------------------------------------------------------
package protodm;

(...)

message AllConnections
{
        required VC curVC               = 1;
        required VC oldVC               = 2;
        repeated Connection connections = 3;
}

message Connection
{
//      required bytes curVC            = 1;
        required string partialConKey   = 2;
        repeated UIParam uiPars         = 5;
        repeated BOParam boPars         = 6;
        repeated STParam stParms        = 7;
}


message VC
{
        required uint32 runningNumber           = 1;
        required uint64 first           = 2;
        required uint64 second          = 3;
}

------------------------------------------------------------------------------------------

and this is my code:

------------------------------------------------------------


bool ProtoPackOwnConnections(boost::array<char, 65535 > buffer, int&
usedBufLen)
{

protodm::AllConnections allCons;
OwnConMap_T::iterator it = myOwnConnections.begin();
char* curUnused = buffer.c_array();
while (it!=myOwnConnections.end())
{
                boost::shared_ptr<SP_Connection> con = it->second;
                protodm::Connection* c = allCons.add_connections();
                con->ProtoPack(c);
                ++it;
}

::Mediornet::protodm::VC* theCurVC= allCons.mutable_curvc();
::Mediornet::protodm::VC* theOldVC= allCons.mutable_oldvc();

theCurVC->set_first(curVC.first);
theCurVC->set_second(curVC.second);
theCurVC->set_runningnumber(curVC.runningNumber);

theOldVC->set_first(oldVC.first);
theOldVC->set_second(oldVC.second);
theOldVC->set_runningnumber(oldVC.runningNumber);

mn_assert(allCons.has_curvc()&& allCons.oldvc().first() ==
oldVC.first, "not set???");

        usedBufLen = allCons.ByteSize();
        google::protobuf::uint8* ptr =
allCons.SerializeWithCachedSizesToArray( (google::protobuf::uint8*)
buffer.c_array() );

        std::string tmp = allCons.ShortDebugString();
        DebugConsole(0, "allCons as ShortDebugString: \n%s\n", tmp.c_str());

//testing unpack:
        protodm::AllConnections unp;

        if (!unp.ParseFromArray(buffer.c_array(), 0))
        {
                DebugConsole(0, "Couldnt parse!");
                return false;
        }
return ptr!=NULL;
}
------------------------------------------------------------------------------------------------------------------------

and this will be the output:


Firmware          : allCons as ShortDebugString:
connections { partialConKey:
"CO00000000000066_00_08__0000000000006A_03_057" uiPars { key { Keydef:
132 } value: 16777472 } uiPars { key { Keydef: 212 } value: 1 } uiPars
{ key { Keydef: 213 } value: 300 } uiPars { key { Keydef: 215 } value:
1279522249 } boPars { key { Keydef: 223 } value: false } boPars { key
{ Keydef: 224 } value: false } stParms { key { Keydef: 10 } value:
"SW00000000000066.CO00000000000066_00_08__0000000000006A_03_057" }
stParms { key { Keydef: 226 } value: "" } stParms { key { Keydef:
16603 keyui: 0 } value: "SW00000000000066.SL03.CH048" } stParms { key
{ Keydef: 16603 keyui: 1 } value: "SW00000000000066.SL05.CH051" }
stParms { key { Keydef: 16603 keyui: 2 } value:
"SW00000000000066.SL10.CH008" } stParms { key { Keydef: 16603 keyui:
3 } value: "SW00000000000066.SL06.CH057" } stParms { key { Keydef:
16604 keyui: 0 } value: "SW00000000000066.SL00.CH018" } stParms { key
{ Keydef: 16604 keyui: 1 } value: "SW00000000000066.SL07.CH060" }
stParms { key { Keydef: 16604 keyui: 2 } value:
"SW00000000000066.SL06.CH048" } stParms { key { Keydef: 16604 keyui:
3 } value: "SW00000000000066.SL04.CH026" } } connections
{ partialConKey: "CO00000000000066_00_20__00000000000039_06_060"
uiPars { key { Keydef: 132 } value: 16777472 } uiPars { key { Keydef:
212 } value: 1 } uiPars { key { Keydef: 213 } value: 300 } uiPars
{ key { Keydef: 215 } value: 1279522249 } boPars { key { Keydef: 223 }
value: false } boPars { key { Keydef: 224 } value: false } stParms
{ key { Keydef: 10 } value:
"SW00000000000066.CO00000000000066_00_20__00000000000039_06_060" }
stParms { key { Keydef: 226 } value: "" } stParms { key { Keydef:
16603 keyui: 0 } value: "SW00000000000066.SL07.CH000" } stParms { key
{ Keydef: 16603 keyui: 1 } value: "SW00000000000066.SL03.CH031" }
stParms { key { Keydef: 16603 keyui: 2 } value:
"SW00000000000066.SL08.CH034" } stParms { key { Keydef: 16603 keyui:
3 } value: "SW00000000000066.SL01.CH014" } stParms { key { Keydef:
16604 keyui: 0 } value: "SW00000000000066.SL10.CH005" } stParms { key
{ Keydef: 16604 keyui: 1 } value: "SW00000000000066.SL08.CH063" }
stParms { key { Keydef: 16604 keyui: 2 } value:
"SW00000000000066.SL02.CH017" } stParms { key { Keydef: 16604 keyui:
3 } value: "SW00000000000066.SL01.CH007" } } connections
{ partialConKey: "CO00000000000066_00_20__00000000000078_10_062"
uiPars { key { Keydef: 132 } value: 16777472 } uiPars { key { Keydef:
212 } value: 1 } uiPars { key { Keydef: 213 } value: 300 } uiPars
{ key { Keydef: 215 } value: 1279522249 } boPars { key { Keydef: 223 }
value: false } boPars { key { Keydef: 224 } value: false } stParms
{ key { Keydef: 10 } value:
"SW00000000000066.CO00000000000066_00_20__00000000000078_10_062" }
stParms { key { Keydef: 226 } value: "" } stParms { key { Keydef:
16603 keyui: 0 } value: "SW00000000000066.SL07.CH062" } stParms { key
{ Keydef: 16603 keyui: 1 } value: "SW00000000000066.SL07.CH027" }
stParms { key { Keydef: 16603 keyui: 2 } value:
"SW00000000000066.SL05.CH005" } stParms { key { Keydef: 16603 keyui:
3 } value: "SW00000000000066.SL09.CH008" } stParms { key { Keydef:
16604 keyui: 0 } value: "SW00000000000066.SL06.CH050" } stParms { key
{ Keydef: 16604 keyui: 1 } value: "SW00000000000066.SL03.CH011" }
stParms { key { Keydef: 16604 keyui: 2 } value:
"SW00000000000066.SL07.CH033" } stParms { key { Keydef: 16604 keyui:
3 } value: "SW00000000000066.SL08.CH017" } } connections
{ partialConKey: "CO00000000000066_00_24__0000000000003D_01_019"
uiPars { key { Keydef: 132 } value: 16777472 } uiPars { key { Keydef:
212 } value: 1 } uiPars { key { Keydef: 213 } value: 300 } uiPars
{ key { Keydef: 215 } value: 1279522249 } boPars { key { Keydef: 223 }
value: false } boPars { key { Keydef: 224 } value: false } stParms
{ key { Keydef: 10 } value:
"SW00000000000066.CO00000000000066_00_24__0000000000003D_01_019" }
stParms { key { Keydef: 226 } value: "" } stParms { key { Keydef:
16603 keyui: 0 } value: "SW00000000000066.SL03.CH003" } stParms { key
{ Keydef: 16603 keyui: 1 } value: "SW00000000000066.SL10.CH009" }
stParms { key { Keydef: 16603 keyui: 2 } value:
"SW00000000000066.SL10.CH048" } stParms { key { Keydef: 16603 keyui:
3 } value: "SW00000000000066.SL02.CH047" } stParms { key { Keydef:
16604 keyui: 0 } value: "SW00000000000066.SL06.CH024" } stParms { key
{ Keydef: 16604 keyui: 1 } value: "SW00000000000066.SL03.CH054" }
stParms { key { Keydef: 16604 keyui: 2 } value:
"SW00000000000066.SL01.CH024" } stParms { key { Keydef: 16604 keyui:
3 } value: "SW00000000000066.SL09.CH017" } } connections
{ partialConKey: "CO00000000000066_00_28__00000000000022_05_047"
uiPars { key { Keydef: 132 } value: 16777472 } uiPars { key { Keydef:
212 } value: 1 } uiPars { key { Keydef: 213 } value: 300 } uiPars
{ key { Keydef: 215 } value: 1279522249 } boPars { key { Keydef: 223 }
value: false } boPars { key { Keydef: 224 } value: false } stParms
{ key { Keydef: 10 } value:
"SW00000000000066.CO00000000000066_00_28__00000000000022_05_047" } stP
libprotobuf ERROR google/protobuf/message_lite.cc:123] Can't parse
message of type "Mediornet.protodm.AllConnections" because it is
missing required fields: curVC, oldVC

Firmware          :
Couldnt parse!

------------------------------------------------------------------------------------------------------------------------

i spare you with the details of the other messages in "Connection",
that is all working fine.
all gets down to: "Why is he apparently not serializing
curVC&oldVC???"

i also tried the normal "SerializeToArray" to no avail.

i dont have any more ideas what i could do different, can anybody give
me a hint what to do?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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.

Reply via email to