Other Parts Discussed in Thread: SYSBIOS
HI,
Below are the components i am using.
I have sntp applicaiton as well library to project "NIMU_ICSS_BasicExample_idkAM437x_wSoCLib_armExampleproject".
Appliation code i am using for sntp is below.
int32_t retVal;
uint32_t seconds;
uint32_t secondsFraction;
SlNetSock_Timeval_t timeval;
uint64_t ntpTimeStamp = 0;
SlNetSock_AddrIn_t ipv4addr;
uint32_t addr = 0xc800a8c0;
//uint32_t addr = 0xc0a880c8;
ipv4addr.sin_family = SLNETSOCK_AF_INET;
ipv4addr.sin_port = SlNetUtil_htons(123/*SNTP_PORT*/);
ipv4addr.sin_addr.s_addr = inet_addr("192.168.0.200");
timeval.tv_sec = 5;
timeval.tv_usec = 0;
while(1) {
retVal = SNTP_getTimeByAddr((SlNetSock_Addr_t *)&ipv4addr, &timeval,
&ntpTimeStamp);
if (retVal == 0) {
// The seconds value is stored in the upper 32 bits
seconds = (0xFFFFFFFF00000000 & ntpTimeStamp) >> 32;
// The seconds fraction is stored in the lower 32 bits
secondsFraction = ntpTimeStamp;
}
/* Sleep to yield */
Task_sleep(16000);
}
Task_exit();
But it is not able to create socket under function "getTime".
failed at
/* Create a UDP socket to communicate with NTP server */
sd = SlNetSock_create(server->sa_family, SLNETSOCK_SOCK_DGRAM, SLNETSOCK_PROTO_UDP, ifID, 0);
if (sd < 0)
{
return (SNTP_ESOCKCREATEFAIL);
}
Kindly help.
Regards,
Vrund
