packet.h

来自「主要用于无线传感网络的编写的书籍.对于初学者有着很大的用处」· C头文件 代码 · 共 43 行

H
43
字号
#ifndef __PACKET__#define __PACKET__#include "../../types/types.h"#include "../link/frame.h"#ifndef SUCCESS#define SUCCESS 1#define FAILURE 0#endif#ifndef TRUE#define TRUE  1#define FALSE 0#endif#define WRITEADDRESS 0xFFFFtypedef struct {  uint16_t address; // on packet reception, this is TOS_UART_ADDR (0x7E), on transmission, this is destination  uint8_t port; // this is referred to as "type" in tos/system/AM.h and is number of parametrized interface  uint8_t group; // same as in AM.h  uint8_t length; // length of data in bytes} __attribute__((packed)) TOS_Hdr;#define PKT_MAX_DATA_SIZE (MTU - sizeof(TOS_Hdr) - 2) // the "- 2" is for the crctypedef struct {  TOS_Hdr hdr;  uint8_t  data[PKT_MAX_DATA_SIZE];} networkPkt; // monitors serial port until a packet is read successfully, returns SUCCESS or FAILUREint readNetworkPkt(int serial_port_fd, networkPkt *p);// sends a packet over the serial port, returns SUCCESS or FAILUREint writeNetworkPkt(int serial_port_fd, networkPkt *p);// prints a packet to output_file_descriptorvoid printPacket(int debug_type, int debug_level, FILE *output_file_descriptor, networkPkt *p);#endif

⌨️ 快捷键说明

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