Hi. I'm a beginner for Arduino and may not able to describe all the details of my questions. But I will try to include more details.
I have the device, it has an USB port and can be controlled by PC via serial communication. I used methods from serial library and setup the port, baudrate, bytesize and other parameter in a python code, and then it worked.
And now I want to use Arduino giga R1 to control this device. I searched a little bit and learned that there is a library called "USBHostSerial.h" that may contain the functions or class that could help.
This library was included in Arduino_USBHostMbed5.h and I put the following in my arduino code:
USBHostSerial USB_A_serial;
bool initialize_connection() {
//enable the USB-A port
pinMode(PA_15, OUTPUT);
digitalWrite(PA_15, HIGH);
if (USB_A_serial.connect()) {
USB_A_serial.baud(115600);
USB_A_serial.format(8, USBHostSerialPort::None, 1);
return true;
} else {
Serial.println("Failed to connect device.");
return false;
}
}
I linked this function to a button and connect the device to the USB-A port ,and I always receive "failed to connect to device" in the serial monitor after I clicked the button.
pinMode(PA_15, OUTPUT);
digitalWrite(PA_15, HIGH);
These two lines were copied from the examples, which allow me read files from a usb drive connected to USB-A port.
In the tutorials they mentioned that "To enable the USB-A port, you will need to define it as an output. You can also disable it inside of a sketch by writing a LOW state to it." Not sure if they are needed here, but I include them in my code.
(https://docs.arduino.cc/tutorials/giga-r1-wifi/giga-usb/)
Did I missed some something to enable the USB-A port for serial communication or setup the connection with the device? Or did I used wrong library for this?
My description could be confusion since I'm not sure about some terms in embeded systems development, please feel free to ask for more information .
Thank You in Advance