3

I am trying to connect a CDC communication device to the Leonardo USB port and have communication with it via the TTL com port. Basically I want to echo to the TTL port whatever is transmitted over USB and vice-versa.

ASCII data is transmitted out the USB from the CDC device into the USB port of the Leonardo Aurduino. The Arduino needs to xtransfer this info over to the UART pins D0 (RX) and D1 (TX) that are connected to the UART of another micro-controller. I should be able to test it by connecting an FTDI TTL-RS232 cable and see results and have comms in my terminal program.

I came across this sketch that appears to be basically what I want, but I think the "hosting" portion is not being set up:

void setup() {
  Serial.begin(9600);  // rx/tx pins
  Serial1.begin(9600); // USB port
  Serial1.write("2nd Version");
}  

void loop() {
  // copy from virtual serial line to UART and vice-versa
  if (Serial.available()) {
    char c = (char)Serial.read();
    Serial1.write(c);
  }
  if (Serial1.available()) {
    char c = (char)Serial1.read();
    Serial.write(c);
  } 
}

What am I missing? Note I am NOT trying to do HID but CDC. Basically I want to eliminate using a PC as a Host device and use the "bridge" between my CDC device and another micro-controller.

  • Interesting. I do know nothing about CDC. Can you show us a schematic showing the connectiions? – user31481 Oct 20 '17 at 14:17
  • 1
    Nothing to it really....ASCII data is transmitted out the USB from CDC device into USB Port of the Leonardo Aurduino. The Aurduino needs to xtransfer this info over to the UART pins D0(RX) and D1(TX) that is connected to the UART of another microcontroller. I should be able to test it by connecting an FTDI ttl-RS232 cable and see results and have comms in my terminal program – AA9GG Oct 20 '17 at 14:54
2

No, the Leonardo cannot be a USB Host. You may be able to use a USB Host Shield in conjunction with the Leonardo, though I have never tried it and cannot vouch for compatibility with the Leonardo.

USB is a host->device protocol, not a peer-to-peer protocol. You cannot just connect two devices together. Only a USB Host can communicate with a USB device.

  • Not even with an OTG cable? – user31481 Oct 20 '17 at 16:18
  • 1
    No. The Leonardo cannot be a USB Host. – Majenko Oct 20 '17 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.