Exemplo n.º 1
0
bool C_sendingBuffer::read(yarp::os::ConnectionReader& connection)
{
	connection.convertTextMode(); // if connection is text-mode, convert!
	int tag = connection.expectInt();
	if (tag!=BOTTLE_TAG_LIST+BOTTLE_TAG_BLOB+BOTTLE_TAG_INT)
		return false;
	int ct = connection.expectInt();
	if (ct!=2)
		return false;
	size_of_the_packet = connection.expectInt();
	connection.expectBlock(packet, SIZE_OF_DATA);
	return true;
}
Exemplo n.º 2
0
bool eventBuffer::read(yarp::os::ConnectionReader& connection)
{
    connection.convertTextMode();   // if connection is text-mode, convert!
    int tag = connection.expectInt();
    if (tag != BOTTLE_TAG_LIST+BOTTLE_TAG_BLOB+BOTTLE_TAG_INT)
        return false;
    int ct = connection.expectInt();
    if (ct!=2)
        return false;
    size_of_the_packet = connection.expectInt();
    int ceilSizeOfPacket = (size_of_the_packet+7)/8*8; // the nearest multiple of 8 greater or equal to size_of_the_packet
    memset(packet, 0, SIZE_OF_DATA);
    connection.expectBlock(packet, ceilSizeOfPacket);
    return true;
}
Exemplo n.º 3
0
bool SystemInfoSerializer::read(yarp::os::ConnectionReader& connection)
{
    // reading memory
    memory.totalSpace = connection.expectInt();
    memory.freeSpace = connection.expectInt();

    // reading storage
    storage.totalSpace = connection.expectInt();
    storage.freeSpace = connection.expectInt();

    // reading network
    //network.mac = connection.expectText();
    //network.ip4 = connection.expectText();
    //network.ip6 = connection.expectText();
    
    // reading processor
    processor.architecture = connection.expectText();
    processor.model = connection.expectText();
    processor.vendor = connection.expectText();
    processor.family = connection.expectInt();
    processor.modelNumber = connection.expectInt();
    processor.cores = connection.expectInt();
    processor.siblings = connection.expectInt();
    processor.frequency = connection.expectDouble();

    // reading load
    load.cpuLoad1 = connection.expectDouble();
    load.cpuLoad5 = connection.expectDouble();
    load.cpuLoad15 = connection.expectDouble();
    load.cpuLoadInstant = connection.expectInt();

    // reading platform
    platform.name = connection.expectText();
    platform.distribution = connection.expectText();
    platform.release = connection.expectText();
    platform.codename = connection.expectText();
    platform.kernel = connection.expectText();
    platform.environmentVars.fromString(connection.expectText());

    // reading user
    user.userName = connection.expectText();
    user.realName = connection.expectText();
    user.homeDir = connection.expectText();
    user.userID = connection.expectInt();
    return true;
}
Exemplo n.º 4
0
bool eventBottle::read(yarp::os::ConnectionReader& connection) {
    connection.convertTextMode();   // if connection is text-mode, convert!
    int tag = connection.expectInt();
    if (tag != BOTTLE_TAG_LIST + BOTTLE_TAG_BLOB + BOTTLE_TAG_INT) {
       return false;
    }
    int ct = connection.expectInt();
    if (ct!=2) {
        return false;
    }
    bytes_of_the_packet = connection.expectInt();
    size_of_the_packet = bytes_of_the_packet / wordDimension;      // number of 32 bit word times 4bytes
    connection.expectBlock(packetPointer,bytes_of_the_packet);

    //printf(" eventBottle::read:size_of_the_packet %d bytes_of_the_packet %d \n", size_of_the_packet, bytes_of_the_packet);


    // ---------------------------------------------------------------------------------------------------------
    // ------------------------ deserialisation of the bottle -------------------------------------
    //printf("bytes of the packet %d \n",bytes_of_the_packet );
    int word;
    char* i_data  = packetPointer;
    packet->clear(); // clear the bottle before any other adding

    unsigned char tmpChar;
    for(int i = 0 ; i < bytes_of_the_packet;) {
        word = 0;
        for (int j = 0 ; j < 4 ; j++){
            tmpChar = (unsigned char) *i_data;
            //printf("%02x ", *i_data );
            int value =  tmpChar << (8 * j);
            word = word | value;
            i_data++;
            i++;
        }
        packet->addInt(word);
        //printf("= %08x \n", word);

    }

    //----------------------------------------------------------------------------------------------------------

    //packet->fromBinary(packetPointer,bytes_of_the_packet);
    size_of_the_bottle = packet->size();
    return true;
}
Exemplo n.º 5
0
bool MapGrid2D::read(yarp::os::ConnectionReader& connection)
{
    // auto-convert text mode interaction
    connection.convertTextMode();

    connection.expectInt();
    connection.expectInt();

    connection.expectInt();
    m_width = connection.expectInt();
    connection.expectInt();
    m_height = connection.expectInt();
    connection.expectInt();
    m_origin.x = connection.expectDouble();
    connection.expectInt();
    m_origin.y = connection.expectDouble();
    connection.expectInt();
    m_origin.theta = connection.expectDouble();
    connection.expectInt();
    m_resolution = connection.expectDouble();
    connection.expectInt();
    int siz = connection.expectInt();
    char buff[255]; memset(buff, 0, 255);
    connection.expectBlock((char*)buff, siz);
    m_map_name = buff;
    m_map_occupancy.resize(m_width, m_height);
    m_map_flags.resize(m_width, m_height);
    bool ok = true;
    unsigned char *mem = nullptr;
    int            memsize = 0;
    connection.expectInt();
    memsize = connection.expectInt();
    if (memsize != m_map_occupancy.getRawImageSize()) { return false; }
    mem = m_map_occupancy.getRawImage();
    ok &= connection.expectBlock((char*)mem, memsize);
    connection.expectInt();
    memsize = connection.expectInt();
    if (memsize != m_map_flags.getRawImageSize()) { return false; }
    mem = m_map_flags.getRawImage();
    ok &= connection.expectBlock((char*)mem, memsize);
    if (!ok) return false;

    return !connection.isError();
        return true;
}