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

📄 btdebug.c

📁 blue tooth protocol stack source code
💻 C
字号:
/* * btdebug.c -- Miscellaneous debug functions *         * Copyright (C) 2000, 2001  Axis Communications AB * * Author: Mattias Agren <mattias.agren@axis.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * Exceptionally, Axis Communications AB grants discretionary and * conditional permissions for additional use of the text contained * in the company's release of the AXIS OpenBT Stack under the * provisions set forth hereunder. * * Provided that, if you use the AXIS OpenBT Stack with other files, * that do not implement functionality as specified in the Bluetooth * System specification, to produce an executable, this does not by * itself cause the resulting executable to be covered by the GNU * General Public License. Your use of that executable is in no way * restricted on account of using the AXIS OpenBT Stack code with it. * * This exception does not however invalidate any other reasons why * the executable file might be covered by the provisions of the GNU * General Public License. * * $Id: btdebug.c,v 1.22 2001/06/06 14:57:19 mattiasagren Exp $ * *//****************** INCLUDE FILES SECTION ***********************************/#define __NO_VERSION__ /* don't define kernel_version in module.h */#ifdef __KERNEL__#include <linux/bluetooth/btdebug.h>#include <linux/bluetooth/bluetooth.h>#include <linux/time.h>#else#include "include/btdebug.h"#endif   /****************** CONSTANT AND MACRO SECTION ******************************//****************** TYPE DEFINITION SECTION *********************************//****************** LOCAL FUNCTION DECLARATION SECTION **********************//****************** GLOBAL VARIABLE DECLARATION SECTION *********************//****************** LOCAL VARIABLE DECLARATION SECTION **********************//****************** FUNCTION DEFINITION SECTION *****************************/#ifdef __KERNEL__static u8 buf[20];static struct timeval tv_old = {0, 0};u8* print_time(s32 use_stdout){	s32 len, diff;	struct timeval tv;  	do_gettimeofday(&tv);		diff = ((tv.tv_sec - tv_old.tv_sec)*1000000 + tv.tv_usec) - 		tv_old.tv_usec;		if (use_stdout == 1) {		printk("[%03d,%06d<%06d>] ", 		       (int)tv.tv_sec, (int)tv.tv_usec, diff);	}	else	{		len = sprintf(buf, "[%03d,%06d<%06d>] ", 			      (int)tv.tv_sec, tv.tv_usec, diff);		buf[len] = 0;	}	tv_old = tv;	return buf;}#else/* No timestamps in usermode yet */char* print_time(int use_stdout){	printf("No timestamps in usermode stack yet\n");	return "No timestamps in usermode stack yet\n";}#endifvoid print_data(const u8 *message, u8 *buf, s32 len){ 	s32 t = 0;#if BT_USE_TIMESTAMPS	if (message)		printk("\n%s %s (%d):\n", print_time(0), message, len);#else	if (message)		printk("\n%s (%d):\n", message, len);#endif	while (t < len)	{		printk("0x%02x ", buf[t++]);		if (!(t % 16))			printk("\n");	}	if (t % 16)		printk("\n");}const char* bd2str(const unsigned char *bd){  static char buf[20];  sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",          bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]);  return buf;}/****************** END OF FILE debug.c *************************************/

⌨️ 快捷键说明

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