How C # uses libusbdotnet to implement examples of USB communication

Source: Internet
Author: User
Online C#USB communication information is relatively small, basically is based on Libusbdotnet and Cyusb, about the printer equipment and there is a opos.

This post is based on libusbdotnet.

1. Download and install the Libusbdotnet installation file.

2. Run the filter Wizard, Install a device filter. Install a USB device that requires communication.

  

3. Build a simple console project to test for printing information that requires communication equipment.

  

Related code:

Reference


Using libusbdotnet;using libusbdotnet.main;using libusbdotnet.info;

Printusbinfo


 public static void Printusbinfo () {Usbdevice usbdevice = null;            Usbregdevicelist alldevices = usbdevice.alldevices;            Console.WriteLine ("Found {0} devices", Alldevices.count); foreach (Usbregistry usbregistry in alldevices) {Console.WriteLine ("Got device: {0}\r\n", Usbre Gistry.                FullName); if (Usbregistry.open (out Usbdevice)) {Console.WriteLine ("Device information\r\n--------                    ----------");                    Console.WriteLine ("{0}", usbDevice.Info.ToString ()); Console.WriteLine ("VID & PID: {0} {1}", UsbDevice.Info.Descriptor.VendorID, UsbDevice.Info.Descriptor.ProductID)                    ;                    Console.WriteLine ("\r\ndevice configuration\r\n--------------------"); foreach (Usbconfiginfo usbconfiginfo in Usbdevice.configs) {Console.WriteLine ("           {0} ", usbconfiginfo.tostring ());             Console.WriteLine ("\r\ndevice interface list\r\n---------------------");                        readonlycollection<usbinterfaceinfo> interfacelist = usbconfiginfo.interfaceinfolist; foreach (Usbinterfaceinfo usbinterfaceinfo in interfacelist) {CONSOLE.W                            Riteline ("{0}", usbinterfaceinfo.tostring ());                            Console.WriteLine ("\r\ndevice endpoint list\r\n--------------------");                            readonlycollection<usbendpointinfo> endpointlist = usbinterfaceinfo.endpointinfolist; foreach (Usbendpointinfo usbendpointinfo in endpointlist) {Cons Ole.                            WriteLine ("{0}", usbendpointinfo.tostring ());                }}} usbdevice.close (); } Console.WriteLine ("\ r \ n-----Device Information Finished-----\ r \ n "); }        }

Call


public static void Main (string[] args)        {            printusbinfo ();            Wait for user input            : Console.readkey ();        }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.