diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 5f736c4..fbcbb51 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -16,14 +16,14 @@ ], "intelliSenseMode": "gcc-x64", "includePath": [ - "C:\\Users\\swp791\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino", - "C:\\Users\\swp791\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\mega", + "C:\\Users\\swp791\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.7\\cores\\arduino", + "C:\\Users\\swp791\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.7\\variants\\mega", "c:\\users\\swp791\\appdata\\local\\arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\\lib\\gcc\\avr\\7.3.0\\include", "c:\\users\\swp791\\appdata\\local\\arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\\lib\\gcc\\avr\\7.3.0\\include-fixed", "c:\\users\\swp791\\appdata\\local\\arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\\avr\\include" ], "forcedInclude": [ - "C:\\Users\\swp791\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino\\Arduino.h" + "C:\\Users\\swp791\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.7\\cores\\arduino\\Arduino.h" ], "cStandard": "c11", "cppStandard": "c++11", diff --git a/mainCode/logData.pde b/mainCode/logData.pde index 9db4034..252aaf7 100644 --- a/mainCode/logData.pde +++ b/mainCode/logData.pde @@ -4,15 +4,18 @@ public void initLogFile() { textFieldFileDirInput = textFieldFileDir.getText() + OsDirChar; fileDirectory = textFieldFileDirInput + fileNameInput + ".log"; fileDirectoryReplaced = fileDirectory.replace("\\", "/"); + try { File logFile = new File(fileDirectoryReplaced); // Creating File if (logFile.createNewFile()) { + logFileExists = false; textAreaMainMsg("\n", "File created: " + textFieldFileDirInput + logFile.getName(), ""); systemPrintln("File created: " + textFieldFileDirInput + logFile.getName()); - } else { - textAreaMainMsg("\n", "File already exists. ", ""); - systemPrintln("File already exists."); + } else if (logFile.exists()) { + logFileExists = true; + textAreaMainMsg("\n", "File already exists: " + textFieldFileDirInput + logFile.getName(), ""); + systemPrintln("File already exists: " + textFieldFileDirInput + logFile.getName()); } } catch (IOException e) { @@ -22,8 +25,7 @@ public void initLogFile() { } try { - //create file writer - Writer = new FileWriter(fileDirectoryReplaced); + Writer = new FileWriter(fileDirectoryReplaced, true); initLogFileOk = true; logData = true; textAreaMainMsg("\n", "Logging data to. " + fileDirectory, ""); @@ -38,7 +40,8 @@ public void initLogFile() { public void writeToFile(String data) { if (logData == true && dataLogPause == false) { try { - Writer.write(data); + Writer.append(data); + //Writer.write(data); Writer.flush(); loggingData = true; } @@ -47,3 +50,4 @@ public void writeToFile(String data) { } } } + diff --git a/mainCode/settingsWindowUI.pde b/mainCode/settingsWindowUI.pde index e0abf72..22f521e 100644 --- a/mainCode/settingsWindowUI.pde +++ b/mainCode/settingsWindowUI.pde @@ -439,6 +439,7 @@ void drawLogConfig() { //action performed event handler public void actionPerformed(ActionEvent actionEvent) { if (loggingData == false) { + dataLogPause = false; initLogFile(); } systemPrintln("buttonStartLog clicked" + " @ " + millis()); @@ -461,7 +462,7 @@ void drawLogConfig() { //action performed event handler public void actionPerformed(ActionEvent actionEvent) { try { - if (loggingData) { + if (loggingData || dataLogPause) { Writer.flush(); Writer.close(); Writer = null; @@ -470,7 +471,7 @@ void drawLogConfig() { loggingData = false; } } - catch (IOException e) { + catch (Exception e) { textAreaMainMsg("\n", "Failed to stop logging data. " + e, ""); } systemPrintln("buttonStopLog clicked" + " @ " + millis()); diff --git a/mainCode/variables.pde b/mainCode/variables.pde index 009f7f4..55bdf0d 100644 --- a/mainCode/variables.pde +++ b/mainCode/variables.pde @@ -15,6 +15,7 @@ int prevCommandsIndex = 0; //count of up key presses for previous command retrie char selectedParity = 'N'; //serial port parity 'N' for none, 'E' for even, 'O' for odd, 'M' for mark, 'S' for space ('N' is the default) +boolean showDebugStatements = true; //if true show debug statements in console boolean connectToCOM = false; //if connecting to com port boolean connectedToCOM = false; //if connected to com port boolean loggingData = false ; //if logging succeeded @@ -28,7 +29,7 @@ boolean portsFound = false; boolean textAreaMainMsgIsRunning = false; boolean textFieldSearchHasText = false; //if textFieldSearch has text other than prompt text boolean serialPortRemoved = false; //if serial port was removed while connected -boolean showDebugStatements = false; //if true show debug statements in console +boolean logFileExists = false; //if log file already exists when creating log file boolean mainUiInit, settingsUiInit, drawPortConfigInit, drawDataConfigInit, drawLogConfigInit = false; //if UI has been initialized boolean commandFound = false; //true if entered command is a valid command