Hi All,
I have been trying to get the below EathernetUdp code to compile, and no matter what I have tried from researching the forums, and every where else I could find, I cant get any code that calls the EathernetUdp2 code to compile. Eathernet2 server / Client code compiles just fine if the #include EathernetUdp2 is not there.
I get some variation of the below errors, or other errors.
I am Trying to down load the information from this little Jewel:
with the PM-101-CE Ethernet Computer Interface.
This is the relevant Tec Doc for interfacing with the Pentametric.
http://www.bogartengineering.com/wp-content/uploads/docs/PentaMetricRS232SerialSpecWeb6-11.pdf
This code is based on various examples that I have put together to do what I think the pentametric needs, and some of it will be stripped out, and other bits added......
Thing is, I am not even sure that the UPD format is the correct way to access the data in the pentametric or not..... Was gonna try, but the compile errors have stymied that effort.
there may be other Library's that would do this better/easier.
Thanks for any help on this issue, as I see others with similar problems with EathernetUDP2, but have not found any answers that fixed it.
...............................Errors........................
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\RS\Documents\Arduino\Pentametric_Coms\Pentametric_Coms.ino: In function 'void setup()':
Pentametric_Coms:40: error: The Udp class has been renamed EthernetUdp.
As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp.
Udp.begin(LocalPort);
^
C:\Users\RS\Documents\Arduino\Pentametric_Coms\Pentametric_Coms.ino: At global scope:
Pentametric_Coms:48: error: expected unqualified-id before '=' token
EthernetUDP = Udp;// To send & receive packets using UDP
^
C:\Users\RS\Documents\Arduino\Pentametric_Coms\Pentametric_Coms.ino: In function 'void ProcessUDPTraffic()':
Pentametric_Coms:64: error: The Udp class has been renamed EthernetUdp.
As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp.
int nPacketSize = Udp.parsePacket();
^
C:\Users\RS\Documents\Arduino\Pentametric_Coms\Pentametric_Coms.ino: In function 'void SendADCData()':
Pentametric_Coms:97: error: The Udp class has been renamed EthernetUdp.
As of Arduino 1.0, the Udp class in the Ethernet library has been renamed to EthernetUdp.
Udp.beginPacket(DestinationAddress, DestinationPort);
^
exit status 1
The Udp class has been renamed EthernetUdp.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
.............................................Code............................................
#include <SPI.h>
#include <Ethernet2.h>
#include <EthernetUdp2.h>
//#include <Udp.h>
#include <EthernetUdp2.cpp>
// ------------------------------------------------------------------
// Configuration
// The mac address is the physical address associated with the
// Ethernet port on the your device. It should be globally unique if
// the board is connected to a public network, or at least locally
// unique if the board is connected to a private network.
byte MacAddress[] = { 0x90, 0xA2, 0xDA, 0x10, 0xA3, 0x4F };
//byte MacAddress[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// The IP address is the internet protocol address for the board. Again
// it should be globally unique if connected to a public network or
// locally unique if connected to a private network. To communicate
// successfully, it should also be on the same sub-net as your PC.
// In practice that means the first three numbers should be the same
// as your PC's IP address. And the last number should be different to
// all devices on your network. Use ipconfig to find out your PC's IP address
IPAddress MyIPAddress(192, 168, 1, 165);
unsigned int LocalPort = 8888; //what would a port for the uno be?
// The destination address is the IP address of the computer you want to send
// messages to. It would normally be on the same sub-net as the Arduino. In practice
// this means the first three numbers of MyIPAddress and DestinationAddress should
// be the same.
IPAddress DestinationAddress(169, 254, 1, 1);
unsigned int DestinationPort = 1701;
//EthernetUDP2 = Ethernet2Udp;
// ------------------------------------------------------------------
// Setup
void setup()
{
// Start ethernet and udp
Ethernet.begin(MacAddress, MyIPAddress);
Udp.begin(LocalPort);
// Start RS232 comms
Serial.begin(9600);
}
// ------------------------------------------------------------------
// Communications
EthernetUDP = Udp;// To send & receive packets using UDP
char PacketBuffer[UDP_TX_PACKET_MAX_SIZE]; // Space to hold messages we receive.
unsigned long LastSend = 0; // Last time we sent a message
const long SendPeriod = 1000; // Time between sending messages [milliseconds]
// ------------------------------------------------------------------
// Data
bool EnableADCSend[] = { true, false, false, false, false, false, false, false };
// This Code will get changed when I can compile the code
// ------------------------------------------------------------------
// Functions
void ProcessUDPTraffic()
{
// See if there is any data available and read it.
int nPacketSize = Udp.parsePacket();
if (nPacketSize > 0)
{
int nRead = Udp.read(PacketBuffer, sizeof(PacketBuffer));
if (nRead >= 1)
{
int nPort = PacketBuffer[0] - '0';
if (nPort >= 0 && nPort < sizeof(EnableADCSend))
{
// Toggle sending data from the specified port.
EnableADCSend[nPort] = !EnableADCSend[nPort];
Serial.print("Sending adc data for channel ");
Serial.print(nPort);
Serial.print(" is ");
Serial.println(EnableADCSend[nPort] ? "on" : "off");
}
}
}
}
void SendADCData()
{
if (millis() - LastSend < SendPeriod)
return;
LastSend = millis();
for (int iPort = 0; iPort < sizeof(EnableADCSend); ++iPort)
{
if (EnableADCSend[iPort])
{
int nValue = analogRead(iPort);
Udp.beginPacket(DestinationAddress, DestinationPort);
Udp.send(81, DestinationAddress, DestinationPort ); // the message to send to get BV
Udp.send(01, DestinationAddress, DestinationPort ); //
Udp.send(02, DestinationAddress, DestinationPort ); //
Udp.send(7B, DestinationAddress, DestinationPort ); // The 7B gives a error too, needs fixing
Udp.endPacket();
}
}
}