如何在VB.NET中从USB端口获取数据
我开发了一个用于管理患者详细信息的软件,该软件将数据存储到MSsql数据库中...... 但是,我需要存储的数据必须从传输数据的外部设备读取...现在我的查询是如何使用 VB.NET 2010 读取该数据。
我在网上搜索并发现我可以使用My.Computer.Port 从 USB 连接的设备读取数据,但我无法获取其逻辑和任何实际完成此操作的示例...
我也阅读了很多书籍来了解执行此操作的实际方法,但还没有解决任何事情......
如果有人可以帮助我示例,以便我找到完成任务的方法......
I have developed a software for managing the details of patients, the software stores the data into MSsql database....
However, the data I need to get stored has to be read from an external device which transmits data... Now my query is how I can read that data using VB.NET 2010.
I have searched on net and found that I can use My.Computer.Port to read data from USB connected device, but I am unable to get its logic and any example to get this practically done...
I also been through many books to understand the practical way of doing this, but not yet resolved with anything.....
If somebody can help me with an example so that i get a way forward to accomplish my task....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我发现的。您可以使用 HID.dll 连接 USB 端口。你知道最好的部分吗?我找到了一些例子。
以下链接包含 USB 接口的基本示例和教程。 HID 页面
示例项目文件
Here is what I found. You use the HID.dll to interface the usb ports. And you know the best part? I found some examples.
Here's a link that contains basic examples and tutorial for usb interfacing. The HID Page
Sample Project File
你循环那些:
IO.DriveInfo.GetDrives() 并检查 DeviceType = IO.DriveType.Removable
然后使用它复制数据或其他内容的设备名称
了解详细信息请查看:检测 USB 驱动器
You loop those :
IO.DriveInfo.GetDrives() and check where DeviceType = IO.DriveType.Removable
then the device name to use it copying data or other stuff
for details check this out : Detect USB drive
Abhilash(我只问了这个问题)
我添加这个问题,只是为了让大家知道,我目前对该主题的理解......
我实际上是从我的一位认识的人......
他向我解释了这一点:-
基本上有两种方法可以从外部仪器获取数据。第一种方法是使用仪器附带的软件。如果仪器有任何类型的接口,都应该有一些读取数据的软件。您可以使用该软件将数据存储到文件中,您的应用程序将读取具有固定结构的文件。很简单。
如果仪器提供串口但没有软件,则可以使用 My.Computer.Port 命名空间访问仪器的串口。向串行端口发送命令并读回响应很容易,但您必须知道另一端识别的命令。您将需要有关该设备的详细文档,您很可能可以在 Internet 上找到这些文档。
第一种方法始终是首选。当然,你必须将数据与患者联系起来。这可能很棘手。如果您能找到允许您将仪器中的数据下载到计算机上的软件,那么获取数据就会很简单。由于有人必须将设备连接到计算机,因此他们还可以启动应用程序并将数据保存到文件中。
Abhilash (I only asked this question)
I am adding this, Just to let you people know, my current understanding about the topic...
I actually asked for the question from one of my know person....
He explained me this:-
There are basically two ways to get data from an external instrument. The fist method is to use the software than came with the instrument. If the instrument has an interface of any type, there should be some software that reads the data. You can use this software to store the data to a file and your application will read a file with s fixed structure. very simple.
If the instrument provides a serial port but no software, then you can use the My.Computer.Port namespace to access the instrument's serial port. It's easy to send commands to a serial port and read back the response, but you have to know the commands that the other end recognizes. You will need detailed documentation about the device, which you will most likely find on the Internet.
The first approach is always preferrable. Of course, you have to associate the data with patients. This can be tricky. If you can find the software that allows you to download data from the instrument to your computer, it will be straightforward to acquire the data. Since someone must connect the device to a computer, they can also start the application and save the data to a file.