コード例 #1
0
int CQboduinoDriver::sendComand(std::string board, CComando& comand, std::vector<dataUnion>& response, std::vector<dataUnion>& data)
{
    response.clear();
    cereal::CerealPort *ser=boards_[board];
    long timeout=*timeouts_[board];
    ser->flush();
    std::string oud;
    if(comand.serialize(data, oud)<0)
        return -4;
    if(!write(ser,oud))
        return -5;
    std::string ind;
    if(!read(ser,ind,timeout))
        return -6;
    if(comand.deserialize(ind, response)<0)
    {
        return -7;
    }
    return 1;
}
コード例 #2
0
int CQboduinoDriver::sendCommand(std::string board, CComando& command, std::vector<dataUnion>& response, std::vector<dataUnion>& data)
{
    response.clear();
    cereal::CerealPort *port=boards_[board];
    long timeout=*timeouts_[board];
    port->flush();
    std::string oud;
    if(command.serialize(data, oud)<0)
        return -4; //data could not be serialized
    if(!write(port,oud))
        return -5; //data could not be writen on port
    std::string ind;
    if(!read(port,ind,timeout))
        return -6; //response could not be read
    if(command.deserialize(ind, response)<0)
    {
        return -7;//response could not be deserialized
    }
    return 1;
}