Mercurial > flash_v2
changeset 759:018143c925ee
* tests/sntp1.c (net_test): Strip the trailing "\n" making it more
readable.
* doc/sntp.sgml: Added license banner and added missing </para>
* include/sntp.h (cyg_sntp_start): C++ safe
* cdl/sntp.cdl: Stricture requirements and same description as in
ecos.db. Only build the test if CYGPKH_NET_BUILD_HW_TESTS
* tests/sntp1.c (net_test): Check we have the required
packages. Require the time to be within 90 days of the build
date of the tes
| author | asl |
|---|---|
| date | Tue, 25 Feb 2003 18:12:18 +0000 |
| parents | 36f3d2a15e37 |
| children | 74589c7c236e |
| files | packages/net/sntp/current/ChangeLog packages/net/sntp/current/cdl/sntp.cdl packages/net/sntp/current/doc/sntp.sgml packages/net/sntp/current/include/sntp.h packages/net/sntp/current/src/sntp.c packages/net/sntp/current/tests/sntp1.c |
| diffstat | 6 files changed, 82 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/net/sntp/current/ChangeLog +++ b/packages/net/sntp/current/ChangeLog @@ -1,3 +1,19 @@ +2003-02-25 Gary Thomas <mlbassoc.com> + + * tests/sntp1.c (net_test): Strip the trailing "\n" making it more + readable. + +2003-02-25 Andrew Lunn <andrew.lunn@ascom.ch> + + * doc/sntp.sgml: Added license banner and added missing </para> + * include/sntp.h (cyg_sntp_start): C++ safe + * cdl/sntp.cdl: Stricture requirements and same description as in + ecos.db. Only build the test if CYGPKH_NET_BUILD_HW_TESTS + * tests/sntp1.c (net_test): Check we have the required + packages. Require the time to be within 90 days of the build + date of the test + + 2003-02-16 Andrew Lunn <andrew.lunn@ascom.ch> * src/sntp.c: First import of SNTP client code.
--- a/packages/net/sntp/current/cdl/sntp.cdl +++ b/packages/net/sntp/current/cdl/sntp.cdl @@ -51,15 +51,15 @@ cdl_package CYGPKG_NET_SNTP { display "Simple Network Time Protocol Client (SNTP)" description " - This package provides an SNTP client which will recieve - SNTP broadcasts and set the system clock to the correct - time." + This package provides a SNTP client which can recieve broadcast time + information and set the system clock." doc ref/net-sntp.html include_dir cyg/sntp requires CYGPKG_NET - requires CYGPKG_ISO_TIME - + requires CYGPKG_LIBC_TIME + requires CYGSEM_LIBC_TIME_TIME_WORKING + requires CYGSEM_LIBC_TIME_SETTIME_WORKING compile sntp.c cdl_component CYGPKG_NET_SNTP_OPTIONS { @@ -95,7 +95,7 @@ cdl_package CYGPKG_NET_SNTP { display "sntp tests" flavor data no_define - calculated { "tests/sntp1.c" } + calculated { CYGPKG_NET_BUILD_HW_TESTS ? "tests/sntp1.c" : "" } } }
--- a/packages/net/sntp/current/doc/sntp.sgml +++ b/packages/net/sntp/current/doc/sntp.sgml @@ -1,4 +1,35 @@ -<PART ID="net-sntp"> +<!-- {{{ Banner --> + +<!-- =============================================================== --> +<!-- --> +<!-- sntp.sgml --> +<!-- --> +<!-- Simple Network Time Protocol Client --> +<!-- --> +<!-- =============================================================== --> +<!-- ####COPYRIGHTBEGIN#### --> +<!-- --> +<!-- =============================================================== --> +<!-- Copyright (C) 2003 Andrew Lunn --> +<!-- This material may be distributed only subject to the terms --> +<!-- and conditions set forth in the Open Publication License, v1.0 --> +<!-- or later (the latest version is presently available at --> +<!-- http://www.opencontent.org/openpub/) --> +<!-- Distribution of the work or derivative of the work in any --> +<!-- standard (paper) book form is prohibited unless prior --> +<!-- permission obtained from the copyright holder --> +<!-- =============================================================== --> +<!-- --> +<!-- ####COPYRIGHTEND#### --> +<!-- =============================================================== --> +<!-- #####DESCRIPTIONBEGIN#### --> +<!-- --> +<!-- ####DESCRIPTIONEND#### --> +<!-- =============================================================== --> + +<!-- }}} --> + +<PART ID="net-sntp-client"> <TITLE>Simple Network Time Protocol Client</TITLE> <PARTINTRO> <PARA> @@ -8,7 +39,7 @@ from an NTP server and uses the informat clock. </PARA> </PARTINTRO> -<CHAPTER id="sntp-the"> +<CHAPTER id="net-sntp"> <TITLE>The SNTP Client</TITLE> <SECT1 id="sntp-starting"> <TITLE>Starting the SNTP client</TITLE> @@ -23,8 +54,8 @@ called. The thread is then started by c void cyg_sntp_start(void); </programlisting> <para> - Once started, the thread will run forever. +</para> </sect1> <sect1 id="net-sntp-operation">
--- a/packages/net/sntp/current/include/sntp.h +++ b/packages/net/sntp/current/include/sntp.h @@ -51,6 +51,7 @@ //============================================================================= /* Call this function to start the SNTP Client */ -void cyg_sntp_start(void); +__externC void +cyg_sntp_start(void); #endif
--- a/packages/net/sntp/current/src/sntp.c +++ b/packages/net/sntp/current/src/sntp.c @@ -51,6 +51,7 @@ #include <network.h> #include <cyg/infra/cyg_type.h> #include <cyg/infra/cyg_ass.h> +#include <cyg/infra/cyg_trac.h> #include <cyg/sntp/sntp.h> #include <time.h> @@ -152,8 +153,10 @@ static void sntp_fn(cyg_addrword_t data) mode = (htonl(buf[0]) & MODE_MASK) >> MODE_SHIFT; /* Only support protocol versions 3 or 4 */ - if (new_srv.version < 3 || new_srv.version > 4) + if (new_srv.version < 3 || new_srv.version > 4) { + CYG_TRACE1(1, "Unsupported version of NTP. Version %d",version); continue; + } /* Only process broadcast packet */ if (mode != MODE_BROADCAST)
--- a/packages/net/sntp/current/tests/sntp1.c +++ b/packages/net/sntp/current/tests/sntp1.c @@ -46,8 +46,11 @@ // Description: Tests the sntp client //####DESCRIPTIONEND#### +#include <pkgconf/isoinfra.h> +#include <cyg/infra/testcase.h> + +#if defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_STRING_STRFUNCS) #include <network.h> -#include <cyg/infra/testcase.h> #include <time.h> #include <cyg/sntp/sntp.h> #include <stdio.h> @@ -69,6 +72,7 @@ net_test(cyg_addrword_t param) "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + char time_info[32]; CYG_TEST_INIT(); @@ -80,7 +84,9 @@ net_test(cyg_addrword_t param) for (seconds = 120; seconds > 0; seconds--) { now = time(NULL); - CYG_TEST_INFO(ctime(&now)); + ctime_r(&now, time_info); + time_info[strlen(time_info)-1] = '\0'; // Strip \n + CYG_TEST_INFO(time_info); cyg_thread_delay(100); } @@ -105,12 +111,12 @@ net_test(cyg_addrword_t param) if (build_time > time(NULL)) { CYG_TEST_FAIL_FINISH("Build time is ahead of SNTP time"); } else { - if ((build_time + 60 * 60 * 24 * 10) > time(NULL)) { - CYG_TEST_FAIL_FINISH("Build time is more than 10 days old"); + if ((build_time + 60 * 60 * 24 * 90) > time(NULL)) { + CYG_TEST_FAIL_FINISH("Build time is more than 90 days old"); } } } - CYG_TEST_FINISH("sntp1 test is complete"); + CYG_TEST_PASS_FINISH("sntp1 test is complete"); } #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL*2) @@ -133,3 +139,12 @@ cyg_user_start(void) ); cyg_thread_resume(thread_handle); // Start it } + +#else //defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_STRING_STRFUNCS) + +void cyg_user_start(void) +{ + CYG_TEST_NA("Not all the required packages are available"); +} + +#endif
