-/* 0x08 - nema interval */
-#define M_NEMAINTERVAL 0x08
+/* 0x08 - nmea interval */
+#define M_NMEAINTERVAL 0x08
typedef struct {
uint8_t gga;
uint8_t gsa;
1 - flash
*/
-} m_nemainterval_t;
+} m_nmeainterval_t;
/* 0x09 - Query Software Version */
typedef struct {
uint8_t msg_type; /*
00 = no output
- 01 = nema output
+ 01 = nmea output
02 = binary output
*/
} m_output_t;
memset(&rate,0,sizeof(m_rate_t));
rate.rate = 20;
- //rate.rate = 0; /* ram */
+ rate.attributes = 0; /* ram */
venus634_send(M_RATE,&rate,sizeof(m_rate_t));
return;
}
+/* Wide Area Augmentation System: use ground stations to increase the precision
+ * of gps position */
void venus634_waas(void)
{
m_waas_t waas;
return;
}
-
+/* Tell we are a car instead of a pedestrian */
void venus634_navmode(void)
{
m_navmode_t navmode;
return;
}
-
-void venus634_nema_interval(void)
+/* frequency of NMEA messages */
+void venus634_nmea_interval(void)
{
- m_nemainterval_t nemainterval;
+ m_nmeainterval_t nmeainterval;
+
+ memset(&nmeainterval,0,sizeof(m_nmeainterval_t));
- memset(&nemainterval,0,sizeof(m_nemainterval_t));
- nemainterval.gga = 1;
- nemainterval.gsa = 1;
- nemainterval.gsv = 1;
- nemainterval.gll = 1;
- nemainterval.rmc = 1;
- nemainterval.vtg = 1;
- nemainterval.zda = 1;
+ /* set frequency for nmea: 1 = once every one position fix, 2 = once
+ * every two position fix, ... */
+ nmeainterval.gga = 1; /* GPGGA interval - GPS Fix Data*/
+ nmeainterval.gsa = 1; /* GNSS DOPS and Active Satellites */
+ nmeainterval.gsv = 1; /* GNSS Satellites in View */
+ nmeainterval.gll = 1; /* Geographic Position - Latitude longitude */
+ nmeainterval.rmc = 1; /* Recomended Minimum Specific GNSS Sentence */
+ nmeainterval.vtg = 1; /* Course Over Ground and Ground Speed */
+ nmeainterval.zda = 1; /* Time & Date*/
- nemainterval.attributes = 1; /* ram flash */
+ nmeainterval.attributes = 1; /* ram flash */
- venus634_send(M_NEMAINTERVAL,&nemainterval,sizeof(m_nemainterval_t));
+ venus634_send(M_NMEAINTERVAL,&nmeainterval,sizeof(m_nmeainterval_t));
return;
}
static int decode_gps_pos(uint8_t *buf, uint16_t len)
{
struct gps_pos *pos = (struct gps_pos *)buf;
+ uint8_t irq_flags;
if (len != sizeof(*pos))
return -1;
+ if (pos->msg_id != 0xA8) /* XXX not tested */
+ return -1;
+
gps_pos.gps_week = ntohs(pos->gps_week);
gps_pos.tow = ntohl(pos->tow);
gps_pos.ecef_vy = ntohl(pos->ecef_vy);
gps_pos.ecef_vz = ntohl(pos->ecef_vz);
+ /* update global structure */
+ IRQ_LOCK(irq_flags);
+ memcpy(&gps_pos, pos, sizeof(gps_pos));
+ IRQ_UNLOCK(irq_flags);
+
return 0;
}
int gps_loop(void)
{
- struct fat_file_struct *fd = NULL;
uint32_t ms;
uint8_t flags, prio;
int16_t len;
char buf[128];
struct gps_pos pos;
- fd = get_log_file();
-
while (1) {
IRQ_LOCK(flags);
(double)gps_pos.sea_altitude/100.);
- if (fd != NULL) {
+ if (sd_log_enabled()) {
- if (fat_write_file(fd, (unsigned char *)buf, len) != len) {
+ if (sd_log_write(buf, len) != len) {
printf_P(PSTR("error writing to file\n"));
return -1;
}
}
+ else
+ printf("%s", buf);
+
}
return 0;