⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node_id.c

📁 MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis的0.9.5版本的源码。
💻 C
字号:
//  This file is part of MANTIS OS, Operating System//  See http://mantis.cs.colorado.edu/////  Copyright (C) 2003,2004,2005 University of Colorado, Boulder////  This program is free software; you can redistribute it and/or//  modify it under the terms of the mos license (see file LICENSE)/**************************************************************************//* File:    node_id.c                                                     *//* Author   Jeff Rose    rosejn@colorado.edu                              *//*   Date:  05/19/2004                                                    *//*                                                                        *//* Description: Gets a random ID initially and lets the user set one.     *//**************************************************************************/#include "mos.h"#include "arg.h"#include <sys/types.h>#include <unistd.h>#include <stdlib.h>#include <stdio.h>boolean retrieved = FALSE;static uint16_t node_id;void mos_node_id_init (){   int r;   pid_t pid = getpid ();   uint8_t *id;      if (mos_arg_check ("-id", &id)) {      node_id = atoi (id);      printf ("Got id: %d\n", node_id);   } else {      srand ((unsigned int)pid);      r = rand ();      node_id = r % UINT16_MAX;   }}inline uint16_t mos_node_id_get (){   return node_id;}void mos_node_id_set (uint16_t new_node_id){   node_id = new_node_id;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -