如何将其更改为伪代码

时间:2011-05-16 13:07:50

标签: pseudocode

我接受了我的程序并缩写了一些部分。我还不确定它是否算作伪代码。在这里。

#include "mbed.h"

const int BUFFERSIZE = 1024;
int buffer[BUFFERSIZE];
int UTC[10];
int lat[10];
int ns;
int lon[10];
int ew;
int posfix;
int numsats[2];

Serial pc(p9, p10);
Serial gps(p13, p14);

int findStart(int pos)
{
    for(int i = pos; i < BUFFERSIZE; i++)
    {
        if buffer[pos to pos+5] == “$GP”
            return pos + 5;
        else
            return BUFFERSIZE;

    }
    return BUFFERSIZE;

}

bool code(int pos, char c[3])
{
    if(buffer[pos to pos + 2]==c)
        return true;
else
        return false;
    return false;
}

void loadVariables(int pos)
{
    assign variables based on relative position to pos
}

void displayVariables()
{ 
    for every variable
        print description + value;  
 }


void parsebuffer()
{
    int pos = 0; // current read position in the buffer

    while (pos < BUFFERSIZE - 1)
    {
        pos = findStart(pos);
        if(pos > BUFFERSIZE - 50) return;

        bool codeknown = true;
        if (found “GGA”)
        {

            pc.printf("Found GGA\r\n");
            loadVariables(pos+3);
            displayVariables();
        }
        else if (found “GLL”)
        {
            pc.printf("Found GLL\r\n");

        }
        else
            codeknown = false;

        if(!codeknown)
        print code found
    }
}

int main() {

    pc.baud(4800);
    pc.format(8,Serial::None,1);

    gps.baud(4800);
    gps.format(8,Serial::None,1);
    pc.putc(0x0c);

    while(1) {

        put data from GPS into array

        parsebuffer();
        pc.printf("\r\npress a key to continue\r\n");    
        pc.getc();
    }
}

1 个答案:

答案 0 :(得分:1)