Pages: [1]   Go Down
Author Topic: Problems with Arduino and MAX/MSP (UDP communication)  (Read 1480 times)
0 Members and 1 Guest are viewing this topic.
Udine, IT
Offline Offline
Newbie
*
Karma: 1
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everybody, I've created a new topic a couple of weeks ago in the Software section of the forum to ask about the problem I'm going to exhibit right now. I think that asking again here will be better since the problem is (probably) not about the Arduino and it's code but MAX/MSP.

This is a prntscreen of the MAX sketch I've made

Pretty simple stuff, it collects 3 bytes generated randomly by 3 different "drunk" functions and send them via UDP to the Arduino.

This is the Arduino code
Quote
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>

#define localPort 7400

byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xE5};      
IPAddress ip(192, 168, 1, 177);                

EthernetUDP Udp;                                  

int PACKET_SIZE = 0;

void setup()                                      
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);
}

void loop()
{
  PACKET_SIZE = Udp.parsePacket();
  byte packetBuffer[PACKET_SIZE];
  
  if (PACKET_SIZE > 0)                            
  {
    Udp.read(packetBuffer, PACKET_SIZE);
    
    for (int i = 0; i <PACKET_SIZE; i++)
    {
      Serial.print(packetBuffer);
      
      if (i < (PACKET_SIZE - 1))
        Serial.print(", ");
      else
        Serial.println(".");
    }
  }
}

Easy, it prints unto the serial monitor the data recevied via UDP by MAX/MSP. The problem is here...


I should receive only 3 bytes, I can't understand why I get 28! Also - the correct ones - are the 20th, 24th and 28th. Seems like the others are something that comes from MAX/MSP but I don't know why and I don't know how to avoid this problem. I'm looking for some help, hope you'll enlighten me guys!
Thanks for your tips!

EDIT: I've just discovered something cool, the first 4 bytes (108, 105, 115, 116) compose the word "list", could this help?
« Last Edit: September 28, 2012, 01:43:31 pm by _Matt_ » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Matt,

Have you tried posting this issue on the Cycling74 website?
There are more Max users there- and there is a special project just for using Max with the Arduino (Maxuino).
Chances are you'll get some good answers.

I've just started using Max myself- but haven't tried interfacing to the Arduino yet.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

MaxMSP's netsend is really sending OSC encoded messages. These are more compact to send, but cause headache for manually encoding. But OSC is common enough that googling can either tell you:
how to get OSC into arduino
how to manually decode OSC into readable strings, and then you can repost your solution for the world to see
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Easy, it prints unto the serial monitor the data recevied via UDP by MAX/MSP. The problem is here...


I should receive only 3 bytes, I can't understand why I get 28! Also -

Print out the value of PACKET_SIZE, that is what is controlling your loop
Logged

Pages: [1]   Go Up
Jump to: