|
发表于 2022-8-16 10:08:47
|
显示全部楼层
新版中好像设置是“5”
- //Change how OpenLog works
- //1) New File Mode: Turn on unit, unit will create new file, and just start logging
- //2) Append File Mode: Turn on, append to known file, and just start logging
- //3) Command Mode: Turn on, sit at command prompt
- //4) Rotate Mode: Turn on, append data to current log file until it becomes to big,
- // then move on to next, rotating to overwrite first one after max file count has been reached
- //5) Resets the newLog file number to zero
- //6) Change the escape charater
- //7) Change number of escape characters needed to enter command mode
- //8) Change max file size for rotate mode in MB
- //9) Change max number of files in rotate mode
- void systemMenu(void)
- {
- byte systemMode = EEPROM.read(LOCATION_SYSTEM_SETTING);
- while (1)
- {
- NewSerial.println(F("\r\nSystem Configuration"));
- NewSerial.print(F("Current boot mode: "));
- if (systemMode == MODE_NEWLOG) NewSerial.print(F("New file"));
- if (systemMode == MODE_SEQLOG) NewSerial.print(F("Append file"));
- if (systemMode == MODE_COMMAND) NewSerial.print(F("Command"));
- if (systemMode == MODE_ROTATE) NewSerial.print(F("Rotate"));
- NewSerial.println();
- NewSerial.print(F("Current escape character and amount: "));
- NewSerial.print(setting_escape_character, DEC);
- NewSerial.print(F(" x "));
- NewSerial.println(setting_max_escape_character, DEC);
- NewSerial.print(F("Rotate mode max file size (MB) and max file count: "));
- NewSerial.print(setting_max_filesize_MB, DEC);
- NewSerial.print(F(", "));
- NewSerial.println(setting_max_filenumber, DEC);
- NewSerial.println(F("Change:"));
- NewSerial.println(F("1) Mode to new file logging"));
- NewSerial.println(F("2) Mode to append file logging"));
- NewSerial.println(F("3) Mode to command prompt"));
- NewSerial.println(F("4) Mode to rotate logging"));
- NewSerial.println(F("5) Reset new file number"));
- NewSerial.println(F("6) Escape character"));
- NewSerial.println(F("7) Number of escape characters"));
- NewSerial.println(F("8) Max file size (MB) in rotate mode"));
- NewSerial.println(F("9) Max file number in rotate mode"));
- #if DEBUG
- NewSerial.println(F("a) Clear all user settings"));
- #endif
- NewSerial.println(F("x) Exit"));
- //Print prompt
- NewSerial.print(F(">"));
- //Read command
- while (!NewSerial.available());
- char command = NewSerial.read();
- //Execute command
- if (command == '1')
- {
- NewSerial.println(F("New file logging"));
- EEPROM.write(LOCATION_SYSTEM_SETTING, MODE_NEWLOG);
- recordConfigFile(); //Put this new setting into the config file
- return;
- }
- if (command == '2')
- {
- NewSerial.println(F("Append file logging"));
- EEPROM.write(LOCATION_SYSTEM_SETTING, MODE_SEQLOG);
- recordConfigFile(); //Put this new setting into the config file
- return;
- }
- if (command == '3')
- {
- NewSerial.println(F("Command prompt"));
- EEPROM.write(LOCATION_SYSTEM_SETTING, MODE_COMMAND);
- recordConfigFile(); //Put this new setting into the config file
- return;
- }
- if (command == '4')
- {
- NewSerial.println(F("Rotate logging"));
- EEPROM.write(LOCATION_SYSTEM_SETTING, MODE_ROTATE);
- recordConfigFile(); //Put this new setting into the config file
- return;
- }
- if (command == '5')
- {
- NewSerial.println(F("New file number reset to zero"));
- EEPROM.write(LOCATION_FILE_NUMBER_LSB, 0);
- EEPROM.write(LOCATION_FILE_NUMBER_MSB, 0);
- //65533 log testing
- //EEPROM_write(LOCATION_FILE_NUMBER_LSB, 0xFD);
- //EEPROM_write(LOCATION_FILE_NUMBER_MSB, 0xFF);
- return;
- }
- if (command == '6')
- {
- NewSerial.print(F("Enter a new escape character: "));
- while (!NewSerial.available()); //Wait for user to hit character
- setting_escape_character = NewSerial.read();
- EEPROM.write(LOCATION_ESCAPE_CHAR, setting_escape_character);
- recordConfigFile(); //Put this new setting into the config file
- NewSerial.print(F("\n\rNew escape character: "));
- NewSerial.println(setting_escape_character, DEC);
- return;
- }
- if (command == '7')
- {
- NewSerial.print(F("\n\rEnter number of escape characters to look for (0 to 255): "));
- int choice = getSerialByte();
- if (choice >= 0)
- {
- setting_max_escape_character = (byte)choice;
- EEPROM.write(LOCATION_MAX_ESCAPE_CHAR, setting_max_escape_character);
- recordConfigFile(); //Put this new setting into the config file
- }
- NewSerial.print(F("\n\rNumber of escape characters needed: "));
- NewSerial.println(setting_max_escape_character, DEC);
- return;
- }
- if (command == '8')
- {
- NewSerial.print(F("\n\rEnter max size of log files in MB (0 to 254): "));
- int choice = getSerialByte();
- if (choice >= 0)
- {
- setting_max_filesize_MB = choice;
- EEPROM.write(LOCATION_MAX_FILESIZE_MB, setting_max_filesize_MB);
- recordConfigFile(); //Put this new setting into the config file
- }
- NewSerial.print(F("\n\rMax log file size in rotate mode now (MB): "));
- NewSerial.println(setting_max_filesize_MB, DEC);
- return;
- }
- if (command == '9')
- {
- NewSerial.print(F("\n\rEnter maximum log file number in rotate mode (0 to 255): "));
- int choice = getSerialByte();
- if (choice >= 0)
- {
- setting_max_filenumber = choice;
- EEPROM.write(LOCATION_MAX_FILENUMBER, setting_max_filenumber);
- recordConfigFile(); //Put this new setting into the config file
- }
- NewSerial.print(F("\n\rMaximum filenumber in rotate mode: "));
- NewSerial.println(setting_max_filenumber, DEC);
- return;
- }
- #if DEBUG
- //This allows us to reset the EEPROM and config file on a unit to see what would happen to an
- //older unit that is upgraded/reflashed to newest firmware
- if (command == 'a')
- {
- //EEPROM.write(LOCATION_BAUD_SETTING, 0xFF);
- EEPROM.write(LOCATION_SYSTEM_SETTING, 0xFF);
- EEPROM.write(LOCATION_FILE_NUMBER_LSB, 0xFF);
- EEPROM.write(LOCATION_FILE_NUMBER_MSB, 0xFF);
- EEPROM.write(LOCATION_ESCAPE_CHAR, 0xFF);
- EEPROM.write(LOCATION_MAX_ESCAPE_CHAR, 0xFF);
- EEPROM.write(LOCATION_MAX_FILESIZE_MB, 0xFF);
- EEPROM.write(LOCATION_MAX_FILENUMBER, 0xFF);
- //Remove the config file if it is there
- SdFile myFile;
- if (!sd.chdir()) systemError(ERROR_ROOT_INIT); // open the root directory
- char configFileName[strlen(CFG_FILENAME) + 1];
- strcpy_P(configFileName, PSTR(CFG_FILENAME)); //This is the name of the config file. 'config.sys' is probably a bad idea.
- //If there is currently a config file, trash it
- if (myFile.open(configFileName, O_WRITE)) {
- if (!myFile.remove()) {
- NewSerial.println(F("Remove config failed"));
- myFile.close(); //Close this file
- return;
- }
- }
- NewSerial.println(F("Unit has been reset. Please power cycle"));
- while (1);
- }
- #endif
- if (command == 'x')
- {
- //Do nothing, just exit
- NewSerial.println(F("Exiting"));
- return;
- }
- }
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|