kopia lustrzana https://github.com/OpenRTX/OpenRTX
Update GPS test
rodzic
67195d178f
commit
2e0ac1b1f6
|
@ -40,6 +40,7 @@ int main()
|
|||
gps_init(9600);
|
||||
gps_enable();
|
||||
|
||||
int i = 0;
|
||||
while(1)
|
||||
{
|
||||
int len = gps_getNmeaSentence(line, MINMEA_MAX_LENGTH*10);
|
||||
|
@ -47,90 +48,78 @@ int main()
|
|||
{
|
||||
printf("Got sentence with length %d:\r\n", len);
|
||||
printf("%s\r\n", line);
|
||||
switch (minmea_sentence_id(line, false)) {
|
||||
case MINMEA_SENTENCE_RMC:
|
||||
{
|
||||
struct minmea_sentence_rmc frame;
|
||||
if (minmea_parse_rmc(&frame, line)) {
|
||||
printf("$RMC: raw coordinates and speed: (%d/%d,%d/%d) %d/%d\n\r",
|
||||
frame.latitude.value, frame.latitude.scale,
|
||||
frame.longitude.value, frame.longitude.scale,
|
||||
frame.speed.value, frame.speed.scale);
|
||||
printf("$RMC fixed-point coordinates and speed scaled to three decimal places: (%d,%d) %d\n\r",
|
||||
minmea_rescale(&frame.latitude, 1000),
|
||||
minmea_rescale(&frame.longitude, 1000),
|
||||
minmea_rescale(&frame.speed, 1000));
|
||||
printf("$RMC floating point degree coordinates and speed: (%f,%f) %f\n\r",
|
||||
minmea_tocoord(&frame.latitude),
|
||||
minmea_tocoord(&frame.longitude),
|
||||
minmea_tofloat(&frame.speed));
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
// int i = 0;
|
||||
// while(1)
|
||||
// {
|
||||
// while((USART3->SR & USART_SR_RXNE) == 0) ;
|
||||
// line[i++] = USART3->DR;
|
||||
// // If a NMEA sentence is complete
|
||||
// if (line[i - 1] == '\n') {
|
||||
// line[i] = '\0';
|
||||
// printf("%s\n\r", line);
|
||||
// switch (minmea_sentence_id(line, false)) {
|
||||
// case MINMEA_SENTENCE_RMC:
|
||||
// {
|
||||
// struct minmea_sentence_rmc frame;
|
||||
// if (minmea_parse_rmc(&frame, line)) {
|
||||
// printf("$RMC: raw coordinates and speed: (%d/%d,%d/%d) %d/%d\n\r",
|
||||
// frame.latitude.value, frame.latitude.scale,
|
||||
// frame.longitude.value, frame.longitude.scale,
|
||||
// frame.speed.value, frame.speed.scale);
|
||||
// printf("$RMC fixed-point coordinates and speed scaled to three decimal places: (%d,%d) %d\n\r",
|
||||
// minmea_rescale(&frame.latitude, 1000),
|
||||
// minmea_rescale(&frame.longitude, 1000),
|
||||
// minmea_rescale(&frame.speed, 1000));
|
||||
// printf("$RMC floating point degree coordinates and speed: (%f,%f) %f\n\r",
|
||||
// minmea_tocoord(&frame.latitude),
|
||||
// minmea_tocoord(&frame.longitude),
|
||||
// minmea_tofloat(&frame.speed));
|
||||
// }
|
||||
// } break;
|
||||
//
|
||||
// case MINMEA_SENTENCE_GGA:
|
||||
// {
|
||||
// struct minmea_sentence_gga frame;
|
||||
// if (minmea_parse_gga(&frame, line)) {
|
||||
// printf("$GGA: fix quality: %d\n\r", frame.fix_quality);
|
||||
// }
|
||||
// } break;
|
||||
//
|
||||
// case MINMEA_SENTENCE_GSV:
|
||||
// {
|
||||
// struct minmea_sentence_gsv frame;
|
||||
// if (minmea_parse_gsv(&frame, line)) {
|
||||
// printf("$GSV: message %d of %d\n\r", frame.msg_nr, frame.total_msgs);
|
||||
// printf("$GSV: satellites in view: %d\n\r", frame.total_sats);
|
||||
// for (int i = 0; i < 4; i++)
|
||||
// printf("$GSV: sat nr %d, elevation: %d, azimuth: %d, snr: %d dbm\n\r",
|
||||
// frame.sats[i].nr,
|
||||
// frame.sats[i].elevation,
|
||||
// frame.sats[i].azimuth,
|
||||
// frame.sats[i].snr);
|
||||
// }
|
||||
// } break;
|
||||
//
|
||||
// case MINMEA_SENTENCE_VTG:
|
||||
// {
|
||||
//
|
||||
// } break;
|
||||
//
|
||||
// // Ignore this message as we take data from RMC
|
||||
// case MINMEA_SENTENCE_GLL:
|
||||
// ;
|
||||
// break;
|
||||
//
|
||||
// // These messages are never sent by the Jumpstar JS-M710 Module
|
||||
// case MINMEA_SENTENCE_GSA: break;
|
||||
// case MINMEA_SENTENCE_GST: break;
|
||||
// case MINMEA_SENTENCE_ZDA: break;
|
||||
//
|
||||
// // Error handling
|
||||
// case MINMEA_INVALID:
|
||||
// {
|
||||
// printf("Error: Invalid NMEA sentence!\n\r");
|
||||
// } break;
|
||||
//
|
||||
// case MINMEA_UNKNOWN:
|
||||
// {
|
||||
// printf("Error: Unsupported NMEA sentence!\n\r");
|
||||
// } break;
|
||||
// }
|
||||
// i = 0;
|
||||
// }
|
||||
// }
|
||||
case MINMEA_SENTENCE_GGA:
|
||||
{
|
||||
struct minmea_sentence_gga frame;
|
||||
if (minmea_parse_gga(&frame, line)) {
|
||||
printf("$GGA: fix quality: %d\n\r", frame.fix_quality);
|
||||
}
|
||||
} break;
|
||||
|
||||
case MINMEA_SENTENCE_GSV:
|
||||
{
|
||||
struct minmea_sentence_gsv frame;
|
||||
if (minmea_parse_gsv(&frame, line)) {
|
||||
printf("$GSV: message %d of %d\n\r", frame.msg_nr, frame.total_msgs);
|
||||
printf("$GSV: satellites in view: %d\n\r", frame.total_sats);
|
||||
for (int i = 0; i < 4; i++)
|
||||
printf("$GSV: sat nr %d, elevation: %d, azimuth: %d, snr: %d dbm\n\r",
|
||||
frame.sats[i].nr,
|
||||
frame.sats[i].elevation,
|
||||
frame.sats[i].azimuth,
|
||||
frame.sats[i].snr);
|
||||
}
|
||||
} break;
|
||||
|
||||
case MINMEA_SENTENCE_VTG:
|
||||
{
|
||||
|
||||
} break;
|
||||
|
||||
// Ignore this message as we take data from RMC
|
||||
case MINMEA_SENTENCE_GLL:
|
||||
;
|
||||
break;
|
||||
|
||||
// These messages are never sent by the Jumpstar JS-M710 Module
|
||||
case MINMEA_SENTENCE_GSA: break;
|
||||
case MINMEA_SENTENCE_GST: break;
|
||||
case MINMEA_SENTENCE_ZDA: break;
|
||||
|
||||
// Error handling
|
||||
case MINMEA_INVALID:
|
||||
{
|
||||
printf("Error: Invalid NMEA sentence!\n\r");
|
||||
} break;
|
||||
|
||||
case MINMEA_UNKNOWN:
|
||||
{
|
||||
printf("Error: Unsupported NMEA sentence!\n\r");
|
||||
} break;
|
||||
}
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue