Contiki 3.x
contiki-sky-main.c
1 /*
2  * Copyright (c) 2006, Swedish Institute of Computer Science
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  */
30 
31 #include <stdio.h>
32 #include <string.h>
33 #include "contiki.h"
34 #include "cc2420.h"
35 #include "dev/ds2411/ds2411.h"
36 #include "dev/leds.h"
37 #include "dev/serial-line.h"
38 #include "dev/slip.h"
39 #include "dev/uart1.h"
40 #include "dev/watchdog.h"
41 #include "dev/xmem.h"
42 #include "lib/random.h"
43 #include "net/netstack.h"
44 #include "net/mac/frame802154.h"
45 
46 #if WITH_UIP6
47 #include "net/ipv6/uip-ds6.h"
48 #endif /* WITH_UIP6 */
49 
50 #include "net/rime/rime.h"
51 
52 #include "sys/node-id.h"
53 #include "cfs-coffee-arch.h"
54 #include "cfs/cfs-coffee.h"
55 #include "sys/autostart.h"
56 
57 #if UIP_CONF_ROUTER
58 
59 #ifndef UIP_ROUTER_MODULE
60 #ifdef UIP_CONF_ROUTER_MODULE
61 #define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE
62 #else /* UIP_CONF_ROUTER_MODULE */
63 #define UIP_ROUTER_MODULE rimeroute
64 #endif /* UIP_CONF_ROUTER_MODULE */
65 #endif /* UIP_ROUTER_MODULE */
66 
67 extern const struct uip_router UIP_ROUTER_MODULE;
68 #endif /* UIP_CONF_ROUTER */
69 
70 #if DCOSYNCH_CONF_ENABLED
71 static struct timer mgt_timer;
72 #endif
73 extern int msp430_dco_required;
74 
75 #ifndef WITH_UIP
76 #define WITH_UIP 0
77 #endif
78 
79 #if WITH_UIP
80 #include "net/ip/uip.h"
81 #include "net/ipv4/uip-fw.h"
82 #include "net/ipv4/uip-fw-drv.h"
83 #include "net/ipv4/uip-over-mesh.h"
84 static struct uip_fw_netif slipif =
85  {UIP_FW_NETIF(192,168,1,2, 255,255,255,255, slip_send)};
86 static struct uip_fw_netif meshif =
87  {UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
88 
89 #endif /* WITH_UIP */
90 
91 #define UIP_OVER_MESH_CHANNEL 8
92 #if WITH_UIP
93 static uint8_t is_gateway;
94 #endif /* WITH_UIP */
95 
96 #ifdef EXPERIMENT_SETUP
97 #include "experiment-setup.h"
98 #endif
99 
100 #define DEBUG 1
101 #if DEBUG
102 #define PRINTF(...) printf(__VA_ARGS__)
103 #else /* DEBUG */
104 #define PRINTF(...)
105 #endif /* DEBUG */
106 
107 void init_platform(void);
108 
109 /*---------------------------------------------------------------------------*/
110 #if 0
111 int
112 force_float_inclusion()
113 {
114  extern int __fixsfsi;
115  extern int __floatsisf;
116  extern int __mulsf3;
117  extern int __subsf3;
118 
119  return __fixsfsi + __floatsisf + __mulsf3 + __subsf3;
120 }
121 #endif
122 /*---------------------------------------------------------------------------*/
123 void uip_log(char *msg) { puts(msg); }
124 
125 /*---------------------------------------------------------------------------*/
126 #if 0
127 void
128 force_inclusion(int d1, int d2)
129 {
130  snprintf(NULL, 0, "%d", d1 % d2);
131 }
132 #endif
133 /*---------------------------------------------------------------------------*/
134 static void
135 set_rime_addr(void)
136 {
137  linkaddr_t addr;
138  int i;
139 
140  memset(&addr, 0, sizeof(linkaddr_t));
141 #if UIP_CONF_IPV6
142  memcpy(addr.u8, ds2411_id, sizeof(addr.u8));
143 #else
144  if(node_id == 0) {
145  for(i = 0; i < sizeof(linkaddr_t); ++i) {
146  addr.u8[i] = ds2411_id[7 - i];
147  }
148  } else {
149  addr.u8[0] = node_id & 0xff;
150  addr.u8[1] = node_id >> 8;
151  }
152 #endif
153  linkaddr_set_node_addr(&addr);
154  PRINTF("Rime started with address ");
155  for(i = 0; i < sizeof(addr.u8) - 1; i++) {
156  PRINTF("%d.", addr.u8[i]);
157  }
158  PRINTF("%d\n", addr.u8[i]);
159 }
160 /*---------------------------------------------------------------------------*/
161 #if !PROCESS_CONF_NO_PROCESS_NAMES
162 static void
163 print_processes(struct process * const processes[])
164 {
165  /* const struct process * const * p = processes;*/
166  printf("Starting");
167  while(*processes != NULL) {
168  printf(" '%s'", (*processes)->name);
169  processes++;
170  }
171  putchar('\n');
172 }
173 #endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
174 /*--------------------------------------------------------------------------*/
175 #if WITH_UIP
176 static void
177 set_gateway(void)
178 {
179  if(!is_gateway) {
180  leds_on(LEDS_RED);
181  PRINTF("%d.%d: making myself the IP network gateway.\n\n",
183  PRINTF("IPv4 address of the gateway: %d.%d.%d.%d\n\n",
184  uip_ipaddr_to_quad(&uip_hostaddr));
185  uip_over_mesh_set_gateway(&linkaddr_node_addr);
186  uip_over_mesh_make_announced_gateway();
187  is_gateway = 1;
188  }
189 }
190 #endif /* WITH_UIP */
191 /*---------------------------------------------------------------------------*/
192 static void
193 start_autostart_processes()
194 {
195 #if !PROCESS_CONF_NO_PROCESS_NAMES
196  print_processes(autostart_processes);
197 #endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
198  autostart_start(autostart_processes);
199 }
200 /*---------------------------------------------------------------------------*/
201 #if WITH_UIP6
202 static void
203 start_uip6()
204 {
205  NETSTACK_NETWORK.init();
206 
207  process_start(&tcpip_process, NULL);
208 
209 #if DEBUG
210  PRINTF("Tentative link-local IPv6 address ");
211  {
212  uip_ds6_addr_t *lladdr;
213  int i;
214  lladdr = uip_ds6_get_link_local(-1);
215  for(i = 0; i < 7; ++i) {
216  PRINTF("%02x%02x:", lladdr->ipaddr.u8[i * 2],
217  lladdr->ipaddr.u8[i * 2 + 1]);
218  }
219  PRINTF("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
220  }
221 #endif /* DEBUG */
222 
223  if(!UIP_CONF_IPV6_RPL) {
224  uip_ipaddr_t ipaddr;
225  int i;
226  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
227  uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
228  uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
229  PRINTF("Tentative global IPv6 address ");
230  for(i = 0; i < 7; ++i) {
231  PRINTF("%02x%02x:",
232  ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
233  }
234  PRINTF("%02x%02x\n",
235  ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
236  }
237 }
238 #endif /* WITH_UIP6 */
239 /*---------------------------------------------------------------------------*/
240 static void
241 start_network_layer()
242 {
243 #if WITH_UIP6
244  start_uip6();
245 #endif /* WITH_UIP6 */
246  start_autostart_processes();
247  /* To support link layer security in combination with WITH_UIP and
248  * TIMESYNCH_CONF_ENABLED further things may need to be moved here */
249 }
250 /*---------------------------------------------------------------------------*/
251 #if WITH_TINYOS_AUTO_IDS
252 uint16_t TOS_NODE_ID = 0x1234; /* non-zero */
253 uint16_t TOS_LOCAL_ADDRESS = 0x1234; /* non-zero */
254 #endif /* WITH_TINYOS_AUTO_IDS */
255 int
256 main(int argc, char **argv)
257 {
258  /*
259  * Initalize hardware.
260  */
261  msp430_cpu_init();
262  clock_init();
263  leds_init();
264  leds_on(LEDS_RED);
265 
266 
267  uart1_init(BAUD2UBR(115200)); /* Must come before first printf */
268 
269  leds_on(LEDS_GREEN);
270  ds2411_init();
271 
272  /* XXX hack: Fix it so that the 802.15.4 MAC address is compatible
273  with an Ethernet MAC address - byte 0 (byte 2 in the DS ID)
274  cannot be odd. */
275  ds2411_id[2] &= 0xfe;
276 
277  leds_on(LEDS_BLUE);
278  xmem_init();
279 
280  leds_off(LEDS_RED);
281  rtimer_init();
282  /*
283  * Hardware initialization done!
284  */
285 
286  /* Initialize energest first (but after rtimer)
287  */
288  energest_init();
289  ENERGEST_ON(ENERGEST_TYPE_CPU);
290 
291 #if WITH_TINYOS_AUTO_IDS
292  node_id = TOS_NODE_ID;
293 #else /* WITH_TINYOS_AUTO_IDS */
294  /* Restore node id if such has been stored in external mem */
295  node_id_restore();
296 #endif /* WITH_TINYOS_AUTO_IDS */
297 
298  /* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
299 #ifdef IEEE_802154_MAC_ADDRESS
300  {
301  uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
302  memcpy(ds2411_id, ieee, sizeof(uip_lladdr.addr));
303  ds2411_id[7] = node_id & 0xff;
304  }
305 #endif
306 
307  random_init(ds2411_id[0] + node_id);
308 
309  leds_off(LEDS_BLUE);
310  /*
311  * Initialize Contiki and our processes.
312  */
313  process_init();
314  process_start(&etimer_process, NULL);
315 
316  ctimer_init();
317 
318 #if WITH_UIP
319  slip_arch_init(BAUD2UBR(115200));
320 #endif /* WITH_UIP */
321 
322  init_platform();
323 
324  set_rime_addr();
325 
326  cc2420_init();
327  {
328  uint8_t longaddr[8];
329  uint16_t shortaddr;
330 
331  shortaddr = (linkaddr_node_addr.u8[0] << 8) +
332  linkaddr_node_addr.u8[1];
333  memset(longaddr, 0, sizeof(longaddr));
334  linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);
335  PRINTF("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
336  longaddr[0], longaddr[1], longaddr[2], longaddr[3],
337  longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
338 
339  cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
340  }
341 
342  PRINTF(CONTIKI_VERSION_STRING " started. ");
343  if(node_id > 0) {
344  PRINTF("Node id is set to %u.\n", node_id);
345  } else {
346  PRINTF("Node id is not set.\n");
347  }
348 
349  /* PRINTF("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
350  ds2411_id[0], ds2411_id[1], ds2411_id[2], ds2411_id[3],
351  ds2411_id[4], ds2411_id[5], ds2411_id[6], ds2411_id[7]);*/
352 
353 #if WITH_UIP6
354  memcpy(&uip_lladdr.addr, ds2411_id, sizeof(uip_lladdr.addr));
355  /* Setup nullmac-like MAC for 802.15.4 */
356 /* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */
357 /* PRINTF(" %s channel %u\n", sicslowmac_driver.name, CC2420_CONF_CCA_THRESH); */
358 
359  /* Setup X-MAC for 802.15.4 */
360  queuebuf_init();
361  NETSTACK_RDC.init();
362  NETSTACK_MAC.init();
363 
364  PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u, CCA threshold %i\n",
365  NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
366  CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
367  NETSTACK_RDC.channel_check_interval()),
368  CC2420_CONF_CHANNEL,
369  CC2420_CONF_CCA_THRESH);
370 
371 #else /* WITH_UIP6 */
372 
373  NETSTACK_RDC.init();
374  NETSTACK_MAC.init();
375  NETSTACK_NETWORK.init();
376 
377  PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u\n",
378  NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
379  CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
380  NETSTACK_RDC.channel_check_interval()),
381  CC2420_CONF_CHANNEL);
382 #endif /* WITH_UIP6 */
383 
384 #if !WITH_UIP && !WITH_UIP6
385  uart1_set_input(serial_line_input_byte);
386  serial_line_init();
387 #endif
388 
389  leds_off(LEDS_GREEN);
390 
391 #if TIMESYNCH_CONF_ENABLED
392  timesynch_init();
394 #endif /* TIMESYNCH_CONF_ENABLED */
395 
396 #if WITH_UIP
397  process_start(&tcpip_process, NULL);
398  process_start(&uip_fw_process, NULL); /* Start IP output */
399  process_start(&slip_process, NULL);
400 
401  slip_set_input_callback(set_gateway);
402 
403  {
404  uip_ipaddr_t hostaddr, netmask;
405 
406  uip_init();
407 
408  uip_ipaddr(&hostaddr, 172,16,
410  uip_ipaddr(&netmask, 255,255,0,0);
411  uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
412 
413  uip_sethostaddr(&hostaddr);
414  uip_setnetmask(&netmask);
415  uip_over_mesh_set_net(&hostaddr, &netmask);
416  /* uip_fw_register(&slipif);*/
417  uip_over_mesh_set_gateway_netif(&slipif);
418  uip_fw_default(&meshif);
419  uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
420  PRINTF("uIP started with IP address %d.%d.%d.%d\n",
421  uip_ipaddr_to_quad(&hostaddr));
422  }
423 #endif /* WITH_UIP */
424 
425  watchdog_start();
426 
427  NETSTACK_LLSEC.bootstrap(start_network_layer);
428 
429  /*
430  * This is the scheduler loop.
431  */
432 #if DCOSYNCH_CONF_ENABLED
433  timer_set(&mgt_timer, DCOSYNCH_PERIOD * CLOCK_SECOND);
434 #endif
435 
436  /* watchdog_stop();*/
437  while(1) {
438  int r;
439  do {
440  /* Reset watchdog. */
442  r = process_run();
443  } while(r > 0);
444 
445  /*
446  * Idle processing.
447  */
448  int s = splhigh(); /* Disable interrupts. */
449  /* uart1_active is for avoiding LPM3 when still sending or receiving */
450  if(process_nevents() != 0 || uart1_active()) {
451  splx(s); /* Re-enable interrupts. */
452  } else {
453  static unsigned long irq_energest = 0;
454 
455 #if DCOSYNCH_CONF_ENABLED
456  /* before going down to sleep possibly do some management */
457  if(timer_expired(&mgt_timer)) {
459  timer_reset(&mgt_timer);
460  msp430_sync_dco();
461 #if CC2420_CONF_SFD_TIMESTAMPS
462  cc2420_arch_sfd_init();
463 #endif /* CC2420_CONF_SFD_TIMESTAMPS */
464  }
465 #endif
466 
467  /* Re-enable interrupts and go to sleep atomically. */
468  ENERGEST_OFF(ENERGEST_TYPE_CPU);
469  ENERGEST_ON(ENERGEST_TYPE_LPM);
470  /* We only want to measure the processing done in IRQs when we
471  are asleep, so we discard the processing time done when we
472  were awake. */
473  energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
474  watchdog_stop();
475  /* check if the DCO needs to be on - if so - only LPM 1 */
476  if (msp430_dco_required) {
477  _BIS_SR(GIE | CPUOFF); /* LPM1 sleep for DMA to work!. */
478  } else {
479  _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF); /* LPM3 sleep. This
480  statement will block
481  until the CPU is
482  woken up by an
483  interrupt that sets
484  the wake up flag. */
485  }
486  /* We get the current processing time for interrupts that was
487  done during the LPM and store it for next time around. */
488  dint();
489  irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
490  eint();
491  watchdog_start();
492  ENERGEST_OFF(ENERGEST_TYPE_LPM);
493  ENERGEST_ON(ENERGEST_TYPE_CPU);
494  }
495  }
496 
497  return 0;
498 }
499 /*---------------------------------------------------------------------------*/
500 #if LOG_CONF_ENABLED
501 void
502 log_message(char *m1, char *m2)
503 {
504  printf("%s%s\n", m1, m2);
505 }
506 #endif /* LOG_CONF_ENABLED */
Coffee architecture-dependent header for the Tmote Sky platform.
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
Definition: uart1.c:143
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
Definition: serial-line.c:60
#define uip_sethostaddr(addr)
Set the IP address of this host.
Definition: uip.h:195
linkaddr_t linkaddr_node_addr
The Rime address of the node.
Definition: linkaddr.c:48
uIP packet forwarding header file.
int process_nevents(void)
Number of events waiting to be processed.
Definition: process.c:316
A timer.
Definition: timer.h:86
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
Definition: uip6.c:115
802.15.4 frame creation and parsing functions
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
Instantiating macro for a uIP network interface.
Definition: uip-fw.h:80
Representation of a uIP network interface.
Definition: uip-fw.h:54
#define LEDS_RED
LED1 (Red) -&gt; PC0.
Definition: board.h:89
Unicast address structure.
Definition: uip-ds6.h:172
void timesynch_init(void)
Initialize the timesynch module.
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
Definition: watchdog.c:49
uip_ipaddr_t ipaddr
The IP address of this interface.
Definition: uip-fw.h:57
Header file for the uIP TCP/IP stack.
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
Definition: uip-ds6.c:535
void rtimer_init(void)
Initialize the real-time scheduler.
Definition: rtimer.c:61
Network interface and stateless autoconfiguration (RFC 4862)
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
Definition: timer.c:64
#define NULL
The null pointer.
void uip_log(char *msg)
Print out a uIP log message.
Definition: uip-log.c:3
Header file for tunnelling uIP over Rime mesh
void clock_init(void)
Initialize the clock library.
Definition: clock.c:76
int main(void)
This is main...
Definition: ethconfig.c:49
void process_init(void)
Initialize the process module.
Definition: process.c:208
Header file for the Rime stack
void timesynch_set_authority_level(int level)
Set the authority level of the current time.
#define LEDS_GREEN
LED3 (Green) -&gt; PC2.
Definition: board.h:81
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
Definition: linkaddr.c:60
void random_init(unsigned short seed)
Seed the cc2430 random number generator.
Definition: random.c:41
void slip_arch_init(unsigned long ubr)
Initalize the RS232 port and the SLIP driver.
Definition: slip-arch.c:56
void watchdog_stop(void)
In watchdog mode, the WDT can not be stopped.
Definition: watchdog.c:58
Generic serial I/O process header filer.
void watchdog_periodic(void)
Writes the WDT clear sequence.
Definition: watchdog.c:64
Header file for module for automatically starting and exiting a list of processes.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
Definition: uip.h:1026
void ctimer_init(void)
Initialize the callback timer library.
Definition: ctimer.c:91
#define uip_ipaddr_to_quad(a)
Convert an IP address to four bytes separated by commas.
Definition: uip.h:927
void uip_init(void)
uIP initialization function.
Definition: uip6.c:411
void uip_fw_default(struct uip_fw_netif *netif)
Register a default network interface.
Definition: uip-fw.c:515
uip_ipaddr_t netmask
The netmask of the interface.
Definition: uip-fw.h:58
void process_start(struct process *p, process_data_t data)
Start a process.
Definition: process.c:99
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
Definition: uip-ds6.h:123
int process_run(void)
Run the system once - call poll handlers and process one event.
Definition: process.c:302
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
Definition: linkaddr.c:72
Header for the Coffee file system.
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
Construct an IP address from four bytes.
Definition: uip.h:955
int timer_expired(struct timer *t)
Check if a timer has expired.
Definition: timer.c:121
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
Definition: uip.h:969
#define uip_setnetmask(addr)
Set the netmask.
Definition: uip.h:239
void timer_reset(struct timer *t)
Reset the timer with the same interval.
Definition: timer.c:84
Include file for the Contiki low-layer network stack (NETSTACK)
#define CLOCK_SECOND
A second, measured in system clock time.
Definition: clock.h:82