SNTPGetUTCTime (FB)¶
FUNCTION_BLOCK SNTPGetUTCTime
Sends a SNTP request to a NTP/SNTP server and reads the current server time.
- InOut:
Scope
Name
Type
Initial
Comment
Input
xExecute
BOOL
A rising edge starts the SNTP request
sSNTPServer
STRING(255)
IP address of the NTP/SNTP server
sOwnIP
STRING(255)
‚0.0.0.0‘
Optional: IP address of the PLC, Default: 0.0.0.0
uiSNTPPort
UINT
Port of the NTP/SNTP server
uiOwnPort
UINT
Own port
udiTimeout
UDINT
1000
Timeout in ms (default 1000)
eNTPVersion
NTP_VERSION.V3
Version of the NTP protokol (default V3)
Output
xDone
BOOL
True if the call has been finished
xBusy
BOOL
True while the request is running
xError
BOOL
True if an error occured.
eError
Error code
uliTimestamp
ULINT
Current UTC time in milliseconds since 1.1.1970 of the NTP/SNTP server with roundtrip correction. You can use the function SysTimeRtc.SysTimeRtcConvertHighResToLocal to convert the UTC time to SysTimeRtc.SYSTIMEDATE.
uliReceiveClientTS
ULINT
Current UTC time in milliseconds since 1.1.1970 when the timestamp has been received by the client (current time of the runtime). You can use the function SysTimeRtc.SysTimeRtcConvertHighResToLocal to convert the UTC time to SysTimeRtc.SYSTIMEDATE.