vb.net 如何从VB.NET中的USB端口获取数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9296609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the data from a USB port in VB.NET
提问by Django Anonymous
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.
我开发了一个用于管理患者详细信息的软件,该软件将数据存储到 MSsql 数据库中......但是,我需要存储的数据必须从传输数据的外部设备中读取......现在我的查询是我如何使用 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...
我在网上搜索,发现我可以使用 My.Computer.Port 从 USB 连接的设备读取数据,但我无法得到它的逻辑和任何例子来实际完成这个......
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....
如果有人能帮我举个例子,让我有办法完成我的任务......
回答by John Woo
Here is what I found. You use the HID.dllto interface the usb ports. And you know the best part? I found some examples.
这是我发现的。您使用HID.dll来连接 USB 端口。你知道最好的部分吗?我找到了一些例子。
Here's a link that contains basic examples and tutorial for usb interfacing. The HID Page
这是一个包含 USB 接口基本示例和教程的链接。隐藏页面
回答by Amen Ayach
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
你循环那些: IO.DriveInfo.GetDrives() 并检查 DeviceType = IO.DriveType.Removable 的位置,然后设备名称使用它复制数据或其他东西
for details check this out : Detect USB drive
有关详细信息,请查看:检测 USB 驱动器
回答by Django Anonymous
Abhilash (I only asked this question)
Abhilash(我只问了这个问题)
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.
如果仪器提供串口但没有软件,那么您可以使用 My.Computer.Port 命名空间访问仪器的串口。向串行端口发送命令并读回响应很容易,但您必须知道另一端识别的命令。您将需要有关该设备的详细文档,这些文档很可能在 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.
第一种方法总是可取的。当然,您必须将数据与患者相关联。这可能很棘手。如果您能找到允许您将数据从仪器下载到计算机的软件,则获取数据将很简单。由于有人必须将设备连接到计算机,他们还可以启动应用程序并将数据保存到文件中。