USB口的问题,200分求解

syeerzy 2005-09-04 12:48:07
有一台设备在USB口上,现在需要向这个口写一串信号,假设为010111011000

现在问题是设备插在哪个口都可能.

求思路与可用的类方法或Win32API.

这个设备是一个可编码的遥控器.不是U盘等存储设备.
...全文
257 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
syeerzy 2005-09-04
  • 打赏
  • 举报
回复
多谢2位,再过一天结贴.

2位提供的信息对我帮助都很大.
syeerzy 2005-09-04
  • 打赏
  • 举报
回复
谢谢 timiil(小华) ,现在这个机器上无2005,打不开那个例子。还是谢谢。

里面代码比较多,等有时间值得研究一下。

向U口直接写2进制数据不知道哪位做过的也顺便介绍一下经验嘛,比如容易犯的毛病或忽略的问题,以及一些非常规与常规方法的区别等。
zeusvenus 2005-09-04
  • 打赏
  • 举报
回复
看看下面这哥们的回复,如果只是在WIN32平台下,可以简单使用GetDefaultCommConfig()这个API。
Why don't you simply call the Win32 API GetDefaultCommConfig() to figure out whether a specific port exists. Optionally followed by CreateFile() if you like to know if another process currently has opened that port.
Works on all Win32 platforms and is much simpler.

Attention:
COM10 or greater must be preceeded with "\\.\" for calls to CreateFile(). See Q115831 for details. WinCE needs a trailing ":" for both GetDefaultCommConfig() and CreateFile().

zeusvenus 2005-09-04
  • 打赏
  • 举报
回复
上面提供免费下载的代码,直接调用就行了,刚好是解决这问题的。
Introduction
You might think that determining which serial ports are present on a Windows PC would be an easy task. It seems like a reasonable enough thing for the OS to support. Unfortunately, there was no support for it at all (short of reading the registry yourself) before Win2K, and even then, the API is a bit cumbersome.

The attached serial port enumeration code first determines which operating system it is running under, and then runs the appropriate routine to enumerate the serial ports. In Win 9x (and Me) it uses the registry. In W2K and later it uses the SetupAPI that was included in that version of the WinSDK. It also has support for "brute force" enumeration of serial ports under NT4.

Unfortunately, I statically linked with setupapi.lib, so the provided executable won't actually run under 95 and nt4 (I didn't really need to support those OS's for my application.) This could be finagled by replacing the SetupDi* function calls with dynamic binding via LoadLibrary if needed.

To use the EnumSerial code, simply include EnumSerial.cpp and .h in your project, and link with setupapi.lib in the win32 sdk (this is under "additional dependencies" in the project link settings in Visual Studio).

All you have to do now is #include "EnumSerial.h" in your source code, allocate an empty CArray of SSerInfo structs, and make a call to EnumSerialPorts. It will populate your array with filled-out SSerInfo structs which contain the following information:

CString strDevPath; // Device path for use with CreateFile()
CString strPortName; // Simple name (i.e. COM1)
CString strFriendlyName; // Full name to be displayed to a user
BOOL bUsbDevice; // Provided through a USB connection?
CString strPortDesc; // friendly name without the COMx
Example
CArray<SSerInfo,SSerInfo&> asi;
EnumSerialPorts(asi,FALSE/*include all*/);

zeusvenus 2005-09-04
  • 打赏
  • 举报
回复
终于找到一个了,看看
http://www.codeproject.com/system/setupdi.asp?target=USB%7Cport
呵呵
syeerzy 2005-09-04
  • 打赏
  • 举报
回复
不至于吧。。。。。200分都这么冷清?
timiil 2005-09-04
  • 打赏
  • 举报
回复
http://weblogs.asp.net/israelio/archive/2005/08/15/422637.aspx
介绍的好像不错
zeusvenus 2005-09-04
  • 打赏
  • 举报
回复
遍寻?
mark.
标题付费自习室管理系统的设计与实现研究AI更换标题第1章引言介绍付费自习室管理系统的研究背景、意义、国内外发展现状及论文创新点。1.1研究背景与意义阐述付费自习室兴起背景及管理系统的重要性。1.2国内外发展现状析国内外付费自习室及其管理系统的发展情况。1.3论文研究方法及创新点概述本文采用的研究方法及系统设计的创新之处。第2章相关理论总结和评述与付费自习室管理系统相关的现有理论。2.1管理信息系统理论介绍管理信息系统的基本概念、构成及作用。2.2用户需求析理论阐述用户需求析的方法和步骤。2.3系统设计理论介绍系统设计的原则、方法和流程。第3章付费自习室管理系统需求析详细描述付费自习室管理系统的功能需求和非功能需求。3.1功能需求析用户管理、座位预订、费用结算等核心功能需求。3.2非功能需求析阐述系统性能、安全性、易用性等非功能需求。3.3用户调研与反馈介绍用户调研方法及收集到的用户反馈意见。第4章付费自习室管理系统设计详细介绍付费自习室管理系统的设计方案和实现过程。4.1系统架构设计给出系统的整体架构、模块划及交互流程。4.2数据库设计设计数据库结构,包括表结构、字段定义及关系。4.3界面设计展示系统界面设计,包括布局、色彩搭配及交互元素。第5章付费自习室管理系统实现与测试阐述付费自习室管理系统的实现过程和测试结果。5.1系统实现技术介绍系统开发所采用的技术栈和工具。5.2系统测试方法阐述系统测试的方法、步骤及测试用例设计。5.3系统测试结果与析展示系统测试结果,包括功能测试、性能测试等,并进行析。第6章结论与展望总结本文的研究成果,并对未来研究方向进行展望。6.1研究结论概括付费自习室管理系统的设计成果及实施效果。6.2展望指出系统存在的不足及未来改进方向,提出后续研究建议。
标题宾馆客房管理系统的设计与实现研究AI更换标题第1章引言介绍宾馆客房管理系统的研究背景、研究意义、国内外研究现状、论文方法及创新点。1.1研究背景与意义阐述宾馆客房管理系统对提升管理效率和服务质量的重要性。1.2国内外研究现状析国内外宾馆客房管理系统的研究现状与发展趋势。1.3研究方法及创新点概述本文采用的研究方法及系统设计的创新之处。第2章相关理论介绍宾馆客房管理系统设计涉及的相关理论和技术。2.1数据库管理理论阐述数据库设计的基本原理和管理方法。2.2软件开发理论介绍软件开发的基本流程和项目管理方法。2.3用户界面设计理论讨论用户界面设计原则和用户体验优化方法。第3章宾馆客房管理系统需求析详细析宾馆客房管理系统的功能需求和性能需求。3.1功能需求析列举系统应具备的主要功能,如预订、入住、退房等。3.2性能需求析系统在响应时间、并发处理等方面的性能要求。3.3用户需求析从用户角度出发,析用户对系统的期望和需求。第4章宾馆客房管理系统设计详细介绍系统的整体架构和各个模块的设计方案。4.1系统架构设计给出系统的整体架构图,包括前端、后端和数据库等部。4.2数据库设计详细介绍数据库的设计方案,包括表结构、字段设置等。4.3模块设计别介绍各个模块的设计思路和功能实现方法。第5章宾馆客房管理系统实现与测试介绍系统的实现过程和测试方法,验证系统的功能性和性能。5.1系统实现阐述系统的开发环境、开发工具和实现步骤。5.2系统测试介绍系统的测试方法、测试用例和测试结果。5.3性能优化根据测试结果,对系统进行性能优化和改进。第6章结论与展望总结本文的研究成果,并对未来研究方向进行展望。6.1研究结论概括本文的主要研究成果和系统的实际应用效果。6.2展望指出系统存在的不足之处和未来改进的方向。

111,118

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧