Code style fixes, no code changes

This commit is contained in:
Lorenz Meier
2014-10-07 12:52:48 +02:00
parent cebdae438d
commit 4ba4135c3b
2 changed files with 96 additions and 82 deletions
+4 -3
View File
@@ -8,7 +8,8 @@
#include <drivers/sf0x/sf0x_parser.h> #include <drivers/sf0x/sf0x_parser.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[])
{
warnx("SF0X test started"); warnx("SF0X test started");
int ret = 0; int ret = 0;
@@ -46,14 +47,14 @@ int main(int argc, char *argv[]) {
int parse_ret; int parse_ret;
for (int i = 0; i < strlen(lines[l]); i++) for (int i = 0; i < strlen(lines[l]); i++) {
{
parse_ret = sf0x_parser(lines[l][i], _parserbuf, &_parsebuf_index, &state, &dist_m); parse_ret = sf0x_parser(lines[l][i], _parserbuf, &_parsebuf_index, &state, &dist_m);
if (parse_ret == 0) { if (parse_ret == 0) {
printf("\nparsed: %f %s\n", dist_m, (parse_ret == 0) ? "OK" : ""); printf("\nparsed: %f %s\n", dist_m, (parse_ret == 0) ? "OK" : "");
} }
} }
printf("%s", lines[l]); printf("%s", lines[l]);
} }
+14 -1
View File
@@ -47,7 +47,7 @@
#ifdef SF0X_DEBUG #ifdef SF0X_DEBUG
#include <stdio.h> #include <stdio.h>
const char* parser_state[] = { const char *parser_state[] = {
"0_UNSYNC", "0_UNSYNC",
"1_SYNC", "1_SYNC",
"2_GOT_DIGIT0", "2_GOT_DIGIT0",
@@ -69,6 +69,7 @@ int sf0x_parser(char c, char *parserbuf, unsigned *parserbuf_index, enum SF0X_PA
*state = SF0X_PARSE_STATE1_SYNC; *state = SF0X_PARSE_STATE1_SYNC;
(*parserbuf_index) = 0; (*parserbuf_index) = 0;
} }
break; break;
case SF0X_PARSE_STATE1_SYNC: case SF0X_PARSE_STATE1_SYNC:
@@ -77,6 +78,7 @@ int sf0x_parser(char c, char *parserbuf, unsigned *parserbuf_index, enum SF0X_PA
parserbuf[*parserbuf_index] = c; parserbuf[*parserbuf_index] = c;
(*parserbuf_index)++; (*parserbuf_index)++;
} }
break; break;
case SF0X_PARSE_STATE2_GOT_DIGIT0: case SF0X_PARSE_STATE2_GOT_DIGIT0:
@@ -84,13 +86,16 @@ int sf0x_parser(char c, char *parserbuf, unsigned *parserbuf_index, enum SF0X_PA
*state = SF0X_PARSE_STATE2_GOT_DIGIT0; *state = SF0X_PARSE_STATE2_GOT_DIGIT0;
parserbuf[*parserbuf_index] = c; parserbuf[*parserbuf_index] = c;
(*parserbuf_index)++; (*parserbuf_index)++;
} else if (c == '.') { } else if (c == '.') {
*state = SF0X_PARSE_STATE3_GOT_DOT; *state = SF0X_PARSE_STATE3_GOT_DOT;
parserbuf[*parserbuf_index] = c; parserbuf[*parserbuf_index] = c;
(*parserbuf_index)++; (*parserbuf_index)++;
} else { } else {
*state = SF0X_PARSE_STATE0_UNSYNC; *state = SF0X_PARSE_STATE0_UNSYNC;
} }
break; break;
case SF0X_PARSE_STATE3_GOT_DOT: case SF0X_PARSE_STATE3_GOT_DOT:
@@ -98,9 +103,11 @@ int sf0x_parser(char c, char *parserbuf, unsigned *parserbuf_index, enum SF0X_PA
*state = SF0X_PARSE_STATE4_GOT_DIGIT1; *state = SF0X_PARSE_STATE4_GOT_DIGIT1;
parserbuf[*parserbuf_index] = c; parserbuf[*parserbuf_index] = c;
(*parserbuf_index)++; (*parserbuf_index)++;
} else { } else {
*state = SF0X_PARSE_STATE0_UNSYNC; *state = SF0X_PARSE_STATE0_UNSYNC;
} }
break; break;
case SF0X_PARSE_STATE4_GOT_DIGIT1: case SF0X_PARSE_STATE4_GOT_DIGIT1:
@@ -108,17 +115,21 @@ int sf0x_parser(char c, char *parserbuf, unsigned *parserbuf_index, enum SF0X_PA
*state = SF0X_PARSE_STATE5_GOT_DIGIT2; *state = SF0X_PARSE_STATE5_GOT_DIGIT2;
parserbuf[*parserbuf_index] = c; parserbuf[*parserbuf_index] = c;
(*parserbuf_index)++; (*parserbuf_index)++;
} else { } else {
*state = SF0X_PARSE_STATE0_UNSYNC; *state = SF0X_PARSE_STATE0_UNSYNC;
} }
break; break;
case SF0X_PARSE_STATE5_GOT_DIGIT2: case SF0X_PARSE_STATE5_GOT_DIGIT2:
if (c == '\r') { if (c == '\r') {
*state = SF0X_PARSE_STATE6_GOT_CARRIAGE_RETURN; *state = SF0X_PARSE_STATE6_GOT_CARRIAGE_RETURN;
} else { } else {
*state = SF0X_PARSE_STATE0_UNSYNC; *state = SF0X_PARSE_STATE0_UNSYNC;
} }
break; break;
case SF0X_PARSE_STATE6_GOT_CARRIAGE_RETURN: case SF0X_PARSE_STATE6_GOT_CARRIAGE_RETURN:
@@ -128,9 +139,11 @@ int sf0x_parser(char c, char *parserbuf, unsigned *parserbuf_index, enum SF0X_PA
*state = SF0X_PARSE_STATE1_SYNC; *state = SF0X_PARSE_STATE1_SYNC;
*parserbuf_index = 0; *parserbuf_index = 0;
ret = 0; ret = 0;
} else { } else {
*state = SF0X_PARSE_STATE0_UNSYNC; *state = SF0X_PARSE_STATE0_UNSYNC;
} }
break; break;
} }