problem with UDP receive
Hi people,
my project is to connect some sensors that transmit through a wireless router to max (with windows) with UDP packets. Using the object of max udp receive I found problems: "OSC packet size not a multiple of 4 bytes" or if I put full-packet max gives me a series of numeridi which I know to interpret their meaning.
Does anyone know advise me or tell me a way to solve this problem?
Thanks in advance for your help!
Luca
How do you form the OSC packets? You can read here how the OSC packets are specified:
If you are reading sensor data with an Arduino and sending OSC packets from the Arduino (with a Yun or an ethernet shield perhaps), you can maybe use CNMAT's OSC libraries. They behaved pretty good for me in the past.
Hi thank you for your reply.
the sensors are connected to a router to which send their data wirelessly. This router is connected usb to pc and is managed by a program that allows us to take the packets in UDP format. So I tried to use the object RECEIVE UDP but this tells us that the incoming UDP packets are not the right size that would MAX. I have to find a way to transform the packets coming from the router in the format that requires udpreceive or switch to max data in another way.
Do you have any other advice for me?
the standard max [udpreceive] object will only accept osc-formatted messages. try using wireshark https://www.wireshark.org/download.html to see what is actually being transmitted-- it is probably not osc format, which means you'll need to use another method. you could try using [mxj net.udp.recv], but that only accepts (or interprets data as) ascii encoded bytes (and you need java installed);
using the second output of jit.net.recv wont work because it uses tcp/ip
you could try the 3rd party object sadam.udpReceiver which receives raw bytes without attempting to 'interpret' them
Thanks guys for your help I was able to finally receive the packages on MAX. Since you have been so kind and prepared, I would like to ask you another question: I received these packages in them contain data of various kinds from the sensors and separated by semicolons, I would just take some information from these data, there is a way to select which characters or otherwise take what information and discard the rest?
the format of the received packet is done this way:
DeviceID;ActorName;BoneName;QuaternionW;QuaternionX;QuaternionY;QuaternionZ;AccX;AccY;AccZ;GyroX;GyroY;GyroZ;MagnX;MagnY;MagnZ
Many thanks in advance for your help
try using regexp
Thanks a lot of rapid response . I have read the help of the command regexp but being still impractical program I need a hand . These packages udp I receive are streaming ( I get one per second ) and have that size that I posted . Someone I can give an example of pacth ? Thanks a lot of patience . For now I used the command MXJ net.udp.recv to get packages udp ... then ? What do I send the output of the object ?
can you connect a print object to the output of the mxj object and copy what is posted to the max window and post it here?
Luca - I am wondering how you got on with this as it sound similar to the problem I am working on. I need to send messages my un via a wireless router connect through my thunderbolt. What format did you have succeed in u sending the messages in? Be great if you would share the patch.
Cheers
I'm also struggling with wireless connecting my sensors via the new Wemos D1 mini and the udp protocol. Bit oblvious how to approach this. So I've you have an example of how you did it, you would help out a fellow struggler.
After a little research I decided this was the wrong way to do it. As far as I can tell MAX cant send fully formed message via wireless without some external scripting being done so... I decided it was simpler to do it in Processing for what I needed. I would love to be wrong so maybe someone can correct me.
Hey guys,
Same here: trying to send sensor data from Adafruit Feather WICED to Max with OSC. Over WireShark it looks like the OSC messages are transferred in the right syntax, but instead of having a complete OSC message per packet, the message in divided to several packets .
Has anybody had any success in sending OSC messages to max as easily as it's supposed to be?
James - can you please elaborate on the coding needed to solve this?
here's my code (OSC stuff mostly at the bottom, in the loop void):
[code]
#include
#include
//#include
#include
#include
#include
#include
#include
//#include
//#include
#include
#include
#include
#define WLAN_SSID "CCCCCC"
#define WLAN_PASS "DDDDDD"
#define LOCAL_PORT 7776
#define REMOTE_IP "10.0.0.12"
AdafruitUDP udp;
typedef union {
float flt;
byte bin[4];
} binFloat;
binFloat counter;
bool connectAP(void)
{
// Attempt to connect to an AP
Serial.print("Attempting to connect to: ");
Serial.println(WLAN_SSID);
if ( Feather.connect(WLAN_SSID, WLAN_PASS) )
{
Serial.println("Connected!");
}
else
{
Serial.printf("Failed! %s (%d)", Feather.errstr(), Feather.errno());
Serial.println();
}
Serial.println();
return Feather.connected();
}
void setup()
{
Serial.begin(115200);
// wait for Serial port to connect. Needed for native USB port only
while (!Serial) delay(1);
Serial.println("UDP Echo Callback Example");
Serial.println();
while( !connectAP() )
{
delay(500);
}
udp.begin(LOCAL_PORT);
}
void loop()
{
counter.flt += 1;
float count = counter.flt;
OSCBundle bndl;
bndl.add("/counter").add(count);
bndl.add("/text").add("blablablo");
udp.beginPacket(REMOTE_IP, LOCAL_PORT);
bndl.send(udp);
udp.endPacket();
bndl.empty();
delay(500);
}
[/code]
In WireShark I see a separate packet for "#bundle", then some 00 (zero) packets, then the "/counter" packet, then more zeros etc.
So the syntax is correct, but the division of a single message to several packets while Max is expecting to find one message per packet causes all the trouble. At least that is my theory (-;
Does all this sound familiar to anyone? Am I doing something wrong?
Did anyone solve this?
I'd love to hear !
thanks,
ith