cnmat / osc Goto Github PK
View Code? Open in Web Editor NEWOSC: Arduino and Teensy implementation of OSC encoding
Home Page: cnmat.berkeley.edu/oscuino
License: Other
OSC: Arduino and Teensy implementation of OSC encoding
Home Page: cnmat.berkeley.edu/oscuino
License: Other
File OSC/SLIPEncodedSPISerial.h references StreamSPI.h, but StreamSPI.h is not provided.
Why does bundle/message.fill() expect an array or single integers if actually bytes are processed?
That way, one cannot handover a complete packet or parts of it by reference from EthernetUDP because those are only arrays of chars.
Hi,
I can't find a forum where questions can be asked about CNMAT (In my case OSC related) externals.
I want to send analog data via esp8266 to max/msp. I managed to get osc messages in max/msp.
But when I declare a constant variable for the analogpin. I don't get the result I want.
Anyway this is not an issue with the osc github part. So doesn't really matter (but you're free to help me whenever you want! ) ;)
The question is if cnmat has a portal/forum where such things can be asked or discussed upon!
Hi If I run SerialSendBundle --> SlipSerialToUDP --> UDPRecieveBundle from the examples all is goodness
if I add... " bndl.add("/s/m").add((int32_t)micros()); " after the request for /digital/5 in SerialSendBundle within a few (random) seconds I get
java.lang.NegativeArraySizeException
at netP5.Bytes.copy(Unknown Source)
at oscP5.OscPatcher.parseBundle(Unknown Source)
at oscP5.OscBundle.(Unknown Source)
at oscP5.OscPacket.parse(Unknown Source)
at oscP5.OscP5.process(Unknown Source)
at oscP5.OscNetManager.process(Unknown Source)
at netP5.AbstractUdpServer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
or less commonly
java.lang.OutOfMemoryError: Java heap space
at netP5.Bytes.copy(Unknown Source)
at oscP5.OscPatcher.parseBundle(Unknown Source)
at oscP5.OscBundle.(Unknown Source)
An OutOfMemoryError means that your code is either using up too much memory
because of a bug (e.g. creating an array that's too large, or unintentionally
loading thousands of images), or that your sketch may need more memory to run.
If your sketch uses a lot of memory (for instance if it loads a lot of data files)
you can increase the memory available to your sketch using the Preferences window.
at oscP5.OscPacket.parse(Unknown Source)
at oscP5.OscP5.process(Unknown Source)
at oscP5.OscNetManager.process(Unknown Source)
at netP5.AbstractUdpServer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
when this happens if I add Bytes.printBytes( data); to SlipSerialToUDP I can see there is an extra byte in the bundle from the arduino immediately after the int32_t.
Help.... I'm out of ideas
Cheers H
Hello,
I am unable control the LED on my Teensy 3.1 from SerialOscuino.pd using the LED toggle.
These are the two sketches I tried running on the Teensy: SerialOscuinowithBundles and SerialOscuinowithMessages.
I also tried controlling the LED pin 13 by attaching the message /d/13 $1 to a toggle. This also didn't work.
I get no complaints from the Pd console, which outputs [comport] opened serial line device 4 (/dev/tty.usbmodem392441) whenever I send devicename /dev/tty.usbmodem392441, baud 9600, pollintervall 1 to it.
Thanks,
Miles
Hey, I get this error message when I try to compile. Below is the error info.
I'm using an Arduino Leonardo with Arduino IDE 1.0.5
openGlove1.ino: In function 'void setup()':
openGlove1:14: error: no matching function for call to 'OscSerial::begin(Serial_&)'
/Users/anthony/Documents/Arduino/libraries/arduinoOsc/OscSerial.h:21: note: candidates are: void OscSerial::begin(HardwareSerial&)
the source of the issue is the line:
void setup(){
Serial.begin(9600);
oscSerial.begin(Serial); // this one
}
Any suggestions, hints, or fixes would be really appreciated. Thanks in advanced
In the past the library was working with touchOSC see:
http://cnmat.berkeley.edu/library/oscuino/controlling_oscuino/touchosc
Now the repository is moved and the example is removed. Could a example be given?
I think the problem is the difference between oscBundle and oscMessage that fails the new libary to work with touchOSC? TouchOSC only works with sending messages, the libary is working with receiving bundles.
Any help with his issue would be appreciated
I need to use SLPSerial with Software serial. For now I've copied the hardwareserial version and changed references however I feel there may be a better way. Is there a more sensible thing to do?
Thanks!
I use Arduino Due with SLIP encoded serial connection. Below is my code and compile error log. Thank you.
// MY_CODE
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
void setup() {
SLIPSerial.begin(9600);
analogReadResolution(12);
}
void loop() {
OSCBundle bundl;
bundl.add("/thinpot/0").add((int)analogRead(A0));
SLIPSerial.beginPacket();
bundl.send(SLIPSerial);
SLIPSerial.endPacket();
bundl.empty();
}
/* ERROR_LOG
Arduino: 1.5.6 (Mac OS X), Board: "Arduino Due (Programming Port)"
OSC/OSCTiming.cpp.o: In function noTone(unsigned long)': /Arduino/libraries/OSC/OSCBoards.h:86: multiple definition of
noTone(unsigned long)'
AnalogReadSerial.cpp.o: /Arduino/libraries/OSC/OSCBoards.h:86: first defined here
OSC/OSCTiming.cpp.o: In function TC3_Handler': /Arduino/libraries/OSC/OSCBoards.h:92: multiple definition of
TC3_Handler'
AnalogReadSerial.cpp.o: /Arduino/libraries/OSC/OSCBoards.h:92: first defined here
OSC/OSCTiming.cpp.o: In function tone(unsigned long, unsigned long, long)': /Arduino/libraries/OSC/OSCBoards.h:54: multiple definition of
tone(unsigned long, unsigned long, long)'
AnalogReadSerial.cpp.o:/Arduino/libraries/OSC/OSCBoards.h:54: first defined here
OSC/OSCTiming.cpp.o: In function tone(unsigned long, unsigned long)': /Arduino/libraries/OSC/OSCBoards.h:82: multiple definition of
tone(unsigned long, unsigned long)'
AnalogReadSerial.cpp.o:/Arduino/libraries/OSC/OSCBoards.h:82: first defined here
collect2: ld returned 1 exit status
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
I have been trying to send an OSC message from my Arduino, using an official ethernet shield, to my Mac BookPro for the past couple of hours. No luck...
I have tried the "UDPsendMessage" sketch. It compiles, but I have not seen any messages get to my computer. Why is this?
I have been using the great OSC sniffer/listener/watcher found here: https://code.google.com/p/osc-tools/downloads/list
The Sniffer was able to pick up every other OSC message used by every other program (Processing, Quartz, Touch OSC, etc) so I am taking it that this UDPsendMessage sketch is either A) Not functioning as it should. Or, B) I did not set it up correctly.
Can anyone help please?
Here is the code I am using...
#include <OSCMessage.h>
/*
Make an OSC message and send it over UDP
Adrian Freed
*/
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCMessage.h>
EthernetUDP Udp;
//the Arduino's IP
IPAddress ip(128, 32, 122, 252);
//destination IP
IPAddress outIp(169, 254, 166, 0);
const unsigned int outPort = 9999;
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0F, 0x2B, 0X1E }; // you can find this written on the board of some Arduino Ethernets or shields
float vvv = 0.0;
void setup() {
Ethernet.begin(mac,ip);
Udp.begin(8888);
}
void loop(){
//the message wants an OSC address as first argument
OSCMessage msg("/analog/");
msg.add(vvv);
Udp.beginPacket(outIp, outPort);
msg.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
delay(20);
vvv = vvv + 0.1;
}
Hi, I am encountering speed issues with creating an OSCMessage, adding OSCMessages, sending through SLIPserial and clearing OSCBundle. Here's the time that takes each function that I have measured :
I think empty() is supposed to return *this, but it doesn't.
I'm not a C++ pro, so I'm not sure if I'm misinterpreting here or if it is a bug...
Hello.
I've connected a Huzzah ESP8266 breakout to a Teensy 3.2 through serial.
I'm trying to make the ESP receive OSC messages over UDP, and send them over serial (with SLIP serial) to the Teensy, and then decode the OSC message and activate a function.
At the moment I've programmed the Teensy to take the messages comming from the ESP, and if there are no errors, route them to the appropriate function. The function then outputs something to the serial connection between my PC and Teensy (not the same one as the ESP and Teensy uses), like for example 'LED ON'.
If there is an error no function is activated and "Error in OSC message" is printed to the serial interface my computer is connected to and also "Serial.println(SLIPSerial.read());"
I get a lot of output to the serial monitor. But almost always with errors.
Only 1/10 times (or something) do I get the output from a function, meaning there was no error.
My problem is that I'm unable to find out what is wrong with the OSC messages.
The function checking for errors is: "msgIN.hasError()" where "msgIN" is an object of type 'OSCMessage'. I'm not able to find any information on what the different possible errors are, or how to output the error message.
Help please!?
This is the code on my Teensy:
`
//DHCP-based OSC server test code
SLIPEncodedSerial SLIPSerial(Serial1);
void setup(){
Serial.begin(9600); //Teensy <=> Computer
SLIPSerial.begin(115200); //Teensy <=> ESP
delay(1000);
Serial.println("Started");
}
void loop(){
OSCMsgReceive();
}
void toggleOnOff(OSCMessage &msg, int addrOffset)
{
int ledState;
ledState = (boolean) msg.getFloat(0);
OSCMessage msgOUT("/OnOff/toggle1");
//digitalWrite(ledPin, ledState);
msgOUT.add(ledState);
if (ledState) {
Serial.println("LED on");
}
else {
Serial.println("LED off");
}
ledState = !ledState; // toggle the state from HIGH to LOW to HIGH to LOW ...
//send osc message back to control object in TouchOSC
//Local feedback is turned off in the TouchOSC interface.
//The button is turned on in TouchOSC interface whe the conrol receives this message.
SLIPSerial.beginPacket();
msgOUT.send(SLIPSerial); // send the bytes
SLIPSerial.endPacket(); // mark the end of the OSC Packet
msgOUT.empty(); // free space occupied by message
}
void funcValue(OSCMessage &msg, int addrOffset ){
int value = msg.getFloat(0);
OSCMessage msgOUT("/Fader/Value");
Serial.print("Value = : ");
Serial.println(value);
msgOUT.add(value);
SLIPSerial.beginPacket();
msgOUT.send(SLIPSerial); // send the bytes
SLIPSerial.endPacket(); // mark the end of the OSC Packet
msgOUT.empty(); // free space occupied by message
}
void OSCMsgReceive()
{
OSCMessage msgIN;
int size;
while(!SLIPSerial.endofPacket())
{
if(size = SLIPSerial.available() > 0)
{
while(size--)
{
msgIN.fill(SLIPSerial.read());
}
if(!msgIN.hasError())
{
msgIN.route("/OnOff/toggle1",toggleOnOff);
msgIN.route("/Fader/Value",funcValue);
}
else
{
Serial.println("Error in OSC message");
Serial.println(msgIN.getError());
}
}
}
}`
Hi,
Constructors and destructors are not done correctly in (almost?) all OSC objects (no copy constructors), so if you try passing around objects by copy (no pointer or reference), you end up freeing already-freed memory -> crash.
Adding some sort of implicit sharing would be the best option to fix the issue. The workaround is of course to use references or pointers and be careful of not doing any copy.
I'll try to push a fix to that asap.
Did anybody try the library on ATSAMD21G18 ARM Cortex M0 / Arduino Zero?
I've just installed the latest odot (1.0.6rc) and OSC for Arduino (this repository). The example Max patches in the "Applications" folder won't run, due to these missing objects:
o.io.slipserial
o.io.slipserial.display.maxpat
o.io.udp
Several of the patches call for o.message (found in "deprecated"), which I guess should be replaced by o.compose and o.display?
Also o.downcast, and o.was (found in "dev") - are these ok to use?
The Arduino team has linked the library for automatic inclusion in the IDE Library manager.
To get things working a new release is needed. Simple guidelines are available here:
https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ
When fixed, within one hour from the release the library manger will show the lib in the IDE.
Hi!
I am trying to communicate my Arduino with Reaper via OSC over Ethernet shield. While sending messages to Reaper is not a problem, recieving one properly bugs me a lot.
I am using Oscuino library from CNMAT.
When I am trying to recieve only /time message from Reaper I get this:
I pressed play at time 0.00 and it gets /time only sometimes.
When I change "/time" to "*" (everything) it looks like this:
As you can see, when using "*", sometimes it gets other values than time.
This is the code I am using:
Ethernet shield is W5100
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCBundle.h>
#include <OSCMessage.h>
#include <OSCMatch.h>
EthernetUDP Udp;
void TimeOSC(OSCMessage &msg);
IPAddress ip(192, 168, 5, 2);
const unsigned int inPort = 8000;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
void setup() {
Serial.begin(115200);
Ethernet.begin(mac,ip);
Udp.begin(inPort);
}
void loop(){
int size;
OSCMessage msgIN;
if ( (size = Udp.parsePacket())>0)
{
while(size--)
msgIN.fill(Udp.read());
msgIN.dispatch("/time",TimeOSC);
}
}
void TimeOSC(OSCMessage &msg) {
float time = msg.getFloat(0);
Serial.print("Time: ");
Serial.println(time);
}
Do you have any ideas why it is not working for me?
Any help would be appreciated :)
Hello, thank you for this library I have been using it since a week for a lighting application and is generally working well. I have a problem in decoding blobs. I am linking the source code for Arduino and Processing.
The code shows perfect communications using integers but fails using blobs.
https://github.com/marcobrianza/testcode
thank you
Marco
hello I can't compile OSC on arduino MKR1000.
I get this error message:
Users/dupraz/Documents/Arduino/libraries/OSC/OSCTiming.cpp: In function 'osctime_t oscTime()':
/Users/dupraz/Documents/Arduino/libraries/OSC/OSCTiming.cpp:150:5: error: return-statement with no value, in function returning 'osctime_t' [-fpermissive]
return ;
thanks for the help
Firstly thank you so much for all you hard work over that past few months.
Everything is up and running on the Teensy 3. I have yet to use the Boolean.
TouchOSC fails to send from udp to serial using the new Processing sketch.
Lemur works fine.
Same thing happens in my maxpatch.
TouchOSC seems to receive ok while send data but not constantly. Serial port requires polling, at least it did in my Maxpatch
Is touchOSC using Messages without bundles that Max/Processing are not handling?
Is the OS locking TX to the serial?
I am running 32bit Max/Processing on 64bit Windows 7.
This has occurred before with the Missing link OSC/Midi box. Lemur would not parse spaces so they had to swap to underscore.
I would be good to be able to specify many UDP transmit ports to send to multiple devices on the network. Same as the OSC targets setup in Lemur. OSC 0->OSC 7
PM me for a copy of my Maxpatch which is very much like your processing sketch with the polling.
Thanks again for your awesome code
The fix is seems pretty easy, we just need to find the right ifdef
for the Galileo (and probably also the Intel Edison) for this line (and the definition in the cpp file). This is probably because the ints
are int_32
on these platforms, so it grumbles that there is a redefinition.
Maybe, is there a case for just getting rid of the int
OSCData type constructor and just keeping int_16
and int_32
? Moving forward there are going to be more 32bit platforms so that ifndef is probably going to keep growing. But i'm not sure right now if we would break anything if we removed the normal int
constructor.
Strings that are 4-byte aligned cause problems. These strings require 0 padding, but OSCMessage::decode gets stuck looking for padding. Subsequent strings in the message get dropped and the message becomes invalid. Adding a check for 0 padding seems to fix this:
around line 649:
//compute the padding size for the data
int dataPad = padSize(datum->bytes);
// if there is no padding required, switch back to DATA, and don't clear the incomingBuffer because it holds next data
if (dataPad == 0){
decodeState = DATA;
}
else if (incomingBufferSize == dataPad){
clearIncomingBuffer();
decodeState = DATA;
}
break;
Hi,
i've tried this library with espressing esp32, but it's not working.
Is there a plan on supporting esp32 boards in the future?
edit: thanks to this article i've been able to run osc on the ESP32:
https://0110.be/posts/ESP32_Thing_as_xOSC_alternative
Can you add support for Arduino Zero, M0, M0pro, MKR1000 etc. with Atmel SAMD21 uc.
I am facing a huge latency when trying the ESP8266ReceiveBundle. Please watch this video showing the code, the pd patch and the latency I am experiencing: esp8266OSC.mp4
I have no problem at all with the example "ESP8266sendMessage", it's lighting fast.
It is because I am using a bundle? I tried the other approach (SLIPserial) but looks like the esp8266 doesn't like it (wtd reset, fatal error, ...)
hi!
In some example code the use of the function fill seems away from optimal (at least for me), the use I saw is this (and similar):
OSCMessage msg_in;
int size;
if( (size = Udp.parsePacket())>0)
{
while(size--) msg_in.fill(Udp.read()); <---- this part takes ~6mS to complete!
If we replace the last statement with:
uint8_t packetBuffer[UDP_TX_PACKET_MAX_SIZE];
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
msg_in.fill(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
now this takes ~500uS to complete!
This was measured in a arduino.org's Zero, UDP_TX_PACKET_MAX_SIZE was defined to 28 bytes.
Hi there,
Running Arduino 1.8.5, for an Arduino UNO, trying to use/include these libraries in a project, but currently failing at compile stage of even the integrated example OSCBundle Test.
Any idea what could be going wrong/is it easily fixable? error messages below:
In file included from /Users/mc/Documents/Arduino/libraries/OSC/OSCBundle.h:29:0,
from /Users/mc/Documents/Arduino/libraries/OSC/test/OSCBundle_test/OSCBundle_test.ino:2:
/Users/mc/Documents/Arduino/libraries/OSC/OSCMessage.h: In instantiation of 'OSCMessage& OSCMessage::add(T) [with T = int]':
/Users/mc/Documents/Arduino/libraries/OSC/test/OSCBundle_test/OSCBundle_test.ino:9:31: required from here
/Users/mc/Documents/Arduino/libraries/OSC/OSCMessage.h:136:34: error: call of overloaded 'OSCData(int&)' is ambiguous
OSCData * d = new OSCData(datum);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCMessage.h:136:34: note: candidates are:
In file included from /Users/mc/Documents/Arduino/libraries/OSC/OSCMessage.h:29:0,
from /Users/mc/Documents/Arduino/libraries/OSC/OSCBundle.h:29,
from /Users/mc/Documents/Arduino/libraries/OSC/test/OSCBundle_test/OSCBundle_test.ino:2:
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:104:5: note: OSCData::OSCData(boolean)
OSCData (boolean);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:103:2: note: OSCData::OSCData(OSCData*) <near match>
OSCData (OSCData *);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:103:2: note: no known conversion for argument 1 from 'int' to 'OSCData*'
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:100:2: note: OSCData::OSCData(double)
OSCData (double);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:99:2: note: OSCData::OSCData(float)
OSCData (float);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:98:5: note: OSCData::OSCData(unsigned int)
OSCData (unsigned int);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:94:2: note: OSCData::OSCData(int32_t)
OSCData (int32_t);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:90:2: note: OSCData::OSCData(const char*) <near match>
OSCData(const char * s);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:90:2: note: no known conversion for argument 1 from 'int' to 'const char*'
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:65:5: note: OSCData::OSCData(char)
OSCData(char t);
^
/Users/mc/Documents/Arduino/libraries/OSC/OSCData.h:55:7: note: constexpr OSCData::OSCData(const OSCData&)
class OSCData
^
exit status 1
Error compiling for board Arduino/Genuino Uno.
Thanks for looking into this!
Cheers,
freadZdead
First, thanks for this project, I can see it being really useful!
I'm having a problem though, that 32-bit numbers sent from Max to Arduino are being converted to 16-bit.
If you run the "SerialEcho" sketch and Max patch, and change the "/ping 100" to "/ping 32769" in Max, the echoed-back bundle from the Arduino contains "/ping -32767".
Also the getInt() method has the same problem, the data is truncated into 16 bits, even though it seems like it should return int32_t according to OSCData.h
Going from the Arduino to Max works fine, in the example the message added by this:
bndl.add("/micros").add((int32_t)micros()); // (int32_t) is the type of OSC Integers
comes across fine in Max.
I looked further through the library source code but unfortunately my C++ skills aren't so good, and I can't tell where it's happening, whether it's a bug, or what I could do in order to get a 32-bit long out of the OSC message and into my Arduino code. It seems odd that it's being converted during a straight bundle.fill / bundle.send operation. Any advice appreciated...
Hello, I'm having problems writing a "for" that adds every available message to the bundle.
The thing I cannot seem to understand is the way "add" works:
would something like this
bndl.add("/piezo/").add(char(pin)).add(actual_analog[pin]).add(timetag).add("/time").add(timetag);
be well written?
(I'm also doing some calibration, so the actual_analog is the analogRead mapped)
Is the second add going to put the value of "piezo" as "pin"? I need to integrate in the address, the number of the pin the for is going on actually...
I saw at SerialOscuinowithBundles some strcpy and strcat and at first thought it was a method of the string type but nor the Arduino reference, nor the cpp nor h files of the OSCBundle seem to establish them, so, is it the way over there?
I think this is the place for this question, correct me if I'm wrong.
good day
I'm new to the lib and tried to reuse a OSCMessage by empty()
refilling it using fill()
This did not work though as empty()
does not reset the decodeState.
Should it? Or should I just delete the message and create a new one?
The following code does not work on Teensy 3:
#include <OSCBundle.h>
#ifdef BOARD_HAS_USB_SERIAL
#include <SLIPEncodedUSBSerial.h>
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
#else
#include <SLIPEncodedSerial.h>
SLIPEncodedSerial SLIPSerial(Serial);
#endif
void setup() {
SLIPSerial.begin(9600);
}
void loop(){
OSCBundle bndl;
int size;
//receive a bundle
while(!SLIPSerial.endofPacket())
if( (size =SLIPSerial.available()) > 0)
{
while(size--)
bndl.fill(SLIPSerial.read());
}
if(!bndl.hasError())
{
bndl.route("/s", routeSystem);
static int32_t sequencenumber=0;
// we can sneak an addition onto the end of the bundle
bndl.add("/micros").add((int32_t)micros()); // (int32_t) is the type of OSC Integers
bndl.add("/sequencenumber").add(sequencenumber++);
bndl.add("/digital/5").add(digitalRead(5)==HIGH);
bndl.add("/lsb").add((sequencenumber &1)==1);
SLIPSerial.beginPacket(); // mark the beginning of the OSC Packet
bndl.send(SLIPSerial);
SLIPSerial.endPacket();
}
}
void routeSystem(OSCMessage &msg, int addrOffset ){
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
Arduino: 1.0.5
Teensyduino: 1.18
I am using Ubuntu 14.04 in combination with the Pure-Data Example (SerialOscuino.pd / SerialOscuinowithBundles.ino). Unfortunately the LED never turns on. I think something in the "route" function doesn't work. (Send and receive on Teensy is working.)
Please let me know if you need more information/testing.
Thanks!
Hello,
I'm trying to do something that seems incredibly simple.
ETC lighting consoles can receive OSC in the format:
/eos/cue/a/b/fire
In order to fire a cue where a is the cuelist and b is the cue number.
Note there are no spaces. Any space used as per the msg.add("example" line of code puts a space between the contents of OSCMessage msg("/etc/cue/") and example for instance. The consoles don't acknowledge any message that's not in this format.
I can't for the life of me figure out how to do this with the library. Is anyone able to tell me how to do this? I need to be able to alter a and b depending on data generated by the arduino. Namely, I want to create a midi program change or MSC to OSC conversion box.
Any help is greatly received!
Andrew
Experimenting with an ESP8266, sending and receiving OSC messages with the included ESP examples:
https://github.com/CNMAT/OSC/blob/master/examples/ESP8266ReceiveBundle/ESP8266ReceiveBundle.ino and https://github.com/CNMAT/OSC/blob/master/examples/ESP8266sendMessage/ESP8266sendMessage.ino
Sending works straight away but receiving data doesn't seem to work. Does anybody know how to get this working?
I'm sending and receiving OSC data from Max7 with the default "udpsend" object and the esp8266 Huzzah is receiving something but the dispatch (or route) function is never called
I've committed a little example Arduino sketch to my Github account that shows how to exchange messages with TouchOSC
https://github.com/TrippyLighting/OSCuino_TouchOSC
Hi,
Thank you for your work.
I found that none of the Max examples work out of the box. The o.io.slipserial needs to be polled in order to send / receive values, is that correct ? When I have finally managed to get it to work with an Arduino Uno (I don't have any Teensy 3 yet), I found that that you can't send and receive messages reliably. At 38400, I can't read all of the analog pins and turn on/off the led 13 for example. Would you have any recommendation ?
analogWrite() is in routeAnalog() which matches against the analog pins
it needs to be in routeDigital() or be matched against the digital PWM pins
Hey.
I have an ESP8266 breakout connected to a Teensy 3.2 with serial connection.
The ESP receives OCSmessages over UDP and sends them to the Teensy over SLIP.
When the messages arrive at the Teensy and I use 'msg.getFloat(0)' the returned value is always 0.
Even when I program the ESP to generate a test message with a single value I defined.
If I program the ESP to just receive OSCmessages and output them to my serial monitor without going through SLIP, the values come out just fine.
It seems to me that either when creating the SLIP packet or when reading it and filling it into a new OSCmessage the value is lost.
Does anyone have any tips to what could be wrong?
Here is the code on the ESP:
OSCMessage testMsg("/Fader/Value");
testMsg.add(42.0);
SLIPSerial.beginPacket();
testMsg.send(SLIPSerial);
SLIPSerial.endPacket();
testMsg.empty();
And the code for receiving messages on the Teensy:
OSCMessage msgIN;
//wait for the end of the packet to be received
while(!SLIPSerial.endofPacket())
{
int size = SLIPSerial.available();
if (size > 0)
{
//fill the msg with all of the available bytes
while(size--)
{
msgIN.fill(SLIPSerial.read());
}
if(!msgIN.hasError())
{
msgIN.route("/OnOff/toggle1",toggleOnOff);
msgIN.route("/Fader/Value",funcValue);
msgIN.route("/XY/xy",xy);
}
}
}
Arduino Mega 2560
I noticed that each time I run .route when compiling the following warning is created.
Sketchbook\libraries\OSC-master/OSCMessage.h:297:7: note: initializing argument 2 of 'bool OSCMessage::route(const char*, void (*)(OSCMessage&, int), int)'
bool route(const char * pattern, void (*callback)(OSCMessage &, int), int = 0);
The sketch completes compiling, loads to the Mega, and looks to work just fine. I am using TouchOSC (Android) via WIFI through my home WIFI router to a WIFI module connected to my Mega.
I am woefully ignorant of what library code does, I cannot see that it in anyway causes a problem.
I am only reporting this issue in case there is a problem I don't see which might create a problem in some other environment.
since 698eb70, getBlob
method always returns 0
and the buffer is not filled with values.
before that commit the first 4 bytes were filled with the blob size (which is a bug that should be fixed).
now is doesn't work at all.
here is the code I'm using for testing : https://gist.github.com/avilleret/4b020ea34bd2f5bc1692
Tested on Arduino UNO and Teensy 3.2
When I try to use a variable with a string value I get an error.
Error code: "note: no known conversion for argument 1 from 'String' to 'const OSCData&'"
Not sure if its an issue with the ESP8266 board using the Arduino IDE, the OSC library or my own inexperience. Any help, greatly appreciated. Thank you
Using Arduino IDE 1.6.9
OSC Library v1.3.3
ESP8266 12e (Esp8266 Board plug in for Arduino IDE v 2.3.0)
Example code from project below.
Function that is giving me the error. The function just takes the variable "doorFrame" which is an integer, converts it to a string and sends it to a label on TouchOSC.
`void sendDoor(OSCMessage &msg, int addrOffset) {
OSCMessage doorMsg("/Door/getSize");
String _doorFrame = String(doorFrame); //Currently getting an error when I feed a string to .add().
doorMsg.add(_doorFrame);
OSCMsgSend(doorMsg, touchOscIp);
}`
I have also tried just making a new string variable and passing that but it also gives me an error.
`void sendDoor(OSCMessage &msg, int addrOffset) {
OSCMessage doorMsg("/Door/getSize");
String myString = "I'm a string"; //Currently getting an error when I feed a string to .add().
doorMsg.add(myString);
OSCMsgSend(doorMsg, touchOscIp);
}`
I'm receiving bundles ok but I never get to the function specified in the arguments of dispatch.
I am running the ESP8266Receive Bundle sketch. Here are the only bits I've altered.
Serial monitor reports 'dispatched' but I never get a 'received' message.
void led(OSCMessage &msg) {
Serial.println("received");
ledState = msg.getInt(0);
Serial.println("received");
digitalWrite(BUILTIN_LED, ledState);
Serial.print("/led: ");
Serial.println(ledState);
}
void loop() {
OSCBundle bundle;
int size = Udp.parsePacket();
if (size > 0) {
while (size--) {
bundle.fill(Udp.read());
}
if (!bundle.hasError()) {
bundle.dispatch("/led", led);
Serial.println("dispatched");
} else {
error = bundle.getError();
Serial.print("error: ");
Serial.println(error);
}
}
}
I've been using this library with the STM32F0-Discovery board. Works great, but I noticed incoming packets getting processed twice. It seems SLIPEncodedSerial::endofPacket() can return true on the starting EOT. Used this hack to stop that behavior:
// use msgInSize hack cause endofPacket can return true at beginning AND end of a packet
int msgInSize = 0;
while((!SLIPSerial.endofPacket()) || (msgInSize < 4) ) {
if( (size =SLIPSerial.available()) > 0) {
while(size--) {
msgIn.fill(SLIPSerial.read());
msgInSize++;
}
}
}
Don't know if I'm missing something.... if there are more bytes in the serial buffer after the starting EOT, this won't happen, but if there is just the starting EOT when SLIPSerial.available() is checked, it will set rstate=FIRSTEOT and endofPacket() returns true. Didn't notice on Arduino, but maybe that is becuase STM32F0 chews bytes so much faster....
our STM32F0 rough port is here
https://github.com/critterandguitari/OSC/tree/master/STM32F0_OSC/Blinking_STM32F0
The examples are written in a way which is not easily scalable for beginners. I spend considerable time figuring out how to make this library work for me and to avoid this hassle for others, please consider adding a basic send and receive example similar to mine pasted below.
/*
Example send and receive OSC over serial
by Arvid Jense
21-5-2015
*/
#include <OSCBundle.h>
#include <SLIPEncodedSerial.h>
SLIPEncodedSerial SLIPSerial(Serial);
int testValue = 1337;
//basic timer
unsigned long timer = 0; // will store last time updated
unsigned long timerInterval = 1000; // interval at which to time (milliseconds)
void setup() {
SLIPSerial.begin(115200);
pinMode(13, OUTPUT);
}
void loop() {
//check for new messages as fast as possible
receiveOSC();
//echo the value every timerInterval
unsigned long currentMillis = millis();
if (currentMillis - timer > timerInterval) {
timer = currentMillis;
sendOSC();
}
}
void receiveOSC() {
OSCMessage messageIN;
int size;
//receive a bundle
if (SLIPSerial.available()) {
while (!SLIPSerial.endofPacket())
if ( (size = SLIPSerial.available()) > 0)
{
while (size--)
messageIN.fill(SLIPSerial.read());
}
if (!messageIN.hasError())
{
messageIN.dispatch("/test/in", action);
}
}
}
void action(OSCMessage &msgIn) {
int testValue = msgIn.getInt(0);
}
void sendOSC() {
OSCMessage msg("/test/out");
msg.add(testValue);
SLIPSerial.beginPacket();
msg.send(SLIPSerial); // send the bytes to the SLIP stream
SLIPSerial.endPacket(); // mark the end of the OSC Packet
msg.empty(); // free space occupied by message
}
Hi,
I'm trying to use this library with the new Arduino MKR1000 board, which uses the WiFi101 library (a modified version of the WiFi library) to communicate.
Receiving messages on the board works like a charm, I've tried it both with TouchOSC and Processing, and have managed to control one of the PWM pins on the board remotely.
The problem appears when trying to send messages from the board to the computer: no matter what I try, I can't seem to create "correct" OSC messages that my receivers can interpret.
Checking with the example codes I think the issue can only lie with one of the three following calls:
Udp.beginPacket(remIP, remPort);
msg.send(Udp);
Udp.endPacket();
I've reached this conclusion because comparing the code of WifiUDP with that of EthernetUDP (with which the same code works) I've seen that the code is quite different, but I'm not savvy enough to identify which pieces of the code might be critical.
The question is: do any of these functions add/require something to/from the UDP packet? The reason I'm asking this is that going deeper and analyzing the packets with Wireshark, I've realized that (at least) precisely 4 bytes are wrong, so maybe something is screwing the 4-padding requirement of OSC up? Here are the images of the capture that make me suspect this (I'm trying to send "layer1/clip1/connect 1"):
Any help and ideas would be greatly appreciated. Thanks a lot in advance!
I'm researching a way to synchronise different Arduino's (well actually Particle Photons) on a network. In this case to display animations at the same time. Research NTP I came across the OSC time tag.
However I can only find literature from about 10 years ago. Are there working implementations (preferably Arduino)?
In file included from /home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.cpp:1:
/home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.h:22: error: ISO C++ forbids declaration of ‘StreamSPI’ with no type
/home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.h:22: error: expected ‘;’ before ‘*’ token
/home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.h:28: error: expected `)' before ‘&’ token
/home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.cpp:8: error: expected `)' before ‘&’ token
/home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.cpp: In member function ‘bool SLIPEncodedSPISerial::endofPacket()’:
/home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.cpp:29: error: ‘serial’ was not declared in this scope
/home/jmunsch/Downloads/arduino/arduino-1.0.5/libraries/OSC/SLIPEncodedSPISerial.cpp: In member function ‘virtual int SLIPEncodedSPISerial::available()’:
Is there something that I am not understanding? This occurs when trying to compile/verify "SerialSendBundle.ino" I see also that there is a fork that may have the corrections (52efba7), but I tried that code too, but to no success.
Arduino Version: 1.0.5
Thanks
Message and Bundle should both allow an argument to be used with the callback.
This library no longer works out-of-the-box with the Teensy 3.1, using the Teensy Loader 1.18-rc1 and Arduino 1.0.5 on OSX 10.8.5.
#include <SLIPEncodedUSBSerial.h>
Fails with the following error.
Arduino/libraries/OSC/SLIPEncodedUSBSerial.h:22:21: fatal error: usb_api.h: No such file or directory
In the SLIPEncodedUSBSerial.h
,
//import the serial USB object
#if defined (__MK20DX128__) || defined(BOARD_maple_mini)
#include <usb_serial.h>
#elif defined(CORE_TEENSY)
#include <usb_api.h>
Fails, because the Teensy 3.0 code on longer uses usb_api.h—it's now using usb_serial.h.
If I modify the code to read:
//import the serial USB object
#if defined (__MK20DX128__) || defined(BOARD_maple_mini) || defined(CORE_TEENSY)
#include <usb_serial.h>
#elif defined(CORE_TEENSY)
#include <usb_api.h>
#elif defined(__SAM3X8E__)
I no longer get compilation errors, and the application works properly.
I apologize, I only have a Teensy 3.1 so I couldn't test if this works with other models, and I don't know how to differentiate between the models, so I'm uncomfortable fixing it myself. My modification works for me right now, and if there's something I can do to help get it fixed globally, please let me know.
Thanks!
Hi,
I've been playing around with trying to use the .match function. Below is my code. I'm trying to see if more than 17 characters match, if so the contents of the message is to be put into a char array. If not, then the message is not inserted into the char array. And the new incoming message takes its place.
while (ResponseCount != ResponsesNeeeded+1) {
if ( (size = Udp.parsePacket()) > 0)
{
while (size--) {
msg[ResponseCount].fill(Udp.read());
}
Serial.println("Match Number");
int matchnum = msg[ResponseCount].match("/eos/out/fader",0)+msg[ResponseCount].match("name",19);
Serial.println(matchnum);
Serial.println(FaderNames[ResponseCount]);
if(matchnum >= 17){msg[ResponseCount].getString(0, FaderNames[ResponseCount], 20); Serial.println(FaderNames[ResponseCount]); ResponseCount++;}
}
}
The variable, when run, matchnum always equals 0 if the if statement is included in the code. If the if statement is removed as shown below, but the ResponseCount increment is still included, then it prints to the console 18. which is the correct amount of characters.
while (ResponseCount != ResponsesNeeeded+1) {
if ( (size = Udp.parsePacket()) > 0)
{
while (size--) {
msg[ResponseCount].fill(Udp.read());
}
Serial.println("Match Number");
int matchnum = msg[ResponseCount].match("/eos/out/fader",0)+msg[ResponseCount].match("name",19);
Serial.println(matchnum);
Serial.println(FaderNames[ResponseCount]);
ResponseCount++;
}
}
Edit: With more experimentation it turns out that it is extremely temperamental.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.