Hi,I'm studing USBLIB for communciate with a device connected to my PC.
When I found a device who I want to talk,what will I do?
I use device.BulkRead(0, msg) for read data from the endpoint. "0" is correct?
For example I have connected my USB Flash disk to the pc and I found it with the follow code line...
------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplicationUSB
{
class Program
{
static void Main(string[] args)
{
byte[] msg = new byte[8];
foreach (ICSharpCode.USBlib.Bus bus in ICSharpCode.USBlib.Bus.Busses)
{
Console.WriteLine(bus);
foreach (ICSharpCode.USBlib.Descriptor descriptor in bus.Descriptors)
{
try
{
if (descriptor.VendorId == 0xEA0 && descriptor.ProductId ==
0x2168) //identifier or my USB flash disk
{
ICSharpCode.USBlib.Device device = descriptor.OpenDevice();
Console.WriteLine("\t\t Product: " +
device.Product);
Console.WriteLine("\t\tManufacturer: " + device.Manufacturer);
Console.WriteLine();
while (true)
{
device.SendControlMessage
device.BulkRead(0, msg);
for (int i = 0; i < msg.Length; i++)
Console.Write(Convert.ToString(msg[i]));
Console.WriteLine();
System.Threading.Thread.Sleep(500);
}
}
else
Console.WriteLine("Not found");
}
catch (ICSharpCode.USBlib.UsbException e)
{
Console.WriteLine("Got Exception : " + e);
}
}
}
}
}
}
For testing the application I have transfer some data from the USB
flash disk with the HDD of my pc, and at the same time I run my
application that it read forever from the endpoint 0 and it prints the
values read.
But the result of the bulkread is always "0"
Someone can tell me how to resolve my problem?
Thanks.
Nicola