Example #1
0
TimeAndDate GPS::getTimeAndDate(){
    TimeAndDate time_and_date;
    char c;
    while (waitForNextCharAvailable()){
        c = getNextChar();
        if(c == '$' && correctPrefix(GPRMC)){
            int i;
            char time_chars[6], date_chars[6];
            if(!skipCommas(1)) break;
            SixChars temp = getSixChars();
            for (i = 0; i < sizeof(time_chars) / sizeof(char); i++) time_chars[i] = temp.six_chars[i];
            if(time_chars[5] < 0) break;
            if(!areDigits(time_chars)) break;
            char temp1[] = {time_chars[0], time_chars[1]};
            time_and_date.hour = (uint8_t)parseToInt(temp1);
            char temp2[] = {time_chars[2], time_chars[3]};
            time_and_date.minute = (uint8_t)parseToInt(temp2);
            char temp3[] = {time_chars[4], time_chars[5]};
            time_and_date.second = (uint8_t)parseToInt(temp3);
            if(!skipCommas(8)) break;
            temp = getSixChars();
            for (i = 0; i < sizeof(date_chars) / sizeof(char); i++) date_chars[i] = temp.six_chars[i];
            if(date_chars[5] < 0) break;
            if(!areDigits(date_chars)) break;
            char temp4[] = {date_chars[0], date_chars[1]};
            time_and_date.day = (uint8_t)parseToInt(temp4);
            char temp5[] = {date_chars[2], date_chars[3]};
            time_and_date.month = (uint8_t)parseToInt(temp5);
            char temp6[] = {date_chars[4], date_chars[5]};
            time_and_date.year = (uint8_t)parseToInt(temp6);
            break;
        }
    }
    return time_and_date;
}
Example #2
0
void GdbMi::parseList(const char *&from, const char *to)
{
    //qDebug() << "parseList: " << QByteArray(from, to - from);
    QTC_CHECK(*from == '[');
    ++from;
    m_type = List;
    skipCommas(from, to);
    while (from < to) {
        if (*from == ']') {
            ++from;
            break;
        }
        GdbMi child;
        child.parseResultOrValue(from, to);
        if (child.isValid())
            m_children += child;
        skipCommas(from, to);
    }
}
Example #3
0
void GdbMi::parseTuple_helper(const char *&from, const char *to)
{
    skipCommas(from, to);
    //qDebug() << "parseTuple_helper: " << QByteArray(from, to - from);
    m_type = Tuple;
    while (from < to) {
        if (*from == '}') {
            ++from;
            break;
        }
        GdbMi child;
        child.parseResultOrValue(from, to);
        //qDebug() << "\n=======\n" << qPrintable(child.toString()) << "\n========\n";
        if (!child.isValid())
            return;
        m_children += child;
        skipCommas(from, to);
    }
}
Example #4
0
Location GPS::getLocation(){
    Location loc;
    char c;
    while (waitForNextCharAvailable()){
        c = getNextChar();
        if(c == '$' && correctPrefix(GPRMC)){
            bool available, is_north, is_west;
            char n_s, w_e;
            if(!skipCommas(2)) break;
            if(!waitForNextCharAvailable()) break;
            available = getNextChar() == 'A';
            if(!available) break;
            
            if(!skipCommas(1)) break;
            loc.latitude = getLatitudeOrLongitude();
            
            if(!waitForNextCharAvailable()) break;
            n_s = getNextChar();
            if (n_s == 'N') loc.n_s = NORTH;
            else if (n_s = 'S') loc.n_s = SOUTH;
            else break;
            
            if(!skipCommas(1)) break;
            loc.longitude = getLatitudeOrLongitude();
            
            if(!waitForNextCharAvailable()) break;
            w_e = getNextChar();
            if (w_e == 'W') loc.w_e = WEST;
            else if (w_e = 'E') loc.w_e = EAST;
            else break;
            
            break;
        }
    }
    return loc;
}
Example #5
0
TimeAndDate GPS::getDate(){
    TimeAndDate date;
    char c;
    while (waitForNextCharAvailable()){
        c = getNextChar();
        if(c == '$' && correctPrefix(GPRMC)){
            int i;
            char date_chars[6];
            if(!skipCommas(9)) break;
            SixChars temp = getSixChars();
            for (i = 0; i < sizeof(date_chars) / sizeof(char); i++) date_chars[i] = temp.six_chars[i];
            if(date_chars[5] < 0) break;
            if(!areDigits(date_chars)) break;
            char temp1[] = {date_chars[0], date_chars[1]};
            date.day = (uint8_t)parseToInt(temp1);
            char temp2[] = {date_chars[2], date_chars[3]};
            date.month = (uint8_t)parseToInt(temp2);
            char temp3[] = {date_chars[4], date_chars[5]};
            date.year = (uint8_t)parseToInt(temp3);
            break;
        }
    }
    return date;
}