Beispiel #1
0
static char get_choice() 
{
    fputs("Please Enter YOU CHOICE : ", stdout);
    char c = getchar();
    read_flush();
    return c;
}
Beispiel #2
0
int gps_autonegotiate_baud(gps_t *g, int guessbaud)
{
    int bauds[] = { 4800, 9600, 19200, 38400, 600, 1200, 2400, -1 };
    int baudidx = -1;

    uint8_t rpy[GPS_MESSAGE_MAXLEN + 1];
    rpy[GPS_MESSAGE_MAXLEN] = 0;

    while (1) {
        int baud;

        if (baudidx < 0)
            baud = guessbaud;
        else {
            if (bauds[baudidx] < 0)
                baudidx = 0;
            baud = bauds[baudidx];
        }

        printf("Trying %6d baud...", baud);
        fflush(NULL);

        // enable all output sentences
        gps_write_command(g, "$PGRMO,,3*");

        serial_setbaud(g->fd, baud);
        read_flush(g->fd);

        for (int i = 0; i < 4; i++) {
            int res = gps_readline(g, rpy, GPS_MESSAGE_MAXLEN);
            if (!res) {
                printf("GPS found!\n");
                return 0;
            }

            printf(".");
            fflush(NULL);
        }
        printf("\n");

        baudidx++;
    }

    // no luck
    return -1;
}
Beispiel #3
0
static void get_str(char *prompts, char *result) 
{
    fputs(prompts, stdout);
    fscanf(stdin, "%s", result);
    read_flush();
}