📄 rf_util.h
字号:
/* rf_util.h Header file for various utility functions ------------------------------------------------------------------------- Copyright (c) 2002, Sensoria Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Sensoria Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <rf.h>#ifndef __RF_UTIL_H__#define __RF_UTIL_H__ /*Allow linkage to C or C++*/__BEGIN_DECLS/* * ioctls, functions for reading status devices */#define TICKER_IOCTL_TYPE 0x5e#define TICKER_SIZE 0x01#define TICKER_DATA 0x02#define TICKER_CLEAR 0x03int ticker_client_clear_readable(int fd);void *ticker_client_binary_read(int fd, size_t *size_ptr);/* simple file helpers */int write_to_file(const char *file, const char *s);int read_from_file(const char *file, char *s, size_t size);/* hexdump of packet data */void fprintf_hexdump(FILE *f, const char *input, int count);/* int max() function */static inline int max(int x, int y) { return (x > y) ? x : y;}char *sim_path(char *orig_path);void sim_init();#ifdef __RF_UTIL_C__extern node_id_t my_node_id;#endif/* * Packet format for the heartbeat packet type. * Exposed so that rfdump can parse them... */struct rf_hb_ack { if_id_t src; // interface address of neighbor uint16_t last_observed_seq; // last sequence number observed uint8_t RSSI; // RSSI of received signal uint8_t reserved; };struct rf_hb { if_id_t src; // 32 bits, sets rf interface address at receiver (wit specific) node_id_t node_id; // 32 bits, unique node id (serial number) uint32_t services:24; // 24 bits, services bitmap uint8_t flags; // 8 bits, flags uint16_t seqno; // 16 bits, sequence number unsigned int heart_period:7; // heart period in quarter-seconds unsigned int num_neighbors:5; // number of neighbors unsigned int acks_per_page:4; // num of acks that fit in each hb struct rf_hb_ack data[0]; // data target address};/* Allow linkage to C or C++ */__END_DECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -