Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem MU2 GPS
main.cpp
00001 #include "mbed.h" 00002 #include "MU2.h" 00003 #include "SDFileSystem.h" 00004 #include "GPS.h" 00005 #include <string> 00006 #include <stdio.h> 00007 #include <string.h> 00008 00009 //おっぱい 00010 int main() 00011 { 00012 00013 MU2 MuPort(p9,p10); 00014 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board 00015 //(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd") 00016 GPS gps(p13,p14); 00017 char Message1[128]; 00018 //char Message2[128]; 00019 00020 Serial pc(USBTX,USBRX); 00021 pc.baud(9600); 00022 00023 FILE* fp; 00024 00025 while(1) { 00026 fp = fopen("/sd/gps/gpsdata.txt", "a");//FILEポインタの宣言 00027 if(fp == NULL) { 00028 error("Could not open file for write\n"); 00029 } 00030 00031 //char Message[]="12345678901234567890"; 00032 if(gps.getGPGGA()) { 00033 int len1=strlen(gps.GPSMessage); 00034 00035 for(int n=0; n<len1+1; n++) { 00036 00037 Message1[n]= gps.GPSMessage[n]; 00038 } 00039 00040 MuPort.send(Message1); 00041 fprintf(fp, "%s\n", Message1); 00042 fclose(fp); 00043 00044 } else { 00045 /* 00046 int len2=strlen(gps.eGPSMessage); 00047 00048 char Message2[128]; 00049 for(int n=0; n<len2+1; n++) { 00050 Message2[n]= gps.eGPSMessage[n]; 00051 }*/ 00052 char errorMessage[] ="Could not get GPS data!"; 00053 00054 00055 00056 //pc.printf("Could not get GPS data!"); 00057 00058 00059 MuPort.send(errorMessage); 00060 fprintf(fp, "%s\n", errorMessage); 00061 fclose(fp); 00062 00063 } 00064 wait(1); 00065 00066 00067 } 00068 }
Generated on Wed Jul 20 2022 16:45:57 by
1.7.2