-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathserialEvent.xml
More file actions
executable file
·81 lines (61 loc) · 2.09 KB
/
Copy pathserialEvent.xml
File metadata and controls
executable file
·81 lines (61 loc) · 2.09 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>serialEvent()</name>
<category>Movie</category>
<subcategory></subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
// Example by Tom Igoe
import processing.serial.*;
Serial myPort; // The serial port
PFont myFont; // The display font
String inString; // Input string from serial port
int lf = 10; // ASCII linefeed
void setup() {
size(400,200);
// You'll need to make this font with the Create Font Tool
myFont = loadFont("ArialMS-18.vlw");
textFont(myFont, 18);
// List all the available serial ports:
printArray(Serial.list());
// I know that the first port in the serial list on my mac
// is always my Keyspan adaptor, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(lf);
}
void draw() {
background(0);
text("received: " + inString, 10,50);
}
void serialEvent(Serial p) {
inString = p.readString();
}
]]></code>
</example>
<description><![CDATA[
Called when data is available. Use one of the <b>read()</b> methods to capture this data. The <b>serialEvent()</b> can be set with <b>buffer()</b> to only trigger after a certain number of data elements are read and can be set with <b>bufferUntil()</b> to only trigger after a specific character is read. The <b>which</b> parameter contains the name of the port where new data is available, but is only useful when there is more than one serial connection open and it's necessary to distinguish between the two.
]]></description>
<syntax>
void serialEvent(Serial <c>whichPort</c>) {
<c>statements</c>
}
</syntax>
<parameter>
<label>whichPort</label>
<description><![CDATA[Serial: the port where new data is available]]></description>
</parameter>
<parameter>
<label>statements</label>
<description><![CDATA[any valid statements]]></description>
</parameter>
<returns></returns>
<related>
Serial
</related>
<availability>1.0</availability>
<type>Function</type>
<partof>core</partof>
</root>