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

System.Decimal.Multiply missing?


  • Please log in to reply
No replies to this topic

#1 croll12

croll12

    Member

  • Members
  • PipPip
  • 10 posts

Posted 12 January 2014 - 01:07 AM

I am using a Netduino Plus 2 with VS 2012 and am trying to sync/set the date and time on the netduino to an NTP server.  I have found a function online and made the necessary conversions to VB and ran into a road block here:

 

fractpart = Convert.ToUInt64(256 * fractpart + ntpData(offsetTransmitTime + i))

 

I am getting an error "Requested opperation is not valid because the runtume library System.Decimal.Multiply is not defined".  I have looked at all references available and can not find a solution.  Any help would be greatly appreciated.  Here is the full function:

 

 Public Function GetNetworkTime() As DateTime
        Dim ep As New IPEndPoint(Dns.GetHostEntry("time-a.nist.gov").AddressList(0), 123)
        Dim s As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
        s.Connect(ep)
        Dim ntpData As Byte() = New Byte(47) {}
        ' RFC 2030
        ntpData(0) = &H1B
        For i As Integer = 1 To 47
            ntpData(i) = 0
        Next
        s.Send(ntpData)
        s.Receive(ntpData)
        Dim offsetTransmitTime As Byte = 40
        Dim intpart As ULong = 0
        Dim fractpart As ULong = 0
        For i As Integer = 0 To 3
            intpart = Convert.ToUInt64(256 * intpart + ntpData(offsetTransmitTime + i))
        Next
 
        For i As Integer = 4 To 7
            fractpart = Convert.ToUInt64(256 * fractpart + ntpData(offsetTransmitTime + i))
        Next
 
        Dim milliseconds As ULong = Convert.ToUInt64(intpart * 1000 + (fractpart * 1000) / &H100000000L)
        s.Close()
        Dim timeSpan__1 As TimeSpan = TimeSpan.FromTicks(CLng(milliseconds) * TimeSpan.TicksPerMillisecond)
        Dim dateTime As New DateTime(1900, 1, 1)
        dateTime += timeSpan__1
        Dim offsetAmount As TimeSpan = TimeZone.CurrentTimeZone.GetUtcOffset(dateTime)
        Dim networkDateTime As DateTime = (dateTime + offsetAmount)
        Debug.Print(networkDateTime.ToString())
        Return networkDateTime
    End Function





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.