GPGSA support: fix indentation
This commit is contained in:
parent
da55e342e3
commit
a04115b3f4
99
minmea.c
99
minmea.c
@ -335,63 +335,56 @@ bool minmea_parse_gpgga(struct minmea_gpgga *frame, const char *sentence)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool minmea_parse_gpgsa(struct minmea_gpgsa *frame, const char *sentence){
|
bool minmea_parse_gpgsa(struct minmea_gpgsa *frame, const char *sentence)
|
||||||
// $GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39
|
{
|
||||||
char type[6];
|
// $GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39
|
||||||
|
char type[6];
|
||||||
|
|
||||||
if (!minmea_scan(sentence, "tciiiiiiiiiiiiifff",
|
if (!minmea_scan(sentence, "tciiiiiiiiiiiiifff",
|
||||||
type,
|
type,
|
||||||
&frame->mode,
|
&frame->mode,
|
||||||
&frame->fix_type,
|
&frame->fix_type,
|
||||||
&frame->sat1,
|
&frame->sat1,
|
||||||
&frame->sat2,
|
&frame->sat2,
|
||||||
&frame->sat3,
|
&frame->sat3,
|
||||||
&frame->sat4,
|
&frame->sat4,
|
||||||
&frame->sat5,
|
&frame->sat5,
|
||||||
&frame->sat6,
|
&frame->sat6,
|
||||||
&frame->sat7,
|
&frame->sat7,
|
||||||
&frame->sat8,
|
&frame->sat8,
|
||||||
&frame->sat9,
|
&frame->sat9,
|
||||||
&frame->sat10,
|
&frame->sat10,
|
||||||
&frame->sat11,
|
&frame->sat11,
|
||||||
&frame->sat12,
|
&frame->sat12,
|
||||||
&frame->pdop,
|
&frame->pdop,
|
||||||
&frame->pdop_scale,
|
&frame->pdop_scale,
|
||||||
&frame->hdop,
|
&frame->hdop,
|
||||||
&frame->hdop_scale,
|
&frame->hdop_scale,
|
||||||
&frame->vdop,
|
&frame->vdop,
|
||||||
&frame->vdop_scale
|
&frame->vdop_scale
|
||||||
)){
|
)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (strcmp(type, "GPGSA")){
|
if (strcmp(type, "GPGSA"))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if(frame->mode == 'A'){
|
if (frame->mode == 'A')
|
||||||
frame->mode = GPGSA_MODE_AUTO;
|
frame->mode = GPGSA_MODE_AUTO;
|
||||||
}
|
else if (frame->mode == 'M')
|
||||||
else if(frame->mode == 'M'){
|
frame->mode = GPGSA_MODE_FORCED;
|
||||||
frame->mode = GPGSA_MODE_FORCED;
|
else
|
||||||
}
|
return false;
|
||||||
else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(frame->fix_type == 1){
|
if (frame->fix_type == 1)
|
||||||
frame->fix_type = GPGSA_FIX_NONE;
|
frame->fix_type = GPGSA_FIX_NONE;
|
||||||
}
|
else if (frame->fix_type == 2)
|
||||||
else if(frame->fix_type == 2){
|
frame->fix_type = GPGSA_FIX_2D;
|
||||||
frame->fix_type = GPGSA_FIX_2D;
|
else if (frame->fix_type == 3)
|
||||||
}
|
frame->fix_type = GPGSA_FIX_3D;
|
||||||
else if(frame->fix_type == 3){
|
else
|
||||||
frame->fix_type = GPGSA_FIX_3D;
|
return false;
|
||||||
}
|
|
||||||
else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int minmea_gettimeofday(struct timeval *tv, const struct minmea_date *date, const struct minmea_time *time)
|
int minmea_gettimeofday(struct timeval *tv, const struct minmea_date *date, const struct minmea_time *time)
|
||||||
|
38
minmea.h
38
minmea.h
@ -67,31 +67,31 @@ struct minmea_gpgga {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum minmea_gpgsa_mode {
|
enum minmea_gpgsa_mode {
|
||||||
GPGSA_MODE_AUTO,
|
GPGSA_MODE_AUTO,
|
||||||
GPGSA_MODE_FORCED
|
GPGSA_MODE_FORCED
|
||||||
};
|
};
|
||||||
|
|
||||||
enum minmea_gpgsa_fix_type {
|
enum minmea_gpgsa_fix_type {
|
||||||
GPGSA_FIX_NONE,
|
GPGSA_FIX_NONE,
|
||||||
GPGSA_FIX_2D,
|
GPGSA_FIX_2D,
|
||||||
GPGSA_FIX_3D
|
GPGSA_FIX_3D
|
||||||
};
|
};
|
||||||
|
|
||||||
struct minmea_gpgsa {
|
struct minmea_gpgsa {
|
||||||
int mode;
|
int mode;
|
||||||
int fix_type;
|
int fix_type;
|
||||||
int sat1;
|
int sat1;
|
||||||
int sat2;
|
int sat2;
|
||||||
int sat3;
|
int sat3;
|
||||||
int sat4;
|
int sat4;
|
||||||
int sat5;
|
int sat5;
|
||||||
int sat6;
|
int sat6;
|
||||||
int sat7;
|
int sat7;
|
||||||
int sat8;
|
int sat8;
|
||||||
int sat9;
|
int sat9;
|
||||||
int sat10;
|
int sat10;
|
||||||
int sat11;
|
int sat11;
|
||||||
int sat12;
|
int sat12;
|
||||||
int pdop, pdop_scale;
|
int pdop, pdop_scale;
|
||||||
int hdop, hdop_scale;
|
int hdop, hdop_scale;
|
||||||
int vdop, vdop_scale;
|
int vdop, vdop_scale;
|
||||||
|
40
tests.c
40
tests.c
@ -337,26 +337,26 @@ START_TEST(test_minmea_parse_gpgsa1)
|
|||||||
const char *sentence = "$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39";
|
const char *sentence = "$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39";
|
||||||
struct minmea_gpgsa frame = {};
|
struct minmea_gpgsa frame = {};
|
||||||
struct minmea_gpgsa expected = {
|
struct minmea_gpgsa expected = {
|
||||||
.mode = GPGSA_MODE_AUTO,
|
.mode = GPGSA_MODE_AUTO,
|
||||||
.fix_type = GPGSA_FIX_3D,
|
.fix_type = GPGSA_FIX_3D,
|
||||||
.sat1 = 4,
|
.sat1 = 4,
|
||||||
.sat2 = 5,
|
.sat2 = 5,
|
||||||
.sat3 = 0,
|
.sat3 = 0,
|
||||||
.sat4 = 9,
|
.sat4 = 9,
|
||||||
.sat5 = 12,
|
.sat5 = 12,
|
||||||
.sat6 = 0,
|
.sat6 = 0,
|
||||||
.sat7 = 0,
|
.sat7 = 0,
|
||||||
.sat8 = 24,
|
.sat8 = 24,
|
||||||
.sat9 = 0,
|
.sat9 = 0,
|
||||||
.sat10 = 0,
|
.sat10 = 0,
|
||||||
.sat11 = 0,
|
.sat11 = 0,
|
||||||
.sat12 = 0,
|
.sat12 = 0,
|
||||||
.pdop = 25,
|
.pdop = 25,
|
||||||
.pdop_scale = 10,
|
.pdop_scale = 10,
|
||||||
.hdop = 13,
|
.hdop = 13,
|
||||||
.hdop_scale = 10,
|
.hdop_scale = 10,
|
||||||
.vdop = 21,
|
.vdop = 21,
|
||||||
.vdop_scale = 10
|
.vdop_scale = 10
|
||||||
};
|
};
|
||||||
ck_assert(minmea_check(sentence) == true);
|
ck_assert(minmea_check(sentence) == true);
|
||||||
ck_assert(minmea_parse_gpgsa(&frame, sentence) == true);
|
ck_assert(minmea_parse_gpgsa(&frame, sentence) == true);
|
||||||
|
Loading…
Reference in New Issue
Block a user