Artnet SoftPWM 'EthernetUDP library error'

Hi, I'm trying to get this code to work with my arduino, but I can't seem to be able to do this, as the sketch uses the old UDP library, instead of the new EthernetUDP library. If anyone can help me get this working I will be eternally grateful. I'm an arduino novice, so sorry for the question!

ARTNET_receiver_softPWM.pde (5.97 KB)

I'm an arduino novice

That doesn't mean that you can't describe your problem better than "this doesn't work".

Are you having problems compiling the code? Or, does the program not do what you want when it runs? What does it do? What do you want it to do?

PaulS:

I'm an arduino novice

That doesn't mean that you can't describe your problem better than "this doesn't work".

Are you having problems compiling the code? Or, does the program not do what you want when it runs? What does it do? What do you want it to do?

Program refuses to compile due to the UDP library being superseded by the EthernetUDP library. I can't find a way to solve the issue of the library, so this is where I need assistance!

Program refuses to compile

I'm sure that you are getting more information than that. Share it, or solve the problem yourself.

What more information do you need? I can post code if you want. I click compile and this is all I get: I'm unsure of how to mitigate the issue of the updated library

What more information do you need?

The exact error messages you get.

I can post code if you want.

You already did. It uses a lot of libraries I don't have, so I can't compile it.

I click compile and this is all I get:

What is?

I'm unsure of how to mitigate the issue of the updated library

You still haven't defined what "the issue" is.

I posted a picture of the error! The code will not compile, because the code uses an old library, so I'm trying to find out how to utilise the newer library as I am unsure. Here is the code. I

/*
ARTNET RECEIVER V3 plus SOFT PWM
This SCRIPT allows you to use arduino with ethernet shield or wifi shield and recieve artnet data. Up to you to use channels as you want.

It works with Arduino 023 software

If you have implemented ameliorations to this sketch, please, contribute by sending back modifications, ameliorations, derivative sketch. It will be a pleasure
to let them accessible to community



For VVVV patchers, please think to put a mainloop node in your patch: minimum frame rate is 40fps with bulbs. But do not go too much higher ( max 100 fps).

This sketch is part of white cat lighting board suite: /http://www.le-chat-noir-numerique.fr  
wich is sending data to many different types of devices, and includes a direct communication in serial also with arduino likes devices
you may find whitecat interresting because its theatre based logic ( cuelist and automations) AND live oriented ( masters, midi, etc)

(c)Christoph Guillermet
http://www.le-chat-noir-numerique.fr
karistouf@yahoo.fr
*/


#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <Udp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#define short_get_high_byte(x) ((HIGH_BYTE & x) >> 8)
#define short_get_low_byte(x)  (LOW_BYTE & x)
#define bytes_to_short(h,l) ( ((h << 8) & 0xff00) | (l & 0x00FF) );
#include <SoftPWM.h>


//MAC and IP of the ethernet shield
//MAC adress of the ethershield is stamped down the shield
//to translate it from hexa decimal to decimal, use: http://www.frankdevelopper.com/outils/convertisseur.php
//HARDWARE
byte mac[] = {  144, 162, 218, 00, 16, 96  };//the mac adress of ethernet shield or uno shield board
byte ip[] = {   192,168,1,177 };// the IP adress of your device, that should be in same universe of the network you are using, here: 192.168.1.x

// the next two variables are set when a packet is received
byte remoteIp[4];        // holds received packet's originating IP
unsigned int remotePort; // holds received packet's originating port

//customisation: edit this if you want for example read and copy only 4 or 6 channels from channel 12 or 48 or whatever.
const int number_of_channels=512; //512 for 512 channels
const int channel_position=1; // 1 if you want to read from channel 1

// buffers
const int MAX_BUFFER_UDP=1024;//definition to do to make work UDP lib
char packetBuffer[MAX_BUFFER_UDP]; //buffer to store incoming data
byte buffer_dmx[number_of_channels+channel_position]; //buffer to store filetered DMX data

// art net parameters
unsigned int localPort = 6454;      // artnet UDP port is by default 6454
const int art_net_header_size=17;
const int max_packet_size=576;
char ArtNetHead[8]="Art-Net";
char OpHbyteReceive=0;
char OpLbyteReceive=0;
short is_artnet_version_1=0;
short is_artnet_version_2=0;
short seq_artnet=0;
short artnet_physical=0;
short incoming_universe=0;
boolean is_opcode_is_dmx=0;
boolean is_opcode_is_artpoll=0;
boolean match_artnet=1;
short Opcode=0;


void setup() {
  //déclaration des ports PWM 
  //ici une diode pour test
  SoftPWMBegin();
  pinMode(2, OUTPUT);  //check with leds + resistance in pwm, this will not work with pins 10 and 11, used by RJ45 shield
  pinMode(4, OUTPUT);  //check with leds + resistance in pwm, this will not work with pins 10 and 11, used by RJ45 shield
  pinMode(7, OUTPUT);  //check with leds + resistance in pwm, this will not work with pins 10 and 11, used by RJ45 shield 
  pinMode(8, OUTPUT);  //check with leds + resistance in pwm, this will not work with pins 10 and 11, used by RJ45 shield 
  pinMode(9, OUTPUT);  //check with leds + resistance in pwm, this will not work with pins 10 and 11, used by RJ45 shield
  pinMode(12, OUTPUT);  //check with leds + resistance in pwm, this will not work with pins 10 and 11, used by RJ45 shield 
 
  // démarrage ethernet et serveur UDP
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
}

void loop() {
  
  int packetSize = Udp.available();
  if( packetSize>art_net_header_size && packetSize<=max_packet_size)//check size to avoid unneeded checks
  {
    Udp.readPacket(packetBuffer,MAX_BUFFER_UDP, remoteIp, remotePort);  
    //read header
     match_artnet=1;//valeur de stockage
     for (int i=0;i<7;i++)
     {
      if(char(packetBuffer[i])!=ArtNetHead[i])
      {match_artnet=0;break;}//if not corresponding, this is not an artnet packet, so we stop reading
     } 
     if (match_artnet==1)//if its an artnet header
     { 
          /*artnet protocole revision, not really needed
          is_artnet_version_1=packetBuffer[10]; 
          is_artnet_version_2=packetBuffer[11];*/
      
          /*sequence of data, to avoid lost packets on routeurs
          seq_artnet=packetBuffer[12];*/
          
          /*physical port of  dmx N°
          //artnet_physical=packetBuffer[13];*/
      
     //operator code enables to know wich type of message Art-Net it is
     Opcode=bytes_to_short(packetBuffer[9],packetBuffer[8]);
     
     if(Opcode==0x5000)//if opcode is DMX type
      {
       is_opcode_is_dmx=1;is_opcode_is_artpoll=0;
       }   
       
     else if(Opcode==0x2000)//if opcode is artpoll 
     {
     is_opcode_is_artpoll=1;is_opcode_is_dmx=0;
     //( we should normally reply to it, giving ip adress of the device)
     } 
 
     if(  is_opcode_is_dmx=1)//if its DMX data we will read it now
     {
     //if you need to filter DMX universes, uncomment next line to have the universe rceived
     //incoming_universe= bytes_to_short(packetBuffer[15],packetBuffer[14])
     
     //getting data from a channel position, on a precise amount of channels, this to avoid to much operation if you need only 4 channels for example
     for(int i=channel_position-1;i< number_of_channels;i++)//channel position
      {
     buffer_dmx[i]= byte(packetBuffer[i+17]);
       }
      }
 
     }//end of sniffing 
    
  }

//stuff to do on PWM or whatever
SoftPWMSet(2,buffer_dmx[2]);  
SoftPWMSet(4,buffer_dmx[4]); 
SoftPWMSet(7,buffer_dmx[7]);   
SoftPWMSet(8,buffer_dmx[8]);  
analogWrite(9,buffer_dmx[9]);
SoftPWMSet(12,buffer_dmx[13]);
}

I posted a picture of the error!

Why? The window contains text. Copy and paste the text.

Here

ARTNET_receiver_softPWM.pde: In function 'void setup()':
ARTNET_receiver_softPWM:85: error: 'Udp' was not declared in this scope

As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp.

ARTNET_receiver_softPWM.pde: In function 'void loop()':
ARTNET_receiver_softPWM:90: error: 'Udp' was not declared in this scope

As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp.

As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp.

Is there some part of this that you don't understand? You need to rename the Udp class to EthernetUdp, as in:

EthernetUdp.begin(localPort);

Which then leads me to this error message. I'm not sure what to do from here.

Arduino: 1.5.6-r2 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

ARTNET_receiver_softPWM.pde: In function 'void setup()':
ARTNET_receiver_softPWM:85: error: 'EthernetUdp' was not declared in this scope
ARTNET_receiver_softPWM.pde: In function 'void loop()':
ARTNET_receiver_softPWM:90: error: 'Udp' was not declared in this scope

As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Which then leads me to this error message. I'm not sure what to do from here.

There are three occurrences of Udp in your sketch. Clearly, you only bothered to change one of them. Why?

PaulS:

Which then leads me to this error message. I'm not sure what to do from here.

There are three occurrences of Udp in your sketch. Clearly, you only bothered to change one of them. Why?

I did change all of them, yet it still gives the 'EthernetUdp was not declared in this scope error'

I did change all of them, yet it still gives the 'EthernetUdp was not declared in this scope error'

OK. It's because the stupid message is wrong. The class is defined in a file called EthernetUdp.h, but is actually called EthernetUDP. Morons!

Thanks for pointing that out! I'm still getting an error though, although this time its an unqualified-id error

ARTNET_receiver_softPWM.ino: In function 'void setup()':
ARTNET_receiver_softPWM.ino:85: error: expected unqualified-id before '.' token
ARTNET_receiver_softPWM.ino: In function 'void loop()':
ARTNET_receiver_softPWM.ino:90: error: expected primary-expression before '.' token
ARTNET_receiver_softPWM.ino:93: error: expected unqualified-id before '.' token