I tested usb host serial on a T4.1 connected to a T3.6.
First, load this receiving program into the T3.6.
Code:
// Works on a T3.6 which receives CR/LF from the
// USB host port on a T4.1
// The LED blinks to indicate reception of
// the two characters
void setup(void)
{
Serial.begin(9600);
while(!Serial && (millis() < 5000));
pinMode(LED_BUILTIN,OUTPUT);
}
void loop(void)
{
if(Serial.available() >= 1) {
char c = Serial.read();
if(c == '\n') {
digitalWrite(LED_BUILTIN,1);
}
if(c == '\r') {
digitalWrite(LED_BUILTIN,0);
}
}
}
Then connect the T3.6 to the T4.1 host and load this sending code into the T4.1
Code:
// This works on a T4.1 sending CR/LF to a T3.6
// via the USB host port on the T4.1
// The LED blinks to indicate transmisison of
// the two characters
#include <USBHost_t36.h>
USBHost myusb;
USBSerial userial(myusb);
void setup(void)
{
delay(10000);
Serial.begin(9600);
myusb.begin();
pinMode(LED_BUILTIN, OUTPUT);
}
void loop(void)
{
myusb.Task();
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
userial.write('\r');
delay(200);
digitalWrite(LED_BUILTIN, HIGH);
userial.write('\n');
}
The T4.1 flashes its LED when CR/LF is sent and the T3.6 should flash its LED when it receives CR/LF.
Pete