Skip to content

Commit 25dceba

Browse files
author
Nathan Seidle
committed
Increase baud limit to 921600. Add debug text to serial RX counter.
1 parent 0dd6b59 commit 25dceba

File tree

6 files changed

+61
-27
lines changed

6 files changed

+61
-27
lines changed

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const int MAX_IDLE_TIME_MSEC = 500;
8282
bool newSerialData = false;
8383
char incomingBuffer[256 * 2]; //This size of this buffer is sensitive. Do not change without analysis using OpenLog_Serial.
8484
int incomingBufferSpot = 0;
85-
//int charsReceived = 0; //Used for verifying/debugging serial reception
85+
int charsReceived = 0; //Used for verifying/debugging serial reception
8686
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
8787

8888
//Add ICM IMU interface
@@ -176,7 +176,7 @@ void setup() {
176176

177177
Serial.flush(); //Complete any previous prints
178178
Serial.begin(settings.serialTerminalBaudRate);
179-
Serial.printf("Artemis OpenLog v%f\n", FIRMWARE_VERSION);
179+
Serial.printf("Artemis OpenLog v%.02f\n", FIRMWARE_VERSION);
180180

181181
beginQwiic();
182182

@@ -234,7 +234,7 @@ void loop() {
234234
serialDataFile.write(incomingBuffer, sizeof(incomingBuffer)); //Record the buffer to the card
235235
incomingBufferSpot = 0;
236236
}
237-
//charsReceived++;
237+
charsReceived++;
238238
}
239239

240240
lastSeriaLogSyncTime = millis(); //Reset the last sync time to now
@@ -257,7 +257,7 @@ void loop() {
257257

258258
newSerialData = false;
259259
lastSeriaLogSyncTime = millis(); //Reset the last sync time to now
260-
//Serial.println("Total chars recevied: " + (String)charsReceived);
260+
printDebug("Total chars received: " + (String)charsReceived);
261261
}
262262
}
263263
}
@@ -349,7 +349,7 @@ void beginSD()
349349
delay(250); //Give SD more time to power up, then try again
350350
if (sd.begin(SD_CONFIG) == false) //Slightly Faster SdFat Beta (we don't have dedicated SPI)
351351
{
352-
Serial.println("SD init failed. Do you have the correct board selected in Arduino? Is card present? Formatted?");
352+
Serial.println("SD init failed. Is card present? Formatted?");
353353
digitalWrite(PIN_MICROSD_CHIP_SELECT, HIGH); //Be sure SD is deselected
354354
online.microSD = false;
355355
return;

Firmware/OpenLog_Artemis/menuMain.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@ void menuMain()
2222
Serial.println("5) Configure Analog Pin Logging");
2323

2424
Serial.println("6) Detect / Configure Attached Devices");
25-
//Serial.println("1) Detect Qwiic Devices"); //Do this in sub menu
26-
//If VL53L1X attached, set read distance, set read rate?
27-
//Log internal temp sensor
28-
//Set record freq
2925

30-
//Serial.println(") Configure Power Control");
31-
//Power down ICM
32-
//Turn off SD? RTC?...
3326
//Serial.println(") Configure Battery Voltage Logging");
3427
//Enable VCC logging
3528

@@ -51,6 +44,13 @@ void menuMain()
5144
menuAnalogLogging();
5245
else if (incoming == '6')
5346
menuAttachedDevices();
47+
else if (incoming == 'd')
48+
{
49+
Serial.print("Debug Messages ");
50+
settings.printDebugMessages ^= 1;
51+
if(settings.printDebugMessages == true) Serial.println("Enabled");
52+
else Serial.println("Disabled");
53+
}
5454
else if (incoming == 'r')
5555
{
5656
Serial.println("\n\rResetting to factory defaults. Continue? Press 'y':");

Firmware/OpenLog_Artemis/menuSerialLogging.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ void menuSerialLogging()
4747
{
4848
if (incoming == '2')
4949
{
50-
Serial.print("Enter baud rate (1200 to 460800): ");
50+
Serial.print("Enter baud rate (1200 to 921600): ");
5151
int newBaud = getNumber(menuTimeout); //Timeout after x seconds
52-
if (newBaud < 1200 || newBaud > 460800)
52+
if (newBaud < 1200 || newBaud > 921600)
5353
{
5454
Serial.println("Error: baud rate out of range");
5555
}

Firmware/OpenLog_Artemis/nvm.ino

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void loadSettings()
2626
EEPROM.get(0, settings);
2727

2828
//Load any settings from config file
29-
if(loadSettingsFromFile() == true)
29+
if (loadSettingsFromFile() == true)
3030
recordSettings(); //Record these new settings to EEPROM and config file
3131
}
3232

@@ -56,7 +56,7 @@ void recordSettingsToFile()
5656
settingsFile.println("sizeOfSettings=" + (String)settings.sizeOfSettings);
5757
settingsFile.println("nextSerialLogNumber=" + (String)settings.nextSerialLogNumber);
5858
settingsFile.println("nextDataLogNumber=" + (String)settings.nextDataLogNumber);
59-
59+
6060
char temp[20];
6161
sprintf(temp, "%lu", settings.usBetweenReadings);
6262
settingsFile.println("usBetweenReadings=" + (String)temp);
@@ -89,6 +89,7 @@ void recordSettingsToFile()
8989
settingsFile.println("logA32=" + (String)settings.logA32);
9090
settingsFile.println("logAnalogVoltages=" + (String)settings.logAnalogVoltages);
9191
settingsFile.println("localUTCOffset=" + (String)settings.localUTCOffset);
92+
settingsFile.println("printDebugMessages=" + (String)settings.printDebugMessages);
9293
// settingsFile.println("=" + (String)settings.sensor_LPS25HB.);
9394

9495
settingsFile.close();
@@ -109,7 +110,7 @@ bool loadSettingsFromFile()
109110
if (settingsFile.open("OLA_settings.cfg", O_READ) == false)
110111
{
111112
Serial.println("Failed to open settings file");
112-
return(false);
113+
return (false);
113114
}
114115

115116
char line[50];
@@ -122,39 +123,40 @@ bool loadSettingsFromFile()
122123
}
123124
else if (line[n - 1] != '\n' && n == (sizeof(line) - 1)) {
124125
Serial.printf("Settings line %d too long\n", lineNumber);
125-
if(lineNumber == 0)
126+
if (lineNumber == 0)
126127
{
127128
//If we can't read the first line of the settings file, give up
128129
Serial.println("Giving up on settings file");
129-
return(false);
130+
return (false);
130131
}
131132
}
132133
else if (parseLine(line) == false) {
133134
Serial.printf("Failed to parse line %d: %s\n", lineNumber, line);
134-
if(lineNumber == 0)
135+
if (lineNumber == 0)
135136
{
136137
//If we can't read the first line of the settings file, give up
137138
Serial.println("Giving up on settings file");
138-
return(false);
139+
return (false);
139140
}
140141
}
142+
141143
lineNumber++;
142144
}
143145

144146
Serial.println("Config file read complete");
145147
settingsFile.close();
146-
return(true);
148+
return (true);
147149
}
148150
else
149151
{
150-
Serial.println("No config file found. Loading defaults.");
152+
Serial.println("No config file found. Using settings from EEPROM.");
151153
//The defaults of the struct will be recorded to a file later on.
152-
return(false);
154+
return (false);
153155
}
154156
}
155157

156158
Serial.println("Config file read failed: SD offline");
157-
return(false); //SD offline
159+
return (false); //SD offline
158160
}
159161

160162
// Check for extra characters in field or find minus sign.
@@ -168,6 +170,10 @@ char* skipSpace(char* str) {
168170
bool parseLine(char* str) {
169171
char* ptr;
170172

173+
//Debug
174+
//Serial.printf("Line contents: %s", str);
175+
//Serial.flush();
176+
171177
// Set strtok start of line.
172178
str = strtok(str, "=");
173179
if (!str) return false;
@@ -180,16 +186,33 @@ bool parseLine(char* str) {
180186
str = strtok(nullptr, "\n");
181187
if (!str) return false;
182188

189+
//Serial.printf("s = %s\n", str);
190+
//Serial.flush();
191+
183192
// Convert string to double.
184193
double d = strtod(str, &ptr);
185194
if (str == ptr || *skipSpace(ptr)) return false;
186195

196+
//Serial.printf("d = %lf\n", d);
197+
//Serial.flush();
198+
187199
// Get setting name
188200
if (strcmp(settingName, "sizeOfSettings") == 0)
189201
{
202+
//We may want to cause a factory reset from the settings file rather than the menu
203+
//If user sets sizeOfSettings to -1 in config file, OLA will factory reset
204+
if (d == -1)
205+
{
206+
EEPROM.erase();
207+
sd.remove("OLA_settings.cfg");
208+
Serial.println("OpenLog Artemis has been factory reset. Freezing. Please restart and open terminal at 115200bps.");
209+
while(1);
210+
}
211+
190212
//Check to see if this setting file is compatible with this version of OLA
191213
if (d != sizeof(settings))
192214
Serial.printf("Warning: Settings size is %d but current firmware expects %d. Attempting to use settings from file.\n", d, sizeof(settings));
215+
193216
}
194217
else if (strcmp(settingName, "nextSerialLogNumber") == 0)
195218
settings.nextSerialLogNumber = d;
@@ -253,8 +276,10 @@ bool parseLine(char* str) {
253276
settings.logAnalogVoltages = d;
254277
else if (strcmp(settingName, "localUTCOffset") == 0)
255278
settings.localUTCOffset = d;
256-
// else if (strcmp(settingName, "") == 0)
257-
// settings. = d;
279+
else if (strcmp(settingName, "printDebugMessages") == 0)
280+
settings.printDebugMessages = d;
281+
// else if (strcmp(settingName, "") == 0)
282+
// settings. = d;
258283
else
259284
{
260285
Serial.print("Unknown setting: ");

Firmware/OpenLog_Artemis/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct struct_settings {
155155
bool logA32 = false;
156156
bool logAnalogVoltages = true;
157157
int localUTCOffset = -7; //Default to Denver because we can
158+
bool printDebugMessages = false;
158159
struct_LPS25HB sensor_LPS25HB;
159160
struct_uBlox sensor_uBlox;
160161
struct_VL53L1X sensor_VL53L1X;

Firmware/OpenLog_Artemis/support.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
void printDebug(String thingToPrint)
2+
{
3+
if(settings.printDebugMessages == true)
4+
{
5+
Serial.print(thingToPrint);
6+
}
7+
}
8+
19

210
//Option not known
311
void printUnknown(uint8_t unknownChoice)

0 commit comments

Comments
 (0)