Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Using TimeService


  • Please log in to reply
9 replies to this topic

#1 Szymon

Szymon

    Advanced Member

  • Members
  • PipPipPip
  • 108 posts
  • LocationPoland, Krakow

Posted 28 September 2010 - 07:24 AM

Hi,
I'm trying to use the TimeService class (from Microsoft.SPOT.Time assembly) to synchronize time on Netduino with NTP server. Here is my code:

  var timeServer = "time.nist.org";
  IPHostEntry timeServerHostEntry = Dns.GetHostEntry(timeServer);

  var status = TimeService.UpdateNow(timeServerHostEntry.AddressList[0].GetAddressBytes(), 200);
  Debug.Print("Current time UTC"+status.CurrentTimeUTC);

But I get this exception when calling any method on TimeService:

    #### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
    #### Message: 
    #### Microsoft.SPOT.Time.TimeService::UpdateNow [IP: 000a] ####
    #### NetworkTest.Program::Main [IP: 0044] ####
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Time.dll
An unhandled exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Time.dll

Is this function implemented in Netduino Plus firmware?

#2 RvBCrS

RvBCrS

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts
  • LocationZutphen, Netherlands

Posted 28 September 2010 - 08:04 AM

I don't know, don't have my Netduino Plus yet :( but maybe try the IP address of the NTP server, maybe DNS is not implemented yet, or what you said maybe NTP is not fully ready yet.
Blog: Morrison Blog
Twitter: @rvbcrs

#3 Szymon

Szymon

    Advanced Member

  • Members
  • PipPipPip
  • 108 posts
  • LocationPoland, Krakow

Posted 28 September 2010 - 08:09 AM

I don't know, don't have my Netduino Plus yet :( but maybe try the IP address of the NTP server, maybe DNS is not implemented yet, or what you said maybe NTP is not fully ready yet.


I have tried the same code with the Tahoe II board and in the emulator. Both work fine so I guess this is simply not implemented in the Netduino Plus firmware.

#4 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 28 September 2010 - 09:52 AM

I only got my ND+ this morning (and I'm at work so can't use it), but I'm pretty sure that DNS is not supported at the moment. Have you checked the IP you get before the TimeService call? Maybe it's not valid.

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 September 2010 - 01:34 PM

DNS is definitely supported in the Netduino Plus. The optional TimeService component is not included in the Netduino Plus firmware (to free more flash/RAM for apps)--but it would certainly be possible to add on such functionality... Chris

#6 Szymon

Szymon

    Advanced Member

  • Members
  • PipPipPip
  • 108 posts
  • LocationPoland, Krakow

Posted 28 September 2010 - 01:42 PM

DNS is definitely supported in the Netduino Plus.

The optional TimeService component is not included in the Netduino Plus firmware (to free more flash/RAM for apps)--but it would certainly be possible to add on such functionality...

Chris


Indeed DNS is supported and works fine for me.

I think for network connected data logger or similar web enabled scenario it would be beneficial to synchronize to proper local time. Even more because Netduino board doesn't include Real Time Clock so the time needs to be set after each reset.

Michael Schwarz shows how to query the NTP server in managed code and this doesn't look overly complex (I will try it today): http://weblogs.asp.n...rk-devices.aspx

If this is not adding much to the firmware size it would be good to have it implemented.

#7 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 28 September 2010 - 01:48 PM

Sorry! I'll keep quiet until I've actually used my Netduino Plus and know what I'm talking about. :)

#8 Szymon

Szymon

    Advanced Member

  • Members
  • PipPipPip
  • 108 posts
  • LocationPoland, Krakow

Posted 28 September 2010 - 01:50 PM

Sorry! I'll keep quiet until I've actually used my Netduino Plus and know what I'm talking about. :)


No worries. Maybe what you had in mind was using DHCP insteado of static IP configuration, which Chris warned that its not officially supported yet.

#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 September 2010 - 02:13 PM

...DHCP insteado of static IP configuration, which Chris warned that its not officially supported yet.


[And on that, DHCP is actually fully implemented... But by using static IP, it's much easier to troubleshoot any glitches in lwIP: if something is not working properly, with static IP one at least knows that the Netduino Plus is already on the network :)]

Chris

#10 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 13 September 2011 - 06:28 AM

Won't this solve the problem?
http://weblogs.asp.n...rk-devices.aspx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.