Exemplo n.º 1
0
////////////////////////////////////////////////////////////////////////////////////
///
///   \brief Reads message payload from the packet.
///
///   Message contents are read from the packet following the JAUS standard.
///
///   \param[in] packet Packet containing message payload data to read.
///
///   \return -1 on error, otherwise number of bytes written.
///
////////////////////////////////////////////////////////////////////////////////////
int ReportConfiguration::ReadMessageBody(const Packet& packet) 
{
    int total = 0;
    int expected = BYTE_SIZE;
    Byte count1 = 0;

    total += packet.Read(count1);
    for(Byte i = 0; i < count1; i++)
    {
        expected += BYTE_SIZE*2;
        Byte node = 0;
        Byte count2 = 0;
        Record::List components;

        total += packet.Read(node);
        total += packet.Read(count2);
        for(Byte j = 0; j < count2; j++)
        {
            expected += BYTE_SIZE*2;
            Record record;
            total += packet.Read(record.mComponent);
            total += packet.Read(record.mInstance);
            components.push_back(record);
        }
        mNodes[node] = components;
    }

    return total == expected ? total : -1;
}
Exemplo n.º 2
0
////////////////////////////////////////////////////////////////////////////////////
///
///   \brief Reads message payload from the packet.
///
///   Message contents are read from the packet following the JAUS standard.
///
///   \param[in] packet Packet containing message payload data to read.
///
///   \return -1 on error, otherwise number of bytes written.
///
////////////////////////////////////////////////////////////////////////////////////
int ReportServices::ReadMessageBody(const Packet& packet) 
{
    int total = 0;
    Byte count1 = 0;

    total += packet.Read(count1);
    for(Byte i = 0; i < count1; i++)
    {
        Byte node = 0;
        Byte count2 = 0;
        Record::List components;

        total += packet.Read(node);
        total += packet.Read(count2);
        for(Byte j = 0; j < count2; j++)
        {
            Byte count3 = 0;
            Record record;
               
            total += packet.Read(record.mComponent);
            total += packet.Read(record.mInstance);
            total += packet.Read(count3);

            for(Byte k = 0; k < count3; k++)
            {
                Service::ID id;
                total += id.Read(packet);
                record.mServices.insert(id);
            }
            components.push_back(record);
        }
        mServices[node] = components;
    }

    return total;
}