Revision f175b4b0
.gitmodules | ||
---|---|---|
1 |
[submodule "applications/sliposc/SlipLib"] |
|
2 |
path = applications/sliposc/SlipLib |
|
3 |
url = https://github.com/rhjdjong/SlipLib/ |
|
4 |
[submodule "firmware/sliposc/OSC"] |
|
5 |
path = firmware/sliposc/OSC |
|
6 |
url = https://github.com/CNMAT/OSC/ |
applications/sliposc/SlipLib | ||
---|---|---|
1 |
Subproject commit fac389bc5a65159df208c24bbb8122325bb60cfa |
firmware/sliposc/OSC | ||
---|---|---|
1 |
Subproject commit 41b44981e309fa6ed4d398de4812b54c75fac195 |
firmware/sliposc/SerialSendBundle/OSC | ||
---|---|---|
1 |
../OSC/ |
firmware/sliposc/SerialSendBundle/SerialSendBundle.ino | ||
---|---|---|
1 |
// vim:ts=2:sw=2:expandtab |
|
2 |
// OSC Lib Example for w/ and w/o timetag |
|
3 |
|
|
4 |
/* |
|
5 |
Make an OSC bundle and send it over SLIP serial |
|
6 |
|
|
7 |
OSCBundles allow OSCMessages to be grouped together to preserve the order and completeness of related messages. |
|
8 |
They also allow for timetags to be carried to represent the presentation time of the messages. |
|
9 |
*/ |
|
10 |
#include "OSC/OSCBundle.h" |
|
11 |
#include "OSC/OSCBoards.h" |
|
12 |
#include "OSC/OSCTiming.h" |
|
13 |
|
|
14 |
#ifdef BOARD_HAS_USB_SERIAL |
|
15 |
#include <SLIPEncodedUSBSerial.h> |
|
16 |
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); |
|
17 |
#else |
|
18 |
#include <SLIPEncodedSerial.h> |
|
19 |
SLIPEncodedSerial SLIPSerial(Serial1); |
|
20 |
#endif |
|
21 |
|
|
22 |
|
|
23 |
void setup() { |
|
24 |
//begin SLIPSerial just like Serial |
|
25 |
SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform |
|
26 |
#if ARDUINO >= 100 |
|
27 |
while(!Serial) |
|
28 |
; // Leonardo bug |
|
29 |
#endif |
|
30 |
|
|
31 |
} |
|
32 |
|
|
33 |
void loop(){ |
|
34 |
//declare the bundle |
|
35 |
OSCBundle bndl; |
|
36 |
osctime_t timetag; |
|
37 |
|
|
38 |
//OSCBundle's add' returns the OSCMessage so the message's 'add' can be composed together |
|
39 |
|
|
40 |
// with timetag |
|
41 |
bndl.add("/analog/0").add((int32_t)adcRead(0, &timetag)); |
|
42 |
bndl.add("/analog/0/time").add(timetag); |
|
43 |
|
|
44 |
bndl.add("/analog/1").add((int32_t)adcRead(1, &timetag)); |
|
45 |
bndl.add("/analog/1/time").add(timetag); |
|
46 |
|
|
47 |
bndl.add("/digital/5").add((digitalRead(5)==HIGH)?"HIGH":"LOW"); |
|
48 |
|
|
49 |
|
|
50 |
bndl.add("/analog/2").add((int32_t)analogRead(2)); |
|
51 |
bndl.add("/analog/3").add((int32_t)analogRead(3)); |
|
52 |
bndl.add("/digital/4").add((digitalRead(4)==HIGH)?"HIGH":"LOW"); |
|
53 |
|
|
54 |
SLIPSerial.beginPacket(); |
|
55 |
bndl.setTimetag(oscTime()); |
|
56 |
bndl.send(SLIPSerial); // send the bytes to the SLIP stream |
|
57 |
SLIPSerial.endPacket(); // mark the end of the OSC Packet |
|
58 |
bndl.empty(); // empty the bundle to free room for a new one |
|
59 |
|
|
60 |
delay(100); |
|
61 |
} |
firmware/sliposc/SerialSendMessage/OSC | ||
---|---|---|
1 |
../OSC/ |
firmware/sliposc/SerialSendMessage/SerialSendMessage.ino | ||
---|---|---|
1 |
// vim:ts=2:sw=2:expandtab |
|
2 |
// OSC Lib Example |
|
3 |
// messages work fine over slip udp, |
|
4 |
// osc bundles likely require tcp stream |
|
5 |
#include "OSC/OSCMessage.h" |
|
6 |
|
|
7 |
/* Make an OSC message and send it over serial */ |
|
8 |
|
|
9 |
#ifdef BOARD_HAS_USB_SERIAL |
|
10 |
#include <SLIPEncodedUSBSerial.h> |
|
11 |
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); |
|
12 |
#else |
|
13 |
#include <SLIPEncodedSerial.h> |
|
14 |
SLIPEncodedSerial SLIPSerial(Serial1); |
|
15 |
#endif |
|
16 |
|
|
17 |
|
|
18 |
void setup() { |
|
19 |
//begin SLIPSerial just like Serial |
|
20 |
SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform |
|
21 |
#if ARDUINO >= 100 |
|
22 |
while(!Serial) |
|
23 |
; //Leonardo "feature" |
|
24 |
#endif |
|
25 |
} |
|
26 |
|
|
27 |
|
|
28 |
void loop(){ |
|
29 |
//the message wants an OSC address as first argument |
|
30 |
OSCMessage msg("/analog/0"); |
|
31 |
msg.add((int32_t)analogRead(0)); |
|
32 |
|
|
33 |
SLIPSerial.beginPacket(); |
|
34 |
msg.send(SLIPSerial); // send the bytes to the SLIP stream |
|
35 |
SLIPSerial.endPacket(); // mark the end of the OSC Packet |
|
36 |
msg.empty(); // free space occupied by message |
|
37 |
|
|
38 |
delay(20); |
|
39 |
} |
Also available in: Unified diff