Hi,
I am trying to read the messages that TouchOSC is sending. I have an enc28j60 connected to my arduino uno 328.
My goal is to read out messages send by TouchOSC without having a computer in between. It is already working, but i still have 2 questions.
In TouchOSC I have a couple of push buttons that have an "pressed" and an "released" value.
This control sends the second value of its value range when pressed and the first value of its value range when released.
The "Pressed" value is 1 and the "released" value is 0.
for now my code gives me the following serial output if i press an push button one:
initialize: success
received: '/1/push1'
remote ip: 192.168.178.18
remote port: 62199
restart connection: success
received: '/1/push1'
remote ip: 192.168.178.18
remote port: 62199
restart connection: success
/1/ means on which page the object is on, push1 is the name of the push button their also should be a value but i can't get that value.
The first block of info is when i press the push button and the second block is when i release the push button.
So my question is:
1: is it possible to only get the first block of information(the message's are received about 50 milliseconds apart, so I was thinking about some kind of timeout?).
2: Is it possible to also get the value that ToucOSC is sending?
my code is based on the UDPserver example from the UIPEthernet library :
#include <UIPEthernet.h>
EthernetUDP udp;
void setup() {
Serial.begin(9600);
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
Ethernet.begin(mac,IPAddress(192,168,178,88));
int success = udp.begin(5000);
Serial.print("initialize: ");
Serial.println(success ? "success" : "failed");
}
void loop() {
//check for new udp-packet:
int size = udp.parsePacket();
if (size > 0) {
do
{
char* msg = (char*)malloc(size+1);
int len = udp.read(msg,size+1);
msg[len]=0;
Serial.print("received: '");
Serial.print(msg);
free(msg);
}
while ((size = udp.available())>0);
//finish reading this packet:
udp.flush();
Serial.println("'");
int success;
do
{
Serial.print("remote ip: ");
Serial.println(udp.remoteIP());
Serial.print("remote port: ");
Serial.println(udp.remotePort());
//send new packet back to ip/port of client. This also
//configures the current connection to ignore packets from
//other clients!
success = udp.beginPacket(udp.remoteIP(),udp.remotePort());
//beginPacket fails if remote ethaddr is unknown. In this case an
//arp-request is send out first and beginPacket succeeds as soon
//the arp-response is received.
}
while (!success);
udp.stop();
//restart with new connection to receive packets from other clients
Serial.print("restart connection: ");
Serial.println (udp.begin(5000) ? "success" : "failed");
Serial.println(" ");
delay(200);
}
}