NTP, UDP with Arduino 0019

Hey greetings,

I need for a project the current timestamp and I want to get it over a NTP Server.

I run into troubles on Mac OS X 10.6 with Arduino 0019 when I use the library from bjoern (http://bitbucket.org/bjoern/arduino_osc/src/tip/libraries/Ethernet/). I want to use this Library with the “Time” (http://www.arduino.cc/playground/Code/Time) Library.

I think it has something to do with the new SPI?

Errormsg:

Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/UdpBytewise.cpp:30:19: error: types.h: No such file or directory
In file included from /Applications/Arduino.app/Contents/Resources/Java/libraries/SPI/SPI.h:15,
                 from /Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.h:14,
                 from /Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/UdpBytewise.cpp:31:
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WProgram.h:17: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WProgram.h:16: error: previous declaration 'uint16_t makeWord(uint16_t)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WProgram.h:27: error: declaration of C function 'long int random(long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WProgram.h:28: error: declaration of C function 'long int random(long int, long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WProgram.h:27: error: previous declaration 'long int random(long int)' here
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/UdpBytewise.cpp: In member function 'void UdpBytewiseClass::begin(uint16_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/UdpBytewise.cpp:46: error: 'Sn_MR_UDP' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/UdpBytewise.cpp: In member function 'int UdpBytewiseClass::available()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/UdpBytewise.cpp:55: error: 'getSn_RX_RSR' was not declared in this scope

Code from the Time Library Example (added Spi.h because he claims about missing Spi.h):

/*
 * Time_NTP.pde
 * Example showing time sync to NTP time source
 *
 * This sketch uses the Ethenet library with the user contributed UdpBytewise extension
 */
 
#include <Time.h> 
#include <SPI.h>
#include <Ethernet.h>
#include <UdpBytewise.h>  // UDP library from: bjoern@cs.stanford.edu 12/30/2008 
#if  UDP_TX_PACKET_MAX_SIZE <64 ||  UDP_RX_PACKET_MAX_SIZE < 64
#error : UDP packet size to small - modify UdpBytewise.h to set buffers to 64 bytes
#endif
/*
 *
 * You may need to modify the UdpBytewise.h library to allow enough space in the buffers for the NTP packets.
 * Open up UdpBytewse.h and set the following buffers to 64 bytes:
 *    #define UDP_TX_PACKET_MAX_SIZE 64
 *    #define UDP_RX_PACKET_MAX_SIZE 64
 */


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
byte ip[] = { 192, 168, 1, 44 }; // set the IP address to an unused address on your network

byte SNTP_server_IP[]    = { 192, 43, 244, 18}; // time.nist.gov
//byte SNTP_server_IP[] = { 130,149,17,21};    // ntps1-0.cs.tu-berlin.de
//byte SNTP_server_IP[] = { 192,53,103,108};   // ptbtime1.ptb.de


time_t prevDisplay = 0; // when the digital clock was displayed
const  long timeZoneOffset = 0L; // set this to the offset in seconds to your local time;

void setup() 
{
  Serial.begin(9600);
  Ethernet.begin(mac,ip);  
  Serial.println("waiting for sync");
  setSyncProvider(getNtpTime);
  while(timeStatus()== timeNotSet)   
     ; // wait until the time is set by the sync provider
}

void loop()
{  
  if( now() != prevDisplay) //update the display only if the time has changed
  {
    prevDisplay = now();
    digitalClockDisplay();  
  }
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

/*-------- NTP code ----------*/

unsigned long getNtpTime()
{
  sendNTPpacket(SNTP_server_IP);
  delay(1000);
  if ( UdpBytewise.available() ) {
    for(int i=0; i < 40; i++)
       UdpBytewise.read(); // ignore every field except the time
    const unsigned long seventy_years = 2208988800UL + timeZoneOffset;        
    return getUlong() -  seventy_years;      
  }
  return 0; // return 0 if unable to get the time
}

unsigned long sendNTPpacket(byte *address)
{
  UdpBytewise.begin(123);
  UdpBytewise.beginPacket(address, 123);
  UdpBytewise.write(B11100011);   // LI, Version, Mode
  UdpBytewise.write(0);    // Stratum
  UdpBytewise.write(6);  // Polling Interval
  UdpBytewise.write(0xEC); // Peer Clock Precision
  write_n(0, 8);    // Root Delay & Root Dispersion
  UdpBytewise.write(49); 
  UdpBytewise.write(0x4E);
  UdpBytewise.write(49);
  UdpBytewise.write(52);
  write_n(0, 32); //Reference and time stamps  
  UdpBytewise.endPacket();   
}

unsigned long getUlong()
{
    unsigned long ulong = (unsigned long)UdpBytewise.read() << 24;
    ulong |= (unsigned long)UdpBytewise.read() << 16;
    ulong |= (unsigned long)UdpBytewise.read() << 8;
    ulong |= (unsigned long)UdpBytewise.read();
    return ulong;
}

void write_n(int what, int how_many)
{
  for( int i = 0; i < how_many; i++ )
    UdpBytewise.write(what);
}

Hi,
I had same problem.
Here is the modified UdpBytewise.cpp file which solves all the compile errors with arduino-0019. I’m not sure if it is all modified correctly, but it works for me.

/*
 * UdpBytewise.cpp: Library to send/receive UDP packets with the Arduino ethernet shield.
 * Drop UdpBytewise.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/
 * TODO: should protect buffer access with critical sections
 *
 * MIT License:
 * Copyright (c) 2008 Bjoern Hartmann
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * bjoern@cs.stanford.edu 12/30/2008
 */

//extern "C" {
//#include "types.h"
#include "w5100.h"
#include "socket.h"
//}

#include "Ethernet.h"
#include "UdpBytewise.h"

/* Start UDP socket, listening at local port PORT */
void UdpBytewiseClass::begin(uint16_t port) {
      _port = port;
      _sock = 0; //TODO: should not be hardcoded
      _txIndex =0;
      _rxIndex =0;
      _rxSize = 0;
      _txOverflowStrategy = UDP_TX_OVERFLOW_SPLIT;
      socket(_sock,SnMR::UDP,_port,0);
}


/* Is data available in rx buffer? Returns 0 if no, number of available bytes if yes. */
int UdpBytewiseClass::available() {
      if(_rxSize==0 || _rxSize-_rxIndex==0) {
            //if local buffer is empty or depleted
            //check wiz5100 buffer for new packet
//            _rxSize = getSn_RX_RSR(_sock); //note: return value is inflated by 8 byte header
            _rxSize = W5100.getRXReceivedSize(_sock); //note: return value is inflated by 8 byte header
            if(_rxSize){
                  //if we have a new packet there
                  //reset buffer index
                  _rxIndex=0;
                  //copy packet into our local buffer
                  _rxSize = recvfrom(_sock,_rxBuffer,_rxSize-8,_rxIp,&_rxPort);
            } else {
                  //else do nothing and rxsize is still 0
                  ;
            }
            return _rxSize; //return the new number of bytes in our buffer
      } else{
            //if buffer is not empty, return remaining # of bytes
            return (_rxSize-_rxIndex);
      }
}


/* Start a new packet with given target ip and port
 * returns 1 on success, 0 if we already started a packet */
int UdpBytewiseClass::beginPacket(uint8_t *ip, unsigned int port) {
      if(_txIndex==0) {
            //ok to start new packet - copy ip and port
            _txIp[0]=ip[0];
            _txIp[1]=ip[1];
            _txIp[2]=ip[2];
            _txIp[3]=ip[3];
            _txPort = port;
            return 1;
      }
      else {
            //we already started a packet and have data in it
            return 0;
      }
}


/* Add a byte to the currently assembled packet if there is space
 * if there isn't space, either truncate (ignore) or split the packet.
 */
void UdpBytewiseClass::write(uint8_t b) {
      if(_txIndex>= UDP_TX_PACKET_MAX_SIZE) {
            //buffer is full - we can either truncate the packet or split in two
            switch (_txOverflowStrategy) {
                  case UDP_TX_OVERFLOW_SPLIT:
                        endPacket();
                        beginPacket(_txIp,_txPort);
                        //fall through to normal add of byte to buffer below
                        break;
                  case UDP_TX_OVERFLOW_TRUNCATE:
                  default:
                        //don't add - just ignore bytes past buffer size
                        return;
            }
      }
      _txBuffer[_txIndex++] = b;
}

/* send an assembled packet out
 * returns # of bytes sent on success, 0 if there's nothing to send */
int UdpBytewiseClass::endPacket() {
      // send the packet
      uint16_t result = sendto(_sock,(const uint8_t *)_txBuffer,_txIndex,_txIp,_txPort);
      // reset buffer index
      _txIndex=0;
      // return sent bytes
      return (int)result;
}

/* read the next byte of the last rececived packet */
int UdpBytewiseClass::read() {
      if(_rxIndex < _rxSize) {
            // if there is something to be read, return the next byte
            return _rxBuffer[_rxIndex++];
      } else {
            //we already sent the last byte - nothing to do
            return -1;
      }
}

void UdpBytewiseClass::getSenderIp(uint8_t*ip) {
      ip[0]=_rxIp[0];
      ip[1]=_rxIp[1];
      ip[2]=_rxIp[2];
      ip[3]=_rxIp[3];
}

unsigned int  UdpBytewiseClass::getSenderPort() {
      return _rxPort;
}

/* what should we do when we try to add to a full outgoing packet?
 * UDP_TX_OVERFLOW_TRUNCATE - throw overflow bytes away
 * UDP_TX_OVERFLOW_SPLIT - split into multiple packets
 */
void UdpBytewiseClass::setOverflowStrategy(uint8_t strategy) {
      _txOverflowStrategy = strategy;
}

/* Create one global object */
UdpBytewiseClass UdpBytewise;

I also modified the original NTP example TimeNTP.pde by adding the mask and gateway into the ethernet initialization. Otherwise the example was not able to connect to NTP server from my local network.

....
byte mask[] = { 255, 255, 255, 0 };
byte gw[] = { 192, 168, 1, 254 };
....
Ethernet.begin(mac,ip,gw,mask);
....

Works like a charm!

Thank you so much!

I just compiled this with arduino 0020, and it works with this latest version as well.

Additionally, I had to copy the w500.h and socket.h from the Ethernet utility directory into the Udp directory (Which I had previously copied into the libraries directory). I also needed to add the ip address of my router as the gateway (Per the prior post). Other than that, works great.

Thanks again for the great update!

Morning all, Having followed the steps above i am still getting errors:

C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:30:19: error: types.h: No such file or directory In file included from C:\Users\Stuart\Downloads\arduino-0021\libraries\SPI/SPI.h:15, from C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\/w5100.h:14, from C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:31: C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:17: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:16: error: previous declaration 'uint16_t makeWord(uint16_t)' here C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:27: error: declaration of C function 'long int random(long int)' conflicts with c:/users/stuart/downloads/arduino-0021/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:28: error: declaration of C function 'long int random(long int, long int)' conflicts with C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:27: error: previous declaration 'long int random(long int)' here C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp: In member function 'void UdpBytewiseClass::begin(uint16_t)': C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:46: error: 'Sn_MR_UDP' was not declared in this scope C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp: In member function 'int UdpBytewiseClass::available()': C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:55: error: 'getSn_RX_RSR' was not declared in this scope

Aplogies if i have missed something obvious here, and thanks for your help in advance, Stuart.

here is the TimeNTP example sketch updated to use the NTP code that is distributed with the ethernet library from 0019 and later

/*
 * Time_NTP.pde
 * Example showing time sync to NTP time source
 *
 * This sketch uses the UDP supplied with th Ethenet library from 0019
 */

#include <Time.h> 
#include <SPI.h>
#include <Ethernet.h>
#include <Udp.h> 

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
byte ip[] = {  192, 168, 1, 44 }; // set the IP address to an unused address on your network

unsigned int localPort = 8888;      // local port to listen for UDP packets

byte timeServer[]  = { 192, 43, 244, 18}; // time.nist.gov

const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message

byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets 



time_t prevDisplay = 0; // when the digital clock was displayed
const  long timeZoneOffset = 0L; // set this to the offset in seconds to your local time;

void setup() 
{
  // start Ethernet and UDP
  Ethernet.begin(mac,ip);  
  Udp.begin(localPort);

  Serial.begin(9600);
  Serial.println("waiting for sync");
  setSyncProvider(getNtpTime);
  while(timeStatus()== timeNotSet)   
    ; // wait until the time is set by the sync provider
}

void loop()
{  
  if( now() != prevDisplay) //update the display only if the time has changed
  {
    prevDisplay = now();
    digitalClockDisplay();  
  }
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

/*-------- NTP code ----------*/

unsigned long getNtpTime()
{
  sendNTPpacket(timeServer); // send an NTP packet to a time server

  unsigned long startMillis = millis();    
  while( millis() - startMillis < 1000)  // wait up to one second for the response
  {  // wait to see if a reply is available
    if ( Udp.available() ) 
    {  
      Udp.readPacket(packetBuffer,NTP_PACKET_SIZE);  // read the packet into the buffer

      //the timestamp starts at byte 40 of the received packet and is four bytes,
      // or two words, long. First, esxtract the two words:
      unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
      unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);  
      // combine the four bytes (two words) into a long integer
      // this is NTP time (seconds since Jan 1 1900):
      unsigned long secsSince1900 = highWord << 16 | lowWord;      
      // now convert NTP time into Arduino Time format:
      // Time starts on Jan 1 1970. In seconds, that's 2208988800:
      const unsigned long seventyYears = 2208988800UL;     
      // subtract seventy years:
      unsigned long epoch = secsSince1900 - seventyYears;
 
      return epoch;
    }
  }
  return 0;   // return 0 if unable to get the time
}  

// send an NTP request to the time server at the given address 
unsigned long sendNTPpacket(byte *address)
{
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, NTP_PACKET_SIZE); 
  // Initialize values needed to form NTP request
  // (see URL above for details on the packets)
  packetBuffer[0] = 0b11100011;   // LI, Version, Mode
  packetBuffer[1] = 0;     // Stratum, or type of clock
  packetBuffer[2] = 6;     // Polling Interval
  packetBuffer[3] = 0xEC;  // Peer Clock Precision
  // 8 bytes of zero for Root Delay & Root Dispersion
  packetBuffer[12]  = 49; 
  packetBuffer[13]  = 0x4E;
  packetBuffer[14]  = 49;
  packetBuffer[15]  = 52;

  // all NTP fields have been given values, now
  // you can send a packet requesting a timestamp:                
  Udp.sendPacket( packetBuffer,NTP_PACKET_SIZE,  address, 123); //NTP requests are to port 123
}

I will distribute this with the next release of the Time library, let me know how you get on with it.

I suspect i am doing somthing stupid here, same errors using the above code:

C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:30:19: error: types.h: No such file or directory In file included from C:\Users\Stuart\Downloads\arduino-0021\libraries\SPI/SPI.h:15, from C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\/w5100.h:14, from C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:31: C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:17: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:16: error: previous declaration 'uint16_t makeWord(uint16_t)' here C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:27: error: declaration of C function 'long int random(long int)' conflicts with c:/users/stuart/downloads/arduino-0021/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:28: error: declaration of C function 'long int random(long int, long int)' conflicts with C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:27: error: previous declaration 'long int random(long int)' here C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp: In member function 'void UdpBytewiseClass::begin(uint16_t)': C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:46: error: 'Sn_MR_UDP' was not declared in this scope C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp: In member function 'int UdpBytewiseClass::available()': C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:55: error: 'getSn_RX_RSR' was not declared in this scope

Could this be as simple as I am missing the file types.h? as I can't see that one in the libraries directory?

Thanks and aplogies in advance, Stuart

the sketch posted above uses the UDP code provided with the Arduino 0019 and later ethernet libraries.

Try compiling after removing UdpBytewise and any other files you may have copied into the ethernet library directory so the only files there are the ones that came with the arduino distribution.

Ok, so a fresh install of 0021 and a fresh download of the Time files, try to compile the code above and I get these errors again:

C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:30:19: error: types.h: No such file or directory In file included from C:\Users\Stuart\Downloads\arduino-0021\libraries\SPI/SPI.h:15, from C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\/w5100.h:14, from C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:31: C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:17: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:16: error: previous declaration 'uint16_t makeWord(uint16_t)' here C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:27: error: declaration of C function 'long int random(long int)' conflicts with c:/users/stuart/downloads/arduino-0021/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:28: error: declaration of C function 'long int random(long int, long int)' conflicts with C:\Users\Stuart\Downloads\arduino-0021\hardware\arduino\cores\arduino/WProgram.h:27: error: previous declaration 'long int random(long int)' here C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp: In member function 'void UdpBytewiseClass::begin(uint16_t)': C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:46: error: 'Sn_MR_UDP' was not declared in this scope C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp: In member function 'int UdpBytewiseClass::available()': C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet\UdpBytewise.cpp:55: error: 'getSn_RX_RSR' was not declared in this scope

I am sure I am just doing something stupid here, but can't for the life of me see what it is???

TIA, Stuart.

C:\Users\Stuart\Downloads<mark>arduino-0021\libraries\Ethernet\UdpBytewise.cpp

Do you have UdpBytewise in the ethernet library directory, its not in the Arduino distribution download and should not be in that directory.
Can you post a listing of the files in your folder: …\arduino-0021\libraries\Ethernet\

I have the IDE 0021, downloaded the time librarys (had to root around to find them), and the posted code downloads the time info to the serial monitor once per second without any apparent issues (using the w5100 ethernet shield).

thanks zoomkat. I expect that Stuart_B has some of the old UDP files in his library directory and that it will start working for him when he removes those files.

Well, to be technically correct, the code compiles and prints times to the serial monitor once a second. I haven't checked to see if connections are actualy being made to the time server.

If the time displayed on the serial monitor is correct then the time must be coming from the NTP server.

The sketch posted above will pause after printing the message: waiting for sync until it gets a valid response from the NTP time server.

List of files in the ethernet directory:

Directory of C:\Users\Stuart\Documents\arduino-0021\libraries\Ethernet

02/10/2010 15:21 .
02/10/2010 15:21 …
02/10/2010 15:21 3,074 Client.cpp
02/10/2010 15:21 713 Client.h
02/10/2010 15:21 881 Ethernet.cpp
02/10/2010 15:21 526 Ethernet.h
02/10/2010 15:21 examples
02/10/2010 15:21 666 keywords.txt
02/10/2010 15:21 1,851 Server.cpp
02/10/2010 15:21 369 Server.h
02/10/2010 15:21 5,051 Udp.cpp
02/10/2010 15:21 2,960 Udp.h
02/10/2010 15:21 utility
9 File(s) 16,091 bytes
4 Dir(s) 3,359,977,472 bytes free

Thanks Stuart.

try compiling again. if the compiler still reports an error in:

C:\Users\Stuart\Downloads\arduino-0021\libraries\Ethernet<mark>UdpBytewise.cpp

then try a file search to see if you can find where UdpBytewise.cpp is being picked up

I finally got it to compile correctly,

Thanks for your help.

I had an old install on my machine, in a compleatly diffrent directory who’s which libary appears to have being read, removed this install and all is now ok… thank god!

Now to have a play with storing data in the EEPROM and writing data to pachube too!

Thanks again,
Stuart.