Now I want to make this with CODESYS Control Win V3 - and I can't get response from server.
And no errors in all NBS fb's.
Maybe somebody will be able to found my mistakes and describe it.
I will be really grateful.
My code:
  iStep:        INT;  fbUdpPeer:       NBS.UDP_Peer;  hPeer:         NBS.CAA.HANDLE;  fbUdpSend:       NBS.UDP_Send;  fbUdpReceive:       NBS.UDP_Receive;  stNtpAddress:      NBS.IP_ADDR;    abyNtpRequest:     ARRAY[0..47]OFBYTE:=[16#1B,47(0)];  abyNtpResponse:    ARRAY[0..47]OFBYTE;    fbSynchroPeriod:    TON;  fbTimeout:       TON;
fbSynchroPeriod(  IN:=NOT(fbSynchroPeriod.Q),  PT:=T#15S);stNtpAddress.sAddr:='129.6.15.28';CASEiStepOF  0:  fbUdpPeer  (    xEnable    :=  TRUE,    ipAddr    :=    ,    uiPort    :=  4023,    ipMultiCast  :=     ,    hPeer    =>  hPeer  );  IFfbUdpPeer.xActiveTHEN    iStep:=10;  END_IF    10:  fbTimeout(IN:=FALSE);  fbUdpSend  (    xExecute  :=   fbSynchroPeriod.Q,    udiTimeOut  :=   ,     hPeer    :=   hPeer,    ipAddr    :=   stNtpAddress,    uiPort    :=   123,     pData    :=   ADR(abyNtpRequest),    szSize    :=   SIZEOF(abyNtpRequest)  );      IFfbUdpSend.xDoneTHEN    fbUdpSend(xExecute:=FALSE);    iStep:=20;  END_IF      20:    fbTimeout(IN:=TRUE,PT:=T#6S);    fbUdpReceive(    xEnable  :=  TRUE,     hPeer  :=  hPeer,    pData  :=  ADR(abyNtpResponse),      //fixed    szSize  :=  SIZEOF(abyNtpResponse),     //fixed   );  IFfbUdpReceive.xReadyTHEN    iStep:=10;  END_IF    IFfbTimeout.QTHEN    iStep:=10;  END_IF  END_CASE
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. I try to use CAA Net Base Servises (3.5.5.0) to get current time from NTP-server. My Device - CODESYS Control Win V3 (3.5.5.0).
NTP-server: 129.6.15.28 (time-a.nist.gov)
http://tf.nist.gov/tf-cgi/servers.cgi
I take example of NTP-request (0x1B and 47 NULL bytes) from this:
https://stackoverflow.com/questions/119 ... er-using-c
I test it with Hercules utility, and it works:
Now I want to make this with CODESYS Control Win V3 - and I can't get response from server.
And no errors in all NBS fb's.
Maybe somebody will be able to found my mistakes and describe it.
I will be really grateful.
My code:
I found my mistake and edit first post. Now it works.
Is above code working as stable?