Go Down

Topic: TouchOSC via Ardosc/Bonjour (Read 4978 times) previous topic - next topic

gavspav

I'm wondering if anyone can help me get this working or point me towards some examples.

I have an Arduino Uno with a W5100 ethernet shield, and a TP Link WR702N connected via ethernet cable in Client Mode.

I'm hoping to send and receive OSC messages from my ipad using Touchosc to control some lighting.

I can do this already via my laptop (Ipad>Laptop>Arduino>Lights) but hoping to bypass it and go Ipad>TpLink>Arduino>Lights.

I have negotiated the Chinese admin panel and got the router into client mode. I can log into it from my browser so I think its working.

Have downloaded Ardosc and Bonjour libraries but feeling a bit overwhelmed by confusion and not sure how to test each individual step. I've searched for some guidance but haven't found any, at least not in simple enough terms.

Can anyone help?

Thanks if you can!

Headroom

I sure can, as that is how I am controlling my lighting systems  @ trippylighting.com

From your post I am not sure what you have achieved so far as you have not yet posted any code. You mentioned that you downloaded ArdOSC but don't exactly know what to do but earlier in the post you seem to indicate that you can already send and receive OSC messages ?

If you want to connect to the Arduino per WiFi directly from your iPad you don' t need to put the router in client mode but in AP mode. That is how it comes out of the box. I would suggest to start with this first so if " things" don't work, you can at least eliminate your network setup as a source of the problem.

In client mode the TP- Link router actually works like what usually is called bridge mode. It works as a bridge between the Adruino and your home router. No notebook needed either way.

I am not sure where you are located, but when I bought my 702 TP- Link router ( fromm Amazon.com IIRC) it had an English interface. The 703 on the other had had a Chinese interface. But then that came directly from Hongkong and i belive it is not officially sold in the US.

Once you have been able to come up with a functioning, manually configured connection  it's time to start using the DHCP / Bonjour libraries. And I'd suggest to start with only the DHCP library first as you need to establish a network connection before Bonjour can work its magic.

Both of these libraries ( available at gkaindl.com ) have to be brought up to Arduino 1.x level first as you'll get those pesky compile errors. That is easy to do and references for how to do that are plenty and easy to find.

What the DHCP library does is establish a DHCP client on the Arduino. When you start- up your Ardiino the DHCP client will request a DHCP address from the router ( either the TP-linkn when in AP mode, or your home router when the TP-L ink is in bridge mode) and once it has received an address you should be able to see your Arduino on the network.

As the next step I'd look into getting the Bonjour part to work.......

One word of caution. Depending on what Arduino you are using, memory on the Arduino will get pretty scarce when using the DHCP / Bojour and ArdOSC libraries. I switched from an Adruino UNO to a Teensy++2 ( Arduino compatible) for that reason.
http://trippylighting.com

http://ledshield.wordpress.com/

gavspav

Thanks for replying. I bought the router from ebay here in UK - the interface is definitely in Chinese!
Its still in client mode at the moment but yes AP mode would be fine.

When I said previously I had OSC working this was via Max/MSP on my laptop. So I had Touch OSC on the Ipad talking to Max/Msp which communicated with Arduino via the serial port. It worked great so I invested in the router and now trying to do it without the laptop/Max.

I'm forgetting about the bonjour stuff for now and trying to get Ardosc communication working.
I'm just using the examples. I can send a message to my laptop from Arduino but I'm not sure I can receive one.
Its hard to tell though really! I get flashing lights on the ethernet port when I send stuff from the ipad but I can't get the 'Simple Receive' patch to work.

Tried printing messages to serial port and sending osc to my laptop but nothing yet. I did the most minor of alterations to the OSC arguments example to try and relay an ipad message back to my laptop but no luck yet!

I'll keep trying, sure I'll get there soon.

Code: [Select]
#include <SPI.h>
#include <Ethernet.h>

#include <ArdOSC.h>

byte myMac[] = { 0xEC, 0x88, 0x8F, 0xDF, 0x44, 0x44 };
byte myIp[]  = { 192, 168, 1, 50 };
byte destIp[]  = { 192, 168, 1, 106 };


int  serverPort  = 10000;

int destPort=12000;

char oscadr[]="/ard/aaa";

OSCServer server;
OSCClient client;


void setup(){
 
// Serial.begin(19200);

Ethernet.begin(myMac ,myIp);
server.begin(serverPort);

//set callback function
server.addCallback(oscadr,&func1);

}
 
void loop(){
  if(server.aviableCheck()>0){
//     Serial.println("alive! ");
  }
}


void func1(OSCMessage *_mes){
 
  logIp(_mes);
  logOscAddress(_mes);
 
  //get source ip address
  byte *sourceIp = _mes->getIpAddress();

  //get 1st argument(int32)
  int tmpI=_mes->getArgInt32(0);
 
  //get 2nd argument(float)
  float tmpF=_mes->getArgFloat(1);
 
  //get 3rd argument(string)
  int strSize=_mes->getArgStringSize(2);
  char tmpStr[strSize]; //string memory allocation
  _mes->getArgString(2,tmpStr);



  //create new osc message
  OSCMessage newMes;
 
  //set destination ip address & port no
  newMes.setAddress(destIp,destPort);
 
  //set argument
  newMes.beginMessage(oscadr);
  newMes.addArgInt32(tmpI+1);
  newMes.addArgFloat(tmpF+0.1);
  newMes.addArgString(tmpStr);

  //send osc message
  client.send(&newMes);

}




void logIp(OSCMessage *_mes){
  byte *ip = _mes->getIpAddress();
  Serial.print("IP:");
  Serial.print(ip[0],DEC);
  Serial.print(".");
  Serial.print(ip[1],DEC);
  Serial.print(".");
  Serial.print(ip[2],DEC);
  Serial.print(".");
  Serial.print(ip[3],DEC);
  Serial.print(" ");
}

void logOscAddress(OSCMessage *_mes){
  Serial.println(_mes->getOSCAddress());
}



Headroom

Don't worry, we'll get you through this including Bonjour and ArcOSC. I just need a few days, perhaps even until the weekend to go through my code and see how I did it and write it down.

This will be a good exercise for myself so I an document it properly ;-)
http://trippylighting.com

http://ledshield.wordpress.com/

Headroom

The code you've posted is already pretty much there.
I've put together a little example that will get you started only using the standard Arduino Ethernet library requesting an IP address from the router through DHCP and ArdOSC. No Bonjour yet, but this should get you started.

I hope my comments in the code are explanatory enough.

Also attached is the little one-button TouchOSC file to provide a complete working example.

Code: [Select]
#include <SPI.h>
#include <Ethernet.h>
#include <ArdOSC.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

OSCServer server;
OSCClient client;

int serverPort = 8000; //Touch OSC Port (outgoing)
int destPort = 9000;   //Touch OSC Port (incoming)
int ledPin = 13;       //6 on a Teensy++2
int flag=0;

void setup(){
  Serial.begin(115200);
  Serial.println("DNS and DHCP-based OSC server");
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  // print your local IP address:
  Serial.print("Arduino IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }
  Serial.println();
  Serial.println();
 
  //start the OSCserver
  server.begin(serverPort);
 
  //add OSC callback function. One function is needed for every TouchOSC interface element that is to send/receive OSC commands.
  server.addCallback("/Eth_ArdOSC/toggle1", &funcOnOff);
}

void loop(){

if(server.aviableCheck()>0){
     Serial.println("alive! ");
    } 
}

//When the button on the TouchOSC inteface is pressed, a message is sent from the iDevice
//to the Arduino to switch (togle) the LED on the Arduino on/off
//then a messeage is sent bak from the Arduino to the iDevice to toggle the buttom on/off

void funcOnOff(OSCMessage *_mes){
  float value = _mes->getArgFloat(0); //TouchOSC expects float values
 
  //create new osc message
  OSCMessage newMes;
 
  //set destination ip address & port no
  newMes.setAddress(_mes->getIpAddress(),destPort);
  newMes.beginMessage("/Eth_ArdOSC/toggle1");
 
  if(flag==1){
    flag=0;
    Serial.println(value);
    digitalWrite(ledPin, LOW);
  }
  else{
    flag=1;
    Serial.println(value);
    digitalWrite(ledPin, HIGH);
  }
  newMes.addArgFloat(flag);
 
  //send osc message
  client.send(&newMes);
 
}
http://trippylighting.com

http://ledshield.wordpress.com/

Headroom

If adding Bonjour functionality is still of interest I'll post it. Otherwise I tend not to reply to my own posts ;-)
http://trippylighting.com

http://ledshield.wordpress.com/

gavspav

Hey thanks for posting this. It works. Especially once I've remembered to change the ip address in touch osc  :smiley-red:

I'm just back into it after the holiday break and to be honest can't remember what I am doing or why.

Now I've got your example working I'll start to build on it.

I guess I should get a teensy as memory issues are already hobbling me. I'd like to be able to store a few 'images' in memory for my 20 x 10 matrix.I did have a teensy before but snapped the usb port off it. Hate those mini usb ports!

So I guess in all honesty I haven't reached the bonjour stage yet. What I was thinking of was having ios and android devices being able to connect to the led matrix and interact collaboratively with the display. Maybe I'll do that this afternoon.

Thanks for the help. I'll report back!

Headroom

I am glad to hear that it worked for you!

The reason I have not not yet posted the Bonjour part is that I've been grinding my teeth on getting it to work on a WIZ820IO Ethernet Module, which employs the newer W5200 chip from Wiznet. I currently use a Teesny++2 with a  WIZ812MJ Ethernet Module. The Teensy++2 is available here http://www.pjrc.com/teensy/index.html and you can also find the adapter board for the WIZ812MJ there.

I have been able to get DHCP/ArdOSC/Bonjour working on the WIZ820IO as well, but for some reason there is a very noticeable lag when using ArdOSC. I am still investigating what the reason for it is. However,it works flawlessly - withaut any lag - with the WIZ812MJ.

I'e been working a slightly more complete code sample and will post it within the next few days.
http://trippylighting.com

http://ledshield.wordpress.com/

#8
Jan 03, 2013, 12:35 pm Last Edit: Jan 03, 2013, 12:39 pm by justcansin Reason: 1
good info to me, thanks for posting this. It works. Especially once I've remembered to change the ip address in touch os

Headroom

#9
Jan 04, 2013, 04:14 am Last Edit: Jan 04, 2013, 04:16 am by Headroom Reason: 1
So here is a little more complete code sample to also get the Bonjour part to work.

Code: [Select]

//DHCP/Bonjour-based OSC server test code
//for use with IDE 1.0.x
//for use with W5100 or W5200 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetBonjour.h>
#include <ArdOSC.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

//create instances of OSC server and client objects.
OSCServer server;
OSCClient client;

int serverPort  = 8000; //TouchOSC (incoming port)
int destPort = 9000;    //TouchOSC (outgoing port)
int ledPin =  6;        //pin 13 on Arduino Uno. Pin 6 on a Teensy++2
int flag=0;


void setup(){
 Serial.begin(115200);
 Serial.println("DHCP-Bonjour-based OSC server test 12/28/12");
 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
   Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
   while(true);
 }
 // print your local IP address:
 Serial.print("Arduino IP address: ");
 for (byte thisByte = 0; thisByte < 4; thisByte++) {
   // print the value of each byte of the IP address:
   Serial.print(Ethernet.localIP()[thisByte], DEC);
   Serial.print(".");
 }
 Serial.println();
 Serial.println();
 
// Initialize the Bonjour/MDNS library. You can now reach or ping this
// Arduino via the host name "arduino.local", provided that your operating
// system is Bonjour-enabled (such as MacOS X).
// Always call this before any other method!
 
   if (EthernetBonjour.begin("arduino")){
      Serial.println("Setting Bonjour Name successful");
   }
   else{    
     Serial.println("Bonjour Name could not be set");
   }
 
// Now let's register the service we're offering (a web service) via Bonjour!
// To do so, we call the addServiceRecord() method. The first argument is the
// name of our service instance and its type, separated by a dot. In this
// case, the service type is _osc. There are many other service types, use
// google to look up some common ones, but you can also invent your own
// service type, like _mycoolservice - As long as your clients know what to
// look for, you're good to go.
// The second argument is the port on which the service is running. This could be
// port 80 here, the standard HTTP port.
// The last argument is the protocol type of the service, either TCP or UDP.
// Of course, our OSC service is a UDPservice.
// With the service registered, it will show up in the Bonjour Browser on a Mac or
// in the Connections settings in TouchOSC

 if(
   EthernetBonjour.addServiceRecord("Arduino OSC Server._osc",
   8000,
   MDNSServiceUDP)){
   Serial.println("Bonjour Service Record added successfully");
  }
  else{    
     Serial.println("Bonjour Service could not be added");
  }  
 
 //Start the OSC server
 server.begin(serverPort);
 
 //Add callback functions for TouchOSC control element
 //One callback function is needed for each independent TouchOSC control element.
 server.addCallback("/OnOff/toggle1", &funcOnOff);
 server.addCallback("/Fader/Value", &funcValue);
}

void loop(){
 
// This actually runs the Bonjour module. YOU HAVE TO CALL THIS PERIODICALLY,
// OR NOTHING WILL WORK! Preferably, call it once per loop().
EthernetBonjour.run();

if(server.aviableCheck()>0){
    Serial.println("alive! ");
   }    
}


void funcOnOff(OSCMessage *_mes){
 float value = _mes->getArgFloat(0);
 
 //create new osc message
 OSCMessage newMes;
 
 //set destination ip address & port no
 newMes.setAddress(_mes->getIpAddress(),destPort);
 newMes.beginMessage("/OnOff/toggle1");
 
 if(flag==1){
   flag=0;
   Serial.println(value);
   digitalWrite(ledPin, LOW);
 }
 else{
   flag=1;
   Serial.println(value);
   digitalWrite(ledPin, HIGH);
 }
 newMes.addArgFloat(flag);
   
 //send osc message back to controll 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.
 client.send(&newMes);
 
}

void funcValue(OSCMessage *_mes){

 long value = (int) _mes->getArgFloat(0);

 Serial.print("Value = : ");
 Serial.println(value);

  //create new osc message
 OSCMessage newMes;

 //set destination ip address & port no
 newMes.setAddress(_mes->getIpAddress(),destPort);
 newMes.beginMessage("/Fader/Value");
 newMes.addArgFloat(value);

 //send osc message
 client.send(&newMes);
}]//DHCP/Bonjour-based OSC server test code
//for use with IDE 1.0.x
//for use with W5100 or W5200 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetBonjour.h>
#include <ArdOSC.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

//create instances of OSC server and client objects.
OSCServer server;
OSCClient client;

int serverPort  = 8000; //TouchOSC (incoming port)
int destPort = 9000;    //TouchOSC (outgoing port)
int ledPin =  6;        //pin 13 on Arduino Uno. Pin 6 on a Teensy++2
int flag=0;


void setup(){
 Serial.begin(115200);
 Serial.println("DHCP-Bonjour-based OSC server test 12/28/12");
 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
   Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
   while(true);
 }
 // print your local IP address:
 Serial.print("Arduino IP address: ");
 for (byte thisByte = 0; thisByte < 4; thisByte++) {
   // print the value of each byte of the IP address:
   Serial.print(Ethernet.localIP()[thisByte], DEC);
   Serial.print(".");
 }
 Serial.println();
 Serial.println();
 
// Initialize the Bonjour/MDNS library. You can now reach or ping this
// Arduino via the host name "arduino.local", provided that your operating
// system is Bonjour-enabled (such as MacOS X).
// Always call this before any other method!
 
   if (EthernetBonjour.begin("arduino")){
      Serial.println("Setting Bonjour Name successful");
   }
   else{    
     Serial.println("Bonjour Name could not be set");
   }
 
// Now let's register the service we're offering (a web service) via Bonjour!
// To do so, we call the addServiceRecord() method. The first argument is the
// name of our service instance and its type, separated by a dot. In this
// case, the service type is _osc. There are many other service types, use
// google to look up some common ones, but you can also invent your own
// service type, like _mycoolservice - As long as your clients know what to
// look for, you're good to go.
// The second argument is the port on which the service is running. This could be
// port 80 here, the standard HTTP port.
// The last argument is the protocol type of the service, either TCP or UDP.
// Of course, our OSC service is a UDPservice.
// With the service registered, it will show up in the Bonjour Browser on a Mac or
// in the Connections settings in TouchOSC

 if(
   EthernetBonjour.addServiceRecord("Arduino OSC Server._osc",
   8000,
   MDNSServiceUDP)){
   Serial.println("Bonjour Service Record added successfully");
  }
  else{    
     Serial.println("Bonjour Service could not be added");
  }  
 
 //Start the OSC server
 server.begin(serverPort);
 
 //Add callback functions for TouchOSC control element
 //One callback function is needed for each independent TouchOSC control element.
 server.addCallback("/OnOff/toggle1", &funcOnOff);
 server.addCallback("/Fader/Value", &funcValue);
}

void loop(){
 
// This actually runs the Bonjour module. YOU HAVE TO CALL THIS PERIODICALLY,
// OR NOTHING WILL WORK! Preferably, call it once per loop().
EthernetBonjour.run();

if(server.aviableCheck()>0){
    Serial.println("alive! ");
   }    
}


void funcOnOff(OSCMessage *_mes){
 float value = _mes->getArgFloat(0);
 
 //create new osc message
 OSCMessage newMes;
 
 //set destination ip address & port no
 newMes.setAddress(_mes->getIpAddress(),destPort);
 newMes.beginMessage("/OnOff/toggle1");
 
 if(flag==1){
   flag=0;
   Serial.println(value);
   digitalWrite(ledPin, LOW);
 }
 else{
   flag=1;
   Serial.println(value);
   digitalWrite(ledPin, HIGH);
 }
 newMes.addArgFloat(flag);
   
 //send osc message back to controll 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.
 client.send(&newMes);
 
}

void funcValue(OSCMessage *_mes){

 long value = (int) _mes->getArgFloat(0);

 Serial.print("Value = : ");
 Serial.println(value);

  //create new osc message
 OSCMessage newMes;

 //set destination ip address & port no
 newMes.setAddress(_mes->getIpAddress(),destPort);
 newMes.beginMessage("/Fader/Value");
 newMes.addArgFloat(value);

 //send osc message
 client.send(&newMes);
}



http://trippylighting.com

http://ledshield.wordpress.com/

Headroom

Unfortunately I had to break this post into two parts as the forum only appears to allow messages up to 9500 characters(?), so here is the second part.

The EthernetBonjour library in it's original form  http://gkaindl.com/software/arduino-ethernet was not compatible with the Arduino 1.0.x IDE, so I performed the necessary minor changes to allow using this library in the 1.0.x IDE. I also applied changes to get it to work with Ethernet shields or modules that employ the W5200 chip (vs. the usual W5100) and while it works, the ArdOSC part is laggy and screen feedback in TouchOSC is noticeably slower than with a W5100 based Ethernet shield or the WIZ812MJ Ethernet Module that I am using in conjunction with my Teensy++2 micro controller board. I am not sure where the problem is and may start another thread to get feedback from some more experienced folks.

Attached are the modified EthernetBojour library and rthe TouchOSC layout that the above code example works with.
If one wants to test out these on a W5200 basd Ethernet while or Module I have also attached an updated Ethernet library  that I found a reference to here on the forum. The original is hosted on github. I don't have the links to the forum thread or to the github repository handy so I won't post these.
The Ethernet Library files are meant to replace the respective Arduio IDE libraries. To "switch" between which chip to compile for you have to comment/uncomment the "#define W5200" line in W5100.h. Don't forget to restart the IDE ;-)

Hope this is useful for someone. I have used it successfully in my project(s) to remotely control lighting systems trippylighting.com
http://trippylighting.com

http://ledshield.wordpress.com/

gavspav

Hey thanks for posting that code. I'll look into it.

I actually started using the z_osc library as opposed to Ardosc as I couldn't work out how to parse the incoming osc addresses using Ardosc (which I needed to do to use touch osc's multitoggle's).

I am sure this is due to inability on my part as opposed to any problems with the library. In fact I'm not even sure if there is any difference between the libraries!

I've got a basic wifi set up working now. Thanks alot for your help.

I'm wondering at what rate I can pass data to the Arduino via wifi. ie could I stream pixel data to my 20x10 array at >15fps. I never intended to do this before but now I'm wondering if its possible. Obviously it depends in part on the network. I guess OSC isn't necessarily the best way of doing this. In fact it might warrant another thread.....

Nixon123

hi guys, thanks for your wonderful code examples, i m trying to get a connection between open frameworks an an arduino ethernet, i can send data from the open frameworks application and i can receive some data, but not a certain value.  Seems like some problems gavspav had too. I think i have some understanding problem of the addCallback function and things related. I'll also post my open frameworks code too, might be useful.




of in header
Code: [Select]

#define HOST "192.168.178.130" //arduino ip
#define RPORT 12000 //incoming
#define SPORT 10000 //outgoing
#define NUM_MSG_STRINGS 100


in cpp
Code: [Select]

cout << "listening for osc messages on port " << RPORT << "\n";
receiver.setup(RPORT); //set up receiver
sender.setup(HOST, SPORT); //set up sender





of sending function

Code: [Select]

void oscc::sendMessages(){

ofxOscMessage m;
m.setAddress("/Eth_ArdOSC/toggle2");
m.addFloatArg(3.0);
sender.sendMessage(m);
}


the arduino code

Code: [Select]


#include <SPI.h>
#include <Ethernet.h>

#include <ArdOSC.h>

OSCServer server;
OSCClient client;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

int  serverPort=10000; //OF incoming port
int destPort=12000; //OF outcoming port

float wert;
int flag=0;

void setup(){

Serial.begin(115200);
 Serial.println("DNS and DHCP-based OSC server");
 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
   Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
   while(true);
 }
 // print your local IP address:
 Serial.print("Arduino IP address: ");
 for (byte thisByte = 0; thisByte < 4; thisByte++) {
   // print the value of each byte of the IP address:
   Serial.print(Ethernet.localIP()[thisByte], DEC);
   Serial.print(".");
 }
 Serial.println();
 Serial.println();
 
 //start the OSCserver
 server.begin(serverPort);
 
 //add OSC callback function. One function is needed for every TouchOSC interface element that is to send/receive OSC commands.
 server.addCallback("/Eth_ArdOSC/toggle2", &funcOnOff);
}
 
void loop(){
 
if(server.aviableCheck()>0){
    Serial.println("alive! ");
     Serial.println(wert);
   }    
}


void funcOnOff(OSCMessage *_mes){
 float value = _mes->getArgFloat(0);
 //create new osc message
 wert=value;
 OSCMessage newMes;
 
 //set destination ip address & port no
 newMes.setAddress(_mes->getIpAddress(),destPort);
 newMes.beginMessage("/Eth_ArdOSC/toggle1");
 
 newMes.addArgFloat(value);
 client.send(&newMes);
}





the serial board output (when starting the sending osc function in of by pressing a key):

Code: [Select]

?óDNS and DHCP-based OSC server
Arduino IP address: 192.168.178.130.

alive!
0.00
alive!
0.00
alive!
0.00
alive!
0.00
alive!
0.00



so it should write 3.00 not 0.00.... :(



Headroom

#13
Jan 09, 2013, 01:09 am Last Edit: Jan 09, 2013, 01:18 am by Headroom Reason: 1
I am not sure that is the entire solution to the problem, but I believe that the format of what you want to send in the open frameworks code is:

Code: [Select]
m.addFloatArg(3.0f);
rather than the
Code: [Select]
m.addFloatArg(3.0);

The "f" behind the "3.0"  designates that it is actually a float value.

Also my gut feeling is that you'd be better off putting the :

Code: [Select]
Serial.println(wert);

Into the callback function right after you've assigned value to wert.
http://trippylighting.com

http://ledshield.wordpress.com/

Nixon123

hey, thanks for your help :)
i've changed the entry in OF -> no change, i placed Serial.println(wert) into the funcOnOff function but now there isn't any serial printout besides alive!

Code: [Select]

void funcOnOff(OSCMessage *_mes){
  float value = _mes->getArgFloat(0);
  //create new osc message
  wert=value;
  Serial.println(wert);
  OSCMessage newMes;
 
 
  //set destination ip address & port no
  newMes.setAddress(_mes->getIpAddress(),destPort);
  newMes.beginMessage("/Eth_ArdOSC/toggle1");
 
  newMes.addArgFloat(value);
  client.send(&newMes);
}

Go Up