Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Reading from one usb port and emulating a usb touch on another

Hybrid View

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    10

    Reading from one usb port and emulating a usb touch on another

    Hey!
    Have a usb device that after reciving a few arrays of bytes will start to send raw data about touch information.
    What I want to achive is to first write to that usb device then continously reading from it and analyzing the data to create touch data send to the other usb device, this case a computer.

    The problem I have is understanding how to do this. Tried creating a USB Host application that writes to a USBSerial and then reads but I can't seem to start the USB Serial driver.

    Here is the example code I have now. I can't get it to start sending data to the device and then reading it.
    Where do I start? Have I missunderstod some concept on how this actually works?
    Code:
    #include "USBHost_t36.h"
    
    USBHost myusb;
    USBHub hub1(myusb);
    USBHub hub2(myusb);
    USBHub hub3(myusb);
    USBSerial userial(myusb);
    const int ledPin = 13;
    
    void setup()
    {
      while (!Serial) ; // wait for Arduino Serial Monitor
    	Serial.println("USB Host Testing");
    	myusb.begin();
      Serial.println("Usb Host started");
      //This never happends
      userial.begin(416000);
      Serial.println("Usb Seriel started");
      pinMode(ledPin, OUTPUT);
      byte init_1[] = {0x79, 0xf0, 0x15, 0x06, 0x00, 0x09, 0xd8, 0x25, 0x46, 0x8e};
      byte init_2[] = {0x79, 0xf0, 0x19, 0x05, 0xfe, 0x38, 0xfb, 0x7e, 0x40};
      byte init_3[] = {0x79, 0xf0, 0x15, 0x06, 0x00, 0x09, 0xd8, 0x25, 0x46, 0x8e};
      byte init_4[] = {0x79, 0xf0, 0x1a, 0x05, 0x01, 0xde, 0x03, 0x46, 0x83};
    
      userial.write(init_1,10);
      userial.write(init_2,9);
      userial.write(init_3,10);
      userial.write(init_4,9);
    
      Serial.println("Started.");
      digitalWrite(ledPin, HIGH);
      delay(3000);
      digitalWrite(ledPin, LOW);
    }
    
    
    void loop()
    {
      int incomingByte;
      myusb.Task();
      if (userial.available() > 0) {
        incomingByte = userial.read();
        Serial.print("USB received: ");
        Serial.println(incomingByte, DEC);
      }
     
    }
    Best Regards
    Martin

  2. #2
    Junior Member
    Join Date
    Oct 2020
    Posts
    10
    Here is the device information using
    lsusb -v -d
    I'm trying to send and read data from:
    Code:
    Bus 001 Device 007: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
    Couldn't open device, some information will be missing
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.00
      bDeviceClass            0 (Defined at Interface level)
      bDeviceSubClass         0 
      bDeviceProtocol         0 
      bMaxPacketSize0        64
      idVendor           0x0403 Future Technology Devices International, Ltd
      idProduct          0x6010 FT2232C Dual USB-UART/FIFO IC
      bcdDevice            7.00
      iManufacturer           1 
      iProduct                2 
      iSerial                 0 
      bNumConfigurations      1
      Configuration Descriptor:
        bLength                 9
        bDescriptorType         2
        wTotalLength           55
        bNumInterfaces          2
        bConfigurationValue     1
        iConfiguration          0 
        bmAttributes         0x80
          (Bus Powered)
        MaxPower              500mA
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        0
          bAlternateSetting       0
          bNumEndpoints           2
          bInterfaceClass       255 Vendor Specific Class
          bInterfaceSubClass    255 Vendor Specific Subclass
          bInterfaceProtocol    255 Vendor Specific Protocol
          iInterface              2 
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x81  EP 1 IN
            bmAttributes            2
              Transfer Type            Bulk
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0200  1x 512 bytes
            bInterval               0
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x02  EP 2 OUT
            bmAttributes            2
              Transfer Type            Bulk
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0200  1x 512 bytes
            bInterval               0
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        1
          bAlternateSetting       0
          bNumEndpoints           2
          bInterfaceClass       255 Vendor Specific Class
          bInterfaceSubClass    255 Vendor Specific Subclass
          bInterfaceProtocol    255 Vendor Specific Protocol
          iInterface              2 
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x83  EP 3 IN
            bmAttributes            2
              Transfer Type            Bulk
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0200  1x 512 bytes
            bInterval               0
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x04  EP 4 OUT
            bmAttributes            2
              Transfer Type            Bulk
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0200  1x 512 bytes
            bInterval               0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •