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?
Best Regards
Martin
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