serial communication between two teensies via usb

Status
Not open for further replies.

lokki

Well-known member
i have the following setup:

-a teensy 3.6 with a 7 port usb hub
-a teensy 4 (configured as midi + serial) connected to said hub
-several usb-midi devices connected to said hub

i have it almost all working! all synth-midi communication is working great! the teensy 4 should communicate bidirectional via midi, but whenever i try to send midi to the teensy 4, the teensy 3.6 gets really laggy. i already made another forum thread about problems with the teensy 4 and 3.6: https://forum.pjrc.com/threads/64363-force-small-rx-tx-buffer-for-usbmidi-teensy-4 receiving midi from the teensy 4 works just as expected.

since i need this setup for a few rehearsals and small gigs in about a week i want to explore other possibilities instead of the non working midi.
it should be possible to send serial data over usb to the teensy 4, but i am struggling to get it working.

how do i have to setup my hub ports on the teensy 3.6 so that it can find and recognise the teensy 4 which is configured as "serial + midi"?

i have:

Code:
#include <USBHost_t36.h>

// Create the ports for USB devices plugged into Teensy's 2nd USB port (via hubs)
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
USBHub hub3(myusb);
USBHub hub4(myusb);
USBSerial userial(myusb);
MIDIDevice_BigBuffer midi01(myusb);
MIDIDevice_BigBuffer midi02(myusb);
MIDIDevice_BigBuffer midi03(myusb);
MIDIDevice_BigBuffer midi04(myusb);
MIDIDevice_BigBuffer midi05(myusb);
MIDIDevice_BigBuffer midi06(myusb);
MIDIDevice_BigBuffer midi07(myusb);
MIDIDevice_BigBuffer * midilist[07] = {
  &midi01, &midi02, &midi03, &midi04, &midi05, &midi06, &midi07
};

but calling:
Code:
Serial.println((char*)userial.serialNumber());
in setup, does not print anything to the serial monitor of teensy 3.6,

so i guess the teensy4 is not found on the hub. the midi part of the teensy4 is found when i scan all seven midi ports i created.

probably i am doing something simple wrong...thanks for any insights.
 
Last edited:
You need to use the usb-host feature on one of both to get that working.
Probably more easy is to use one of the hardware serial ports on both.
Preferable Serial1 (larger FIFO)
 
thanks, i am aware of that.
i have the hub nicely working on the teensy 3.6, all my synths and the teensy4 are connected to it. look at the code snippets above, they contain the hub portion and the midi ports.
this is all working nicely except for midi communication from teensy 3.6 to teensy4. that is why i want to use serial for that.

hardware serial is unfortunately not possible, since this is a musical instrument type of controller that has only one usb cable as connection to the floor (where it connects to the 7 port hub) hence i am bound to usb communication.
 
no problem! any other insights? should the above code be working i.e. should a serialnr. be printed to the teensy 3.6 console? do i need to set anything special on the teensy4 side?
 
i may have found the problem... teensy4 needs the
Code:
USBSerial_BigBuffer userial(myusb);
for serial communication as well, at least that is indicated on Github in the usbhost examples. my version of teensyduino does not yet know about that BigBuffer version, so will try to update...
 
Glad the updated code was found - I saw KurtE on the other thread - but no mention of using the current Beta5 of TD1.54 if the code has been included? I hoped to have tested this after KurtE did the updates - but have been distracted. Glad he had a working sample included for reference.
 
yes! i can confirm my teensy4 is now found with the BigBuffer in place. i just replaced the USBHost library in my 1.53 install with the GitHub version. I can also confirm that serial communication does not slow down my teensy 3.6 when sent to teensy4, unlike midi communication. i placed an example patch-set in the other thread (https://forum.pjrc.com/threads/64363-force-small-rx-tx-buffer-for-usbmidi-teensy-4) to show the problem. it would be great if that could be fixed...
 
Status
Not open for further replies.
Back
Top