Skip to content

Commit d1aefc7

Browse files
committed
Adding 'read firmware version' example
1 parent e9b34ca commit d1aefc7

File tree

4 files changed

+207
-5
lines changed

4 files changed

+207
-5
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
Example of creating a file, reading a file, and reading the disk properties on OpenLog
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: September 22nd, 2013
6+
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
7+
8+
This example reads the firmware version of the OpenLog without the need for a USB to serial connection.
9+
The firmware version of your OpenLog is very helpful if you need tech support.
10+
11+
Connect the following OpenLog to Arduino:
12+
RXI of OpenLog to pin 2 on the Arduino
13+
TXO to 3
14+
GRN to 4
15+
VCC to 5V
16+
GND to GND
17+
18+
This example code assumes the OpenLog is set to operate in default mode. This is 9600bps
19+
in NewLog mode, meaning OpenLog should power up and output '12<'. This code then sends the
20+
three escape characters and then sends the commands to bring up the help menu '?' and then
21+
looks for the "OpenLog v4.0" text at the top of the menu. It will then print the version
22+
# to the serial terminal.
23+
24+
This code assume OpenLog is in the default state of 9600bps with ASCII-26 as the esacape character.
25+
If you're unsure, make sure the config.txt file contains the following: 9600,26,3,0
26+
27+
Be careful when sending commands to OpenLog. println() sends extra newline characters that
28+
cause problems with the command parser. v2.51 and above ignores \n commands so it should be easier to
29+
talk to on the command prompt level. This example code works with all OpenLog v2 and higher.
30+
31+
*/
32+
33+
#include <SoftwareSerial.h>
34+
35+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
36+
//Connect TXO of OpenLog to pin 3, RXI to pin 2
37+
SoftwareSerial OpenLog(3, 2); //Soft RX on 3, Soft TX out on 2
38+
//SoftwareSerial(rxPin, txPin)
39+
40+
int resetOpenLog = 4; //This pin resets OpenLog. Connect pin 4 to pin GRN on OpenLog.
41+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
42+
43+
int statLED = 13;
44+
45+
void setup() {
46+
pinMode(statLED, OUTPUT);
47+
Serial.begin(9600);
48+
49+
Serial.println("Find OpenLog Firmware Version");
50+
51+
setupOpenLog(); //Resets logger and waits for the '<' I'm alive character
52+
Serial.println("OpenLog online");
53+
54+
gotoCommandMode(); //Puts OpenLog in command mode
55+
OpenLog.println('?'); //Send a character to get help menu
56+
delay(100);
57+
58+
byte counter = 200;
59+
while(OpenLog.available() && counter > 0)
60+
{
61+
byte incoming = OpenLog.read();
62+
if(incoming == 'v') counter = 4; //Get the next four characters
63+
64+
Serial.write(incoming);
65+
counter--;
66+
}
67+
Serial.println();
68+
}
69+
70+
void loop() {
71+
//Do nothing
72+
}
73+
74+
//Setups up the software serial, resets OpenLog so we know what state it's in, and waits
75+
//for OpenLog to come online and report '<' that it is ready to receive characters to record
76+
void setupOpenLog(void) {
77+
pinMode(resetOpenLog, OUTPUT);
78+
OpenLog.begin(9600);
79+
80+
//Reset OpenLog
81+
digitalWrite(resetOpenLog, LOW);
82+
delay(100);
83+
digitalWrite(resetOpenLog, HIGH);
84+
85+
//Wait for OpenLog to respond with '<' to indicate it is alive and recording to a file
86+
while(1) {
87+
if(OpenLog.available())
88+
if(OpenLog.read() == '<') break;
89+
}
90+
}
91+
92+
//This function pushes OpenLog into command mode
93+
void gotoCommandMode(void) {
94+
//Send three control z to enter OpenLog command mode
95+
//Works with Arduino v1.0
96+
OpenLog.write(26);
97+
OpenLog.write(26);
98+
OpenLog.write(26);
99+
100+
//Wait for OpenLog to respond with '>' to indicate we are in command mode
101+
while(1) {
102+
if(OpenLog.available())
103+
if(OpenLog.read() == '>') break;
104+
}
105+
}

firmware/Arduino_Examples/Performance_Testing/Buffer_Overrun_Test/Buffer_Overrun_Test.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ void setup()
4545
{
4646
pinMode(ledPin, OUTPUT);
4747

48-
//Serial.begin(9600); //9600bps is default for OpenLog
48+
Serial.begin(9600); //9600bps is default for OpenLog
4949
//Serial.begin(57600); //Much faster serial, used for testing buffer overruns on OpenLog
50-
Serial.begin(115200); //Much faster serial, used for testing buffer overruns on OpenLog
50+
//Serial.begin(115200); //Much faster serial, used for testing buffer overruns on OpenLog
5151

5252
delay(1000); //Wait a second for OpenLog to init
5353

5454
Serial.println();
5555
Serial.println("Run OpenLog Test");
5656

57-
int testAmt = 30;
57+
int testAmt = 3;
5858
//At 9600, testAmt of 4 takes about 1 minute, 10 takes about 3 minutes
5959
//At 57600, testAmt of 10 takes about 1 minute, 40 takes about 5 minutes
6060
//At 115200, testAmt of 30 takes about 1 minute
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
Example of creating a file, reading a file, and reading the disk properties on OpenLog
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: September 22nd, 2013
6+
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
7+
8+
This example puts OpenLog in command mode with and without LED so we can test current
9+
consumption during command prompt.
10+
11+
Connect the following OpenLog to Arduino:
12+
RXI of OpenLog to pin 2 on the Arduino
13+
TXO to 3
14+
GRN to 4
15+
VCC to 5V
16+
GND to GND
17+
18+
This example code assumes the OpenLog is set to operate at 9600bps in NewLog mode, meaning OpenLog
19+
should power up and output '12<'. This code then sends the three escape characters and then sends
20+
the commands to create a new random file called log###.txt where ### is a random number from 0 to 999.
21+
The example code will then read back the random file and print it to the serial terminal.
22+
23+
This code assume OpenLog is in the default state of 9600bps with ASCII-26 as the esacape character.
24+
If you're unsure, make sure the config.txt file contains the following: 9600,26,3,0
25+
26+
Be careful when sending commands to OpenLog. println() sends extra newline characters that
27+
cause problems with the command parser. The new v2.51 ignores \n commands so it should be easier to
28+
talk to on the command prompt level. This example code works with all OpenLog v2 and higher.
29+
30+
*/
31+
32+
#include <SoftwareSerial.h>
33+
34+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
35+
//Connect TXO of OpenLog to pin 3, RXI to pin 2
36+
SoftwareSerial OpenLog(3, 2); //Soft RX on 3, Soft TX out on 2
37+
//SoftwareSerial(rxPin, txPin)
38+
39+
int resetOpenLog = 4; //This pin resets OpenLog. Connect pin 4 to pin GRN on OpenLog.
40+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
41+
42+
int statLED = 13;
43+
44+
void setup() {
45+
pinMode(statLED, OUTPUT);
46+
Serial.begin(9600);
47+
48+
setupOpenLog(); //Resets logger and waits for the '<' I'm alive character
49+
Serial.println("OpenLog online");
50+
}
51+
52+
void loop() {
53+
Serial.println("Going to command mode");
54+
55+
gotoCommandMode(); //Puts OpenLog in command mode
56+
57+
//OpenLog will now be at ~6.7mA
58+
59+
OpenLog.write('p'); //Send a character to get LED to turn on and stay on
60+
61+
//OpenLog will now be at ~7.2mA
62+
63+
while(1); //Freeze
64+
}
65+
66+
//Setups up the software serial, resets OpenLog so we know what state it's in, and waits
67+
//for OpenLog to come online and report '<' that it is ready to receive characters to record
68+
void setupOpenLog(void) {
69+
pinMode(resetOpenLog, OUTPUT);
70+
OpenLog.begin(9600);
71+
72+
//Reset OpenLog
73+
digitalWrite(resetOpenLog, LOW);
74+
delay(100);
75+
digitalWrite(resetOpenLog, HIGH);
76+
77+
//Wait for OpenLog to respond with '<' to indicate it is alive and recording to a file
78+
while(1) {
79+
if(OpenLog.available())
80+
if(OpenLog.read() == '<') break;
81+
}
82+
}
83+
84+
//This function pushes OpenLog into command mode
85+
void gotoCommandMode(void) {
86+
//Send three control z to enter OpenLog command mode
87+
//Works with Arduino v1.0
88+
OpenLog.write(26);
89+
OpenLog.write(26);
90+
OpenLog.write(26);
91+
92+
//Wait for OpenLog to respond with '>' to indicate we are in command mode
93+
while(1) {
94+
if(OpenLog.available())
95+
if(OpenLog.read() == '>') break;
96+
}
97+
}

hardware/OpenLog.sch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!DOCTYPE eagle SYSTEM "eagle.dtd">
3-
<eagle version="7.5.0">
3+
<eagle version="7.7.0">
44
<drawing>
55
<settings>
66
<setting alwaysvectorfont="no"/>
@@ -152,7 +152,7 @@
152152
<layer number="254" name="cooling" color="7" fill="1" visible="yes" active="yes"/>
153153
<layer number="255" name="routoute" color="7" fill="1" visible="no" active="yes"/>
154154
</layers>
155-
<schematic xreflabel="%F%N/%S" xrefpart="/%S">
155+
<schematic xreflabel="%F%N/%S" xrefpart="/%S.%C%R">
156156
<libraries>
157157
<library name="SparkFun">
158158
<packages>

0 commit comments

Comments
 (0)