PaulStoffregen / USBHost_t36

USB Host Library for Teensy 3.6 and 4.0
165 stars 85 forks source link

USBSerial support for setting DTR/CTS #68

Closed KurtE closed 3 years ago

KurtE commented 3 years ago

As per the forum Thread: https://forum.pjrc.com/threads/67677-Kurt-USB_HOST-(T4-1)-Serial-hardware-handshake

Frank wanted the ability to write a pass through sketch that would allow him to program either an Arduino UNO or an ESP32 that was plugged into the USBHost.

Adding support for this helped to uncover a few other issues with the code, like turned out there was/is an long standing bug with the read code that it was reading the wrong byte from the queue. He has another PR that addressed this.

This PR has both that fix as well as fixing Peek.

To support the reprogramming, needed to add support for allowing the host code to control both the DTR and the RTS signals. Likewise it is needed to allow the code to change the baud rates. This part uncovered an issue with the CP2102 code that would hang when end was called. The end was called before we would then call begin again with a different baud rate.

So far with my version of the T4.1 sketch code, I am able to fully reprogram an arduino UNO. At least the newer ones. Likewise was able to reprogram a Mega 1280

Likewise I can now reporgram an ESP32 as well as an ESP8266. However so far the board after reprogramming does not successfully reboot. You need to turn it off an on and then it runs the new program.

So far no luck with Arduino Leonardo or Due. Will try more later.

KurtE commented 3 years ago

@PaulStoffregen - I see you merged in @FrankBoesing change here... Which this one also includes. I know that he did some testing of this as well as @mjs513

There will probably be other tweaks needed to support additional boards.

Wonder if one of these sketches should be added as an example sketch?

PaulStoffregen commented 3 years ago

More examples would be good. Simpler examples too. Will probably make "Serial" a folder, when we have more than 1 example, and rename the 1 we have (which honestly, is a bit too complex to be a good example for most people...)

FrankBoesing commented 3 years ago

Agreed, the existing example is way too complex. Needs to be more "Hello World" like.

FrankBoesing commented 3 years ago

btw,  some time ago i tried to run some of the SDFat examples - nothing worked "out of the box".

PaulStoffregen commented 3 years ago

Yes, the SdFat examples are on a long list of stuff to fix. Most of the issue is with "File". Was going to reach out to Bill after I wrap up the encryption stuff (which got put on hold to wrap up 1.54).

FrankBoesing commented 3 years ago

I could write a simple "PingPong" that demonstrates COmmunication and Programming a UNO without unplugging,

But for "Hello world" even that is a bit soo much... perhaps OK for a blog article (which I would not write..)