• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/03-Aug-2024-3625

CMakeLists.txtD03-Aug-2024195 95

Makefile.hostD03-Aug-2024129 63

README.rstD03-Aug-20241.4 KiB4531

prj.confD03-Aug-2024706 3221

sample.yamlD03-Aug-2024402 1918

README.rst

1.. _posix-gettimeofday-sample:
2
3POSIX gettimeofday() with clock initialization over SNTP
4########################################################
5
6Overview
7********
8
9This sample application demonstrates using the POSIX `gettimeofday()`_ function to display the
10absolute wall clock time and local time every second. At system startup, the current time is
11queried using the SNTP networking protocol, enabled by setting the
12:kconfig:option:`CONFIG_NET_CONFIG_CLOCK_SNTP_INIT` and
13:kconfig:option:`CONFIG_NET_CONFIG_SNTP_INIT_SERVER` options.
14
15Requirements
16************
17
18- :ref:`networking_with_host`
19- or, a board with hardware networking
20- NAT/routing should be set up to allow connections to the Internet
21- DNS server should be available on the host to resolve domain names
22
23Building and Running
24********************
25
26This project outputs to the console. It can be built and executed on QEMU as follows:
27
28.. zephyr-app-commands::
29   :zephyr-app: samples/posix/gettimeofday
30   :host-os: unix
31   :board: qemu_x86
32   :goals: run
33   :compact:
34
35For comparison, to build directly for your host OS if it is POSIX compliant (for ex. Linux):
36
37.. code-block:: console
38
39   cd samples/posix/gettimeofday
40   make -f Makefile.host
41
42The make output file will be located in samples/posix/gettimeofday/build.
43
44.. _gettimeofday(): https://pubs.opengroup.org/onlinepubs/009604599/functions/gettimeofday.html
45