use Serial() class with USB host port from USB host shield?

hello,
given I plug my Uno to a USB Host Shield https://store.arduino.cc/arduino-usb-host-shield:
is it possible to kind of redirect Serial() (write, read, available,...) to the shield's Host port, to be used by quite the same way for Serial communication like formerly the Uno's built-in USB client port?
(if not Serial.write() etc, then perhaps e.g., Serial4.write() or Serial10.write() etc).

If not possible out of the box, what has to be done so that the Serial() class can be used that way?

is it possible to kind of redirect Serial() (write, read, available,...) to the shield's Host port, to be used by quite the same way for Serial communication like formerly the Uno's built-in USB client port?

That depends on what you connect to the USB port it provides. To be able to use the HardwareSerial class (or at least a compatible interface) you must connect an USB to serial adapter to the port (p.e. FTDI, PL-2303, etc.). For the mentioned chips and for the ACM interface (which the UNO, Leonardo, Mega2560 and others use) the USB host shield library has support already, but that support doesn't emulate a hardware serial interface. With a bit of glue code you could easily achieve that.

If you use another chip as USB to serial adapter (the cheap CH340/341 come to mind) you have to develop a corresponding driver yourself.

yes, indeed I wanted to plug a USB-to-Serial converter to the USB port, and actually the one I have is a CH341.
I also have a Nano, a Mega and a Due, but at least for the UNO and perhaps the Mega it would be fine if I could make it work.
With my Raspi I am already successfully using this stick on it's USBs, connected then to a HC05 wireless board, I now want it to work also on my Arduino(s), just to plug, no extra wires.

If not the CH341, which different USB stick with integrated UART converter (FTDI ?) will work (out of the box) ?

If not the CH341, which different USB stick with integrated UART converter (FTDI ?) will work (out of the box) ?

As I wrote: FTDI and PL-2303 will work as well as the Arduino USB2Serial converter (which uses an ATmega16U2). BTW, these are not USB sticks, an USB stick is a storage device (in common nomenclature).

But, just out of curiosity, what are you trying to achieve? Such a setup doesn't make sense. You can get the same connectivity much easier and much cheaper. I get the impression that you design your project with over-complexity.

can you show me link to such a FTDI or PL-2303 with a USB plug?
The best choice would be if it also had integrated wireless functionality, like e.g. the HC05.

What I want:
I want wireless connections arbitarily and flexible between 2 Arduinos or 2 Raspis or 1 Raspi and 1 Arduino, just by using USB plugs and by using just the Serial() class on Arduino for Serial communication.

(On my Raspis it already works, using wiringPi/wiringSerial, and on my Arduinos it works by bare HC05 modules wired to the Arduino GPIOs, but here I also want to use USB in future.)

can you show me link to such a FTDI or PL-2303 with a USB plug?

http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm

The best choice would be if it also had integrated wireless functionality, like e.g. the HC05.

I don't think that such a product exists.

(On my Raspis it already works, using wiringPi/wiringSerial, and on my Arduinos it works by bare HC05 modules wired to the Arduino GPIOs, but here I also want to use USB in future.)

I see only drawbacks with the solution you're drafting. If I understood the sentence correctly you already have the better solution than the one you're trying to achieve, given that you get the USB hardware you'd need for it.

I have a working solution, yes, but too much wire salad over all, so I wanted a simple flexible USB thing/stick whatever, like for wireless keybord or WiFi, just to plug and play on either board.

but back to topic:
how would it work practically, if I want to address the Aduino USB Host shield port with a plugged-in USB-FTDI "stick" by commands like e.g.,

while (!Serial.available() );
...
for(uint8_t i=0; i<64; i++) {        
    Serial.read(buf[i]);
}
...
for(uint8_t i=0; i<64; i++) {        
    Serial.write(buf[i]);
}

how would it work practically, if I want to address the Aduino USB Host shield port with a plugged-in USB-FTDI "stick" by commands like e.g.,

That won't work, because Serial is already used for the hardware serial interface. Take a look at the FTDI class of the USB Host Shield library. You have methods for sending and receiving data and to change the serial parameters. But there is no glue code yet to adapt to the Stream interface for example (I guess that's what you're trying to do). So you would have to write that code. You might want use the code for the circular buffer from the HardwareSerial class.

as written in the opening post:

dsyleixa:
given I plug my Uno to a USB Host Shield https://store.arduino.cc/arduino-usb-host-shield:
is it possible to kind of redirect Serial() (write, read, available,...) to the shield's Host port, to be used by quite the same way for Serial communication like formerly the Uno's built-in USB client port?
(if not Serial.write() etc, then perhaps e.g., Serial4.write() or Serial10.write() etc).

If not possible out of the box, what has to be done so that the Serial() class can be used that way?

I need to use commands which work just like on the local Arduino programming port with Serial.yyy() , perhaps something like Serialxxx.yyy which does it analoguously, adequately, just to simply exchange my Serial() commands by their substitute command names.
Or just HardwareSerial.yyy() ? // yyy== available, read, write

So where is the exact code I need? I need actually something ready-to-use.

So where is the exact code I need?

You will have to write the code. Take a look at the examples for the FTDI controller. It looks nothing like hardware serial.

gdsports:
You will have to write the code. Take a look at the examples for the FTDI controller. It looks nothing like hardware serial.

USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino at master · felis/USB_Host_Shield_2.0 · GitHub

I'm afraid I can't do that.
I can include a Arduino lib and use provided example code e.g. for Serial.write/read, but I don't understand C++, just simple Arduinish and basic C99.
I actually expect the developers and vendors of that Aduino USB Host shield to provide ready working Serial libs. Without it, I never would buy one.

You could always ask the USB host shield developers at the github repo. The devs do not hang out at this site.

ok, I will do that, thank you!

Sorry for bringing back up this topic.

I was wondering if you ever figured out how to redirect those Serial commands to send out data using the Hosts port? All the other posts i've read about this topic seem to suggest that it is just not possible to send out data using this port, only reading data into the arduino using the usb host shield.