Exemple #1
0
void newData(void){
    char c;
    
    while (zender.readable()) {
        c = zender.getc();
        if (state["echo"])
            zender.putc(c);
        
         
        
        if (c == '$') {
            buffer.clear();            
        }   
        
        else if (c == '#'){
            if (state["echo"])
                zender.printf("\n\r");
            
            std::vector<std::string> commands = split(buffer);
            
            if (commands[0] == "get" && commands.size() >= 2)
                zender.printf("%f \n\r", state[commands[1]]);
                
            else if (commands[0] == "set" && commands.size() >= 3){
                if (commands[2] == "True")
                    updateable[commands[1]] = 1;
                else if (commands[2] == "False")
                    updateable[commands[1]] = 0;
                else{    
                    float n;
                    sscanf(commands[2].c_str(),"%f",&n);
                    updateable[commands[1]] = n;
               }
            }
            else if (commands[0] == "route_set"){
                route.update(commands);
            }
            else if (commands[0] == "route_get"){
                zender.printf("%s\n\r", route.lees().c_str() );
            }
            else if (commands[0] == "gps_gga"){
                zender.printf("%s\n\r", gps.getgga().c_str() );
            }
        }
        else
            buffer += c;           
        
               

   }
}