output only raw data (acceleration, anguler rate, geomagnetism, air pressure)

Dependencies:   mbed SDFileSystem ConfigFile

Committer:
ojan
Date:
Thu Aug 06 15:45:48 2015 +0000
Revision:
34:4bda9af9a0cd
Parent:
16:174daf81eea0
LAURUS_Program_v2.9.0; ; + add RULE3_1; + add "volatile" to some variables like "flag"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ojan 1:6cd6d2760856 1 #include "mbed.h"
ojan 1:6cd6d2760856 2 #include "GMS6_CR6.h"
ojan 1:6cd6d2760856 3
ojan 1:6cd6d2760856 4 GMS6_CR6::GMS6_CR6(Serial* ps, Serial* pc): p_port(ps), p_pc(pc) {
ojan 1:6cd6d2760856 5 p_port->baud(4800);
ojan 1:6cd6d2760856 6 pointer = 0;
ojan 1:6cd6d2760856 7 INT_flag = 0;
ojan 1:6cd6d2760856 8 p_port->attach(this, &GMS6_CR6::INT_Rx, Serial::RxIrq);
ojan 1:6cd6d2760856 9 }
ojan 1:6cd6d2760856 10
ojan 1:6cd6d2760856 11 GMS6_CR6::~GMS6_CR6() {
ojan 1:6cd6d2760856 12 p_port = NULL;
ojan 1:6cd6d2760856 13 }
ojan 1:6cd6d2760856 14
ojan 1:6cd6d2760856 15 void GMS6_CR6::read() {
ojan 1:6cd6d2760856 16 while(INT_flag);
ojan 1:6cd6d2760856 17 int ret = sscanf(buff2, "$GPGGA,%f,%f,%c,%f,%c,%d,%d",
ojan 4:45dc5590abc0 18 &time, &raw_latitude, &lat_hem, &raw_longitude, &lng_hem, &mode, &Ns);
ojan 1:6cd6d2760856 19 if(!ret) {
ojan 1:6cd6d2760856 20 p_pc->printf("sscanf Error\r\n");
ojan 1:6cd6d2760856 21 return;
ojan 1:6cd6d2760856 22 }
ojan 1:6cd6d2760856 23
ojan 1:6cd6d2760856 24 int deg_lat = (int)raw_latitude / 100;
ojan 1:6cd6d2760856 25 float min_lat = (raw_latitude - (float)(deg_lat*100)) / 60.0f;
ojan 1:6cd6d2760856 26 latitude = (float)deg_lat + min_lat;
ojan 1:6cd6d2760856 27
ojan 1:6cd6d2760856 28 int deg_lng = (int)raw_longitude / 100;
ojan 1:6cd6d2760856 29 float min_lng = (raw_longitude - (float)(deg_lng*100)) / 60.0f;
ojan 1:6cd6d2760856 30 longitude = (float)deg_lng + min_lng;
ojan 1:6cd6d2760856 31
ojan 1:6cd6d2760856 32
ojan 1:6cd6d2760856 33 }
ojan 1:6cd6d2760856 34
ojan 1:6cd6d2760856 35 void GMS6_CR6::INT_Rx() {
onaka 16:174daf81eea0 36 char *sp;
ojan 1:6cd6d2760856 37 buff1[pointer] = p_port->getc();
ojan 1:6cd6d2760856 38
ojan 1:6cd6d2760856 39 if(buff1[pointer] != '\r') {
onaka 16:174daf81eea0 40 if(pointer<(BuffSize-1)){
onaka 16:174daf81eea0 41 pointer = pointer+1;
onaka 16:174daf81eea0 42 }
ojan 1:6cd6d2760856 43 } else {
onaka 16:174daf81eea0 44 if((sp=strstr(buff1, "$GPGGA")) != NULL) {
ojan 1:6cd6d2760856 45 buff1[pointer] = '\0';
ojan 1:6cd6d2760856 46 INT_flag = 1;
onaka 16:174daf81eea0 47 strcpy(buff2, sp);
ojan 1:6cd6d2760856 48 INT_flag = 0;
ojan 1:6cd6d2760856 49 }
onaka 16:174daf81eea0 50 pointer = 0;
ojan 1:6cd6d2760856 51 }
ojan 1:6cd6d2760856 52 }