log編集中
Dependencies: mbed MPU6050_2 HMC5883L_2 SDFileSystem3
Revision 17:6b00aec234c7, committed 2019-02-13
- Comitter:
- taknokolat
- Date:
- Wed Feb 13 11:38:59 2019 +0000
- Parent:
- 16:26cee2aaf61d
- Commit message:
- a
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Feb 13 08:18:10 2019 +0000 +++ b/main.cpp Wed Feb 13 11:38:59 2019 +0000 @@ -7,6 +7,7 @@ //MPU_check用 #define PI 3.14159265358979 +#define LOGNAME "Datalog" //拡張子を除いたログファイル名 #define servo_NEUTRAL_R 1614 #define servo_NEUTRAL_L 1621 @@ -54,6 +55,7 @@ void MoveCameraBoard(); void MatchPosition(); void FocusAdjust(); +void NewFileCreate(char *fname); //新しくファイルを生成 //sd設定 int GetParameter(FILE *fp, const char *paramName,char parameter[]); @@ -424,8 +426,11 @@ &Turntable_NEUTRAL,&Matchspeed,&Focus_NEUTRAL, &Camera_deg_A, &Camera_deg_B, &Pint_speed,&Pint_wait + ); + + char filename[30]; - ); + NewFileCreate(filename); Init_sensors(); //switch2.rise(ResetTrim); @@ -726,7 +731,30 @@ } } +void NewFileCreate(char fname[]){ + + uint16_t i_FileCheck; + FILE *fileP; + for (i_FileCheck = 1; i_FileCheck < 99; i_FileCheck++) { + sprintf(fname, "/sd/%s%02d.txt", LOGNAME, i_FileCheck); + pc.printf("%s\r\n",fname); + + fileP = fopen(fname, "r"); + if(fileP == NULL){ //参照した番号のファイルがなければ生成 + fileP = fopen(fname,"w"); + + if(fileP != NULL) { + pc.printf("%s was created\r\n",fname); + + fclose(fileP); + break; + } + else pc.printf("Faired to create a new file.\r\n"); + } + else fclose(fileP); + } +} void DebugPrint(){ //for(uint8_t i=0; i<3; i++) pc.printf("%3.2f\t",nowAngle[i]); //skipper地磁気センサ_デバック用