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

📄 cmd_usbio.c

📁 USB monitor
💻 C
字号:
/* cmd_usbio.c - Nereid USB Monitor / USB Input/Output command * Copyright (C) 2003 Tachibana Eriko * * 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 */#include <stdio.h>#include <stdlib.h>#include "include/usbdef.h"#include "cmd_usbio.h"#include "usbinfo.h"#include "usbio.h"#include "usbmon.h"#include "util.h"/* Functions */static void usb_input_sub (int devadr, int ep, int len);/* ---------------------------------------------------------------------- *//* Command: 僨乕僞擖椡 */intusb_input (int argc, char* argv[]){  int i;  if (argc == 0)    {      printf ("<devadr> = 1乣127\tUSB 婡婍偺僨僶僀僗傾僪儗僗傪巜掕偟傑偡.\n"	      "<ep> = 0乣15\t\t僄儞僪億僀儞僩斣崋傪巜掕偟傑偡.\n"	      "<len> = 0乣\t撉傒崬傓挿偝傪巜掕偟傑偡.\n");      /* 惓忢廔椆 */      return RET_SUCCESS;    }/* UsbTransfer() 偺僶僌偑庢傟偨傜丄孞傝曉偟夞悢傪巜掕偱偒傞傛偆偵偡傞梊掕 */  for (i = 0; i < argc; i += 3)    {      int devadr, ep, len;      if (argc < i + 3)	{	  printf ("input: 堷悢偑懌傝傑偣傫.\n");	  return RET_FAILURE;	}      if ((sscanf (argv[i + 0], "%i", &devadr) != 1)       || (sscanf (argv[i + 1], "%i", &ep) != 1)       || (sscanf (argv[i + 2], "%i", &len) != 1)       || (devadr < 0 || DEVADR_MAX < devadr)       || (ep < 0 || ENDPOINT_MAX < ep)       || (len < 0))	{	  printf ("input: 堷悢偑惓偟偔偁傝傑偣傫.\n");	  return RET_FAILURE;	}      usb_input_sub (devadr, ep, len);    }  /* 惓忢廔椆 */  return RET_SUCCESS;}/* 僨乕僞擖椡 壓惪偗 */static voidusb_input_sub (int devadr, int ep, int len){  UsbInfo* usb = get_usbinfo (devadr);  unsigned char* buf;  int rc;  if (usb == NULL)    return;  if ((buf = malloc (len)) == NULL)    {      perror ("input");      return;    }  rc = UsbTransfer (usb->devadr, ep, PID_IN, buf, len, usb->bMaxPacketSize0, usb->speed);  if (rc > 0)    {      printf ("%d 僶僀僩庴怣偟傑偟偨.\n", rc);      hexdump (buf, rc);      printf ("\n");    }  free (buf);}/* ---------------------------------------------------------------------- *//* Command:  */intusb_output (int argc, char* argv[]){  printf ("output: 傑偩幚憰偝傟偰偄傑偣傫.\n");  /* 惓忢廔椆 */  return RET_SUCCESS;}/* ---------------------------------------------------------------------- *//* EOF */

⌨️ 快捷键说明

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