USB to serial port virtual serial port driver

Source: Internet
Author: User
ArticleDirectory
    • Method -:
    • Method 2:
    • Use Windows APIs
    • MSComm control used in MFC
    • Use USB to serial drive cypress_m8.ko (kernel> = 2.6)
    • Use hiddev
Introduction: USB 2com is a virtual serial port driver of USB to serial port converter. Program (Windows2000/XP), USB-HID-> com converter (not tested) for the proxyess, and compatible devices. USB-HID-> com converter is compatible with USB hid devices, so you can access it directly with USB _ hid devices without using this driver.

Features:
    • You can set the baud rate, parity, and stop bits.
    • Event detection. Only serial_ev_rxchar | serial_ev_rxflag | serial_ev_txempty is supported.
    • Data Flow Control. Todo
    • Timeout settings. Todo
Installation Method -:
    1. Insert the hid-> com converter into the USB port.
    2. The hid-> com converter is recognized as a USB ergonomic input device.
    3. Choose Device Manager> ergonomic input device> USB ergonomic input device, and right-click the device.
    4. Select Update driver.
    5. Select to install from the list or a specified location, and click Next.
    6. Select do not search. I want to select the driver to be installed and click Next.
    7. Select the path where the driver is installed from the disk, and click OK.
    8. The system prompts that the Windows logo test is not passed and the option continues.
    9. After the installation is complete, the USB-HID-> COMM port (COM?) is displayed under the Port (COM and LPT) item ?).
Method 2: Use the installer. -;) Accessing the device
      • Use Windows APIs
        • Blocked read/write comtst. c
        • Detection event comevent. c
        • Appropriate timeout settings can be used to implement readfile return when data is available, and blocking when no data is available.
 
Commtimeouts. readintervaltimeout = 3; commtimeouts. Timeout = 0; commtimeouts. Timeout = 0; commtimeouts. Timeout = 0; commtimeouts. Timeout = 0; BRC = setcommtimeouts (hcomatrix, & commtimeouts );
      • MSComm control used in MFC
    1. Vc6.0 project menu ---> Add to project ---> components and controls ---> registered ActiveX controls, select components: Microsoft Communications Control to insert to the current workspace. The result adds the cmscomm class (and corresponding files: MSComm. h and MScomm. cpp ).
    2. ... See http://www.gjwtech.com/scomm/scmfcprogramfujie.htm

 

      • Access with USB hid Devices
    1. Open the device: bool bopenhiddevice (handle * hiddevhandle, ushort vid, ushort PID)
    2. Set the baud rate, parity, and stop bit:
 
Outbuffer [0] = 0;/* No report ID */* (unsigned int *) & outbuffer [1] = 19200; /* baud rate * // * configuration byte7 6543210reset0 parity typeparity enablestop bits0data bits */outbuffer [5] = 0x03;/* Data bit 8, no parity check, stop bit 1 */bresult = hidd_setfeature (hiddevhandle, outbuffer, capabilities. featurereportbytelength); If (bresult) {} elseprintf ("hidd_setfeature failed % d \ n", getlasterror ());
      1. Read/write data
    Outbuffer [0] = 0;/* No report ID */outbuffer [1] = 7;/* Data Length */For (INT I = 0; I <7; I ++) outbuffer [2 + I] = 'A' + I; bresult = writefile (hiddevhandle, & outbuffer [0], capabilities. outputreportbytelength, & numbytesreturned, null); inbuffer [0] = 0;/* No report ID */bresult = readfile (hiddevhandle, & inbuffer [0], capabilities. inputreportbytelength, & numbytesreturned, null); If (bresult) {// dump data printf ("Len = % d \ n", inbuffer [1]); for (INT I = 0; I <inbuffer [1]; I ++) printf ("% C", inbuffer [I + 2]);}
    How the driver works with todo. Use USB-HID-> com converter in Linux
        • Use USB to serial drive cypress_m8.ko (kernel> = 2.6)
      1. Insert the device. If the driver cannot be installed automatically, run modprobe cypress_m8.
      2. It can be like accessing a common serial port device (/dev/TTYs ?) In this way, access this device (/dev/ttyusb ?).
  • Use libusb
  • Testlibusb. c
        • Use hiddev
    Todo. Reference:
      • different ways of handling IRPs
      • proper completion -- resubmitting IRPs from within a completion routine
      • using the hid class eases the job of writing USB device drivers
      • http://www.lvr.com/hidpage.htm
      • http://www.gjwtech.com/serialcomm.htm

    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.