阅读:1294回复:2
高分求助!driverworks生成USB驱动求助!!!!
小弟我刚开始搞USB驱动,一师兄让我先用BUS HOUND抓一U盘的描述符,找到其批量传输的端点,然后编写一简单的从输出端点读数据,再把数据写到输入端点中。
我用driverworks生成了一框架,对端口1进行读操作,对2进行写操作,没有改动生成的驱动。 安装驱动后运行应用程序出现 Test application Test_usb starting... Device found, handle open。 Usage: Test_usb [r n] [w n] [i n]\\n r initiates a read of specified number of bytes w initiates a write of specified number of bytes i initiates an IO Control Code message withspecified index value (no IO Control Codes are defined) Example: Test_usb r 32 w 32 read 32 bytes, then write 32 bytes 应用程序主要部分 int __cdecl main(int argc, char *argv[]) { int nArgIndex; // Walk through command line arguments int nArgIncrement = 0; int val; DWORD Error; printf(\"Test application Test_usb starting...\\n\"); hDevice = OpenByInterface( &ClassGuid, 0, &Error); if (hDevice == INVALID_HANDLE_VALUE) { printf(\"ERROR opening device: (%0x) returned from CreateFile\\n\", GetLastError()); Exit(1); } else { printf(\"Device found, handle open.\\n\"); } // Parse the command line if (argc < 2) Usage();//程序到这里终止,我输出了一下argc的值,是1,不知道这个值代表什么意思? nArgIndex = 1; while (nArgIndex < argc) { // Parse ahead to determine numeric value of argument if (nArgIndex+1 >= argc) Usage(); if (!isdigit(argv[nArgIndex+1][0])) Usage(); val = atoi(argv[nArgIndex+1]); switch (argv[nArgIndex][0]) { case \'r\': case \'R\': doRead(val); nArgIncrement = 2; break; case \'w\': case \'W\': doWrite(val); nArgIncrement = 2; break; case \'i\': case \'I\': printf(\"No IO Control Codes defined\\n\"); Exit(1); case \'?\': case \'h\': default: Usage(); } nArgIndex += nArgIncrement; } return 0; } 我把函数doRead放在Usage前运行的话会产生错误,机子就会自动重起,是我的端点方向搞错了?还是传输最大值错了?还是方法根本不对,希望各位大哥帮帮我。 只要回复就给分!!!!!!!!! [编辑 - 4/16/05 by superwu] [编辑 - 4/16/05 by superwu] |
|
沙发#
发布于:2005-04-19 13:07
运行测试程序的时候需要输入参数
int __cdecl main(int argc, char *argv[]) argc表示参数个数 ,argv指针数组指向输入的参数 argc=1表示运行测试程序的时候没有输入参数(为什么是1不是0可能是有一个默认的参数吧) 参数怎么输入: 在vc的环境中project->setting->debug中program argument这一行输入 或者在命令提示符号下在可执行文件名后跟上你的参数 |
|
板凳#
发布于:2005-04-16 19:38
没有人知道吗?
|
|