2017年伊豆大島共同打ち上げ実験用電装モジュール搭載GPS測位プログラム
Dependents: Hybrid_interruptGPS Hybrid_main_FirstEdtion rocket_logger_sinkan2018_v1 HYBRYD2018_IZU_ROCKET ... more
GPS_interrupt.h
- Committer:
- Gaku0606
- Date:
- 2017-01-02
- Revision:
- 2:7be89bab6db9
- Parent:
- 1:57eeee14dd31
- Child:
- 3:8e66ec281888
File content as of revision 2:7be89bab6db9:
/*============================================================================= * GPS_interrupt.lib ver 1.2.5 * * Each palameters are not stable because they can be changed unexpectedly. * Therefor, you should use the funtions which have return value. * Then, you must not substitute any value for those palameters. * なんかコマンドの送信ミスがあるみたいで、確認して次に進めるようにすべきかも * PCソフトで設定して、バックアップ電池付けるのが正確っぽい *=============================================================================*/ #ifndef GPS_INTERRUPT_H_ #define GPS_INTERRUPT_H_ #include "mbed.h"//要る? class GPS_interrupt{ public: /**===================================================================== * @brief GPS_interrupt's constructer * @param *_gps : your Rawserial bus address * @param _baudrate : baudrate you want to communication with GPS module * @param _frequency : set updata rate * @param start_baudrate : baudrate in starting link *=======================================================================*/ GPS_interrupt(RawSerial *_gps, int _baudrate = 115200, int _frequency = 10, int start_baudrate = 9600); static GPS_interrupt* gps_irq; void initialize();//初期化関数 void gps_auto_receive(); bool processGPRMC(char *line); bool processGPGGA(char *line); void debug(char *str); unsigned char checkSum(char *str); void rmc_initialize(); void gga_initialize(); private://別にpublicにしても良かったけれど、unexpectedlyに変更されるので使えないようにしてやった int baudrate; int frequency; static double latitude; static double longitude; static int year; static int month; static int day; static int hour; static int minutes; static double seconds; static double knot; static double degree; static double height; static double geoid; static int number; static char gps_buffer_A[128]; static char gps_buffer_B[128]; public: static char *gps_read_buffer; static bool gps_readable; private: RawSerial *gps; public: inline double Longitude(){ return longitude; } inline double Latitude(){ return latitude; } inline int Year(){ return year; } inline int Month(){ return month; } inline int Day(){ return day; } inline int Hour(){ return hour; } inline int Minutes(){ return minutes; } inline double Seconds(){ return seconds; } inline void getPosition(double *lon, double *lat){ *lon = longitude; *lat = latitude; } inline void getPosition(double *lonlat){ lonlat[0] = longitude; lonlat[1] = latitude; } inline void getUTC(int *_year, int *_month, int *_day, int *_hour, int *_minutes, double *_seconds){ *_year = year; *_month = month; *_day = day; *_hour = hour; *_minutes = minutes; *_seconds = seconds; } inline void getUTC(float *_utc){ _utc[0] = (float)year; _utc[1] = (float)month; _utc[2] = (float)day; _utc[3] = (float)hour; _utc[4] = (float)minutes; _utc[5] = seconds; } inline void getUTC(int *_utc){ _utc[0] = year; _utc[1] = month; _utc[2] = day; _utc[3] = hour; _utc[4] = minutes; _utc[5] = (int)seconds; } inline void getSpeedVector(double *_knot, double *_degree){ *_knot = knot; *_degree = degree; } inline int Number(){ return number; } inline double Height(){ return height; } inline double Knot(){ return knot; } inline double Degree(){ return degree; } }; ///////////////// /////sample////// ///////////////// /* #include "mbed.h" #include "GPS_interrupt.h" Serial pc(USBTX, USBRX); RawSerial mygps(p9, p10); GPS_interrupt gps(&mygps, 115200, 10, 115200); void bootFunction(){//do not need pc.printf("\r\n"); pc.printf("start LPC1768 boot phase\r\n"); wait(0.5); for(int i = 0;i < 100;i++){ pc.printf("Loading... : %3d [%%]\r", i); wait(0.025); } pc.printf("Loading... : %3d [%%]\r\n", 100); pc.printf("\t-> finished!!\r\n"); pc.printf("System : %d Hz\r\n", SystemCoreClock ); wait(0.5); pc.printf("start main program\r\n"); wait(0.1); pc.printf("initialize"); wait(0.75); pc.printf(" -> OK\r\n"); wait(0.1); pc.printf("GPS Connecting"); wait(0.5); pc.printf("."); wait(0.5); pc.printf("."); wait(0.5); pc.printf("."); wait(0.5); pc.printf("."); wait(0.5); pc.printf("."); wait(0.5); pc.printf("."); wait(0.5); while(1){ if(gps.gps_readable) break; } pc.printf(" -> OK\r\n"); pc.printf("start!!\r\n\r\n"); wait(0.5); } int main() { pc.baud(115200); //mygps.baud(9600); bootFunction(); while(1){ double xy[2] = {0}; float utc[6] = {0}; gps.getPosition(xy); gps.getUTC(utc); pc.printf("\033[K"); pc.printf("%d/%d/%d %d:%d:%02.2f ",(int)utc[0],(int)utc[1], (int)utc[2], (int)utc[3], (int)utc[4] ,utc[5]); pc.printf("(%3.7fe,%3.7fn) ",xy[0], xy[1]); pc.printf("%d satellites, %.2f[m], %.3f[m/s], %3.2f[degree]\r", gps.Number(), gps.Height(), gps.Knot()*1852/3600, gps.Degree()); wait(0.1); } } */ #endif