How to get the data from a USB port in VB.NET
Asked Answered
N

3

9

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....

Nammu answered 15/2, 2012 at 15:53 Comment(5)
Do you already have drivers ect for this device? Is it as simple as just reading a file off a USB memory stick?Regin
What interface does the device implement? You have a couple of standard interfaces for USB: USB Keyboards, USB drives, USB Serial... If the device communicates using one of these, you are in luck and there probably is a standard interface. If the device does not implement these, you will have to resort to writing your own driver or interfacing with the vendor-supplied driver. Your best bet is to ask the vendor if there is an API available; what you are trying to do is not as easy as "reading the USB port". Look at the Device Manager. How is the USB device reported? Special drivers?Platy
Hello @Platy My device connects using the serial port Com port... And the device does not require driver, its sending some packets of data.Nammu
See lvr.com/serial_ports_dotnet.htmPlaty
What you want to read from it is just a bunch of zeros and ones? Without a driver to translate it, this data will make absolutely no sense. What's the device you are using? Using a Com port is not the same as using a USB port, are you aware of that?Dannielledannon
C
12

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

Cesspool answered 19/2, 2012 at 9:56 Comment(4)
Thanks for the quick answer John, let me check it... If it can work for me :)Nammu
I used that DLL when i made a security program which locks the explorer when there is no flashdrive attached on the computer.Cesspool
Both of these links are broken now; they go to a fashion website. Domain was probably sold.Chere
FYI: The links should now go to: janaxelson.com instead of lvr.com. I edited the answer to reflect those changes, so once it gets reviewed, they should be correct now.Ogilvy
O
4

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

Ottillia answered 16/2, 2012 at 8:47 Comment(0)
N
2

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.

Nammu answered 19/2, 2012 at 9:53 Comment(4)
Is this an answer? Or additional information that belongs in the question?Mesne
@cody-grey This is the answer which i found from one of my friend.... This is to let everyone now, that i have understood this much, but still how to get this thing practically... is in question...Nammu
the above are not two ways ... but steps :-)Caritta
@Caritta Its an old thread but anyway... Those are actually two different ways, not steps. Many USB devices has their own drivers, but some often use standard FTDI USB to COMport convertor. And when you use that, you dont connect to USB, but to simulated COM port.Trafficator

© 2022 - 2024 — McMap. All rights reserved.