-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRead_avocado.pde
62 lines (56 loc) · 1.58 KB
/
Read_avocado.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import processing.serial.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.io.PrintWriter;
import java.io.FileWriter;
import java.io.*;
import java.io.PrintStream;
import java.io.File;
import processing.net.*;
PrintWriter output;
String var = "";
int x;
String serialcheck = "/dev/tty.wchusbserial1450";
Serial myPort;
void setup() {
// detect command line invocation
if (args != null) {
if (args.length != 0) {
println("args!");
}
}
String fileName = "/Users/d059566/Documents/Avocado_Buster/Data/" + new SimpleDateFormat("yyyy-MM-dd-HH;mm;ss").format(new Date()) + ".txt";
output = createWriter(fileName);
printArray(Serial.list());
//if (Serial.list().toString().matches(serialcheck)){
myPort = new Serial(this, "/dev/tty.wchusbserial1450", 115200);
//}
//{ println("No serial connector found");
//}
}
void draw() {
//try {
while (myPort.available() > 0) {
String inBuffer = myPort.readString();
//String[] valueArray = split(inBuffer, ' ');
//println(valueArray);
if (inBuffer == null) {
inBuffer = "0";
}
println(inBuffer);
//System.out.println(inBuffer);
//PrintStream fileStream = new PrintStream("/Users/d059566/Downloads/test.txt");
//System.setOut(fileStream);
//saveStrings("/Users/d059566/Downloads/output.txt", valueArray);
output.append(inBuffer);
output.flush(); // Writes the remaining data to the file
//output.close(); // Finishes the file
delay(2000);
exit();
}
//}
//catch (FileNotFoundException fnf) {
// // TODO Auto-generated catch block
// fnf.printStackTrace();
//}
}