I can't communicate using USB serial

Example: when I plug my nodeMCU ESP-12E with this code or other USB serial devices I can’t communicate even with /dev/ttyUSB0 open. (Google translator)

sudo screen /dev/ttyUSB0 115200
sudo gtkterm -p /dev/ttyUSB0 -s 115200

#include <Arduino.h>

#define LED_PIN 2

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN,OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    char data = Serial.read();
    
    if(data=='0' || data=='1'){
      Serial.printf("Data: %d\r\n", data-'0');
      digitalWrite(LED_PIN,!(data-'0'));
    }
  }
}
[ 4119.374661] usb 1-2.1.2: new full-speed USB device number 9 using tegra-xusb
[ 4119.395922] usb 1-2.1.2: New USB device found, idVendor=1a86, idProduct=7523
[ 4119.395927] usb 1-2.1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4119.395931] usb 1-2.1.2: Product: USB2.0-Ser!
[ 4119.397730] ch341 1-2.1.2:1.0: ch341-uart converter detected
[ 4119.399323] usb 1-2.1.2: ch341-uart converter now attached to ttyUSB0

i tried to re-compile the usb modules and it continued with the same problem
a-guide-to-solve-usb-serial-driver-problems-on-tx2/60787

To get around this problem I’m using jetson’s GPIO, but I’ll have to connect other devices

import sys
import socket
import RPi.GPIO as GPIO

try:
    server_ip = sys.argv[1]
except IndexError:
    server_ip = "0.0.0.0"

try:
    server_port = sys.argv[2]
except IndexError:
    server_port = 9999

output_pin = 18

server_address = (server_ip, server_port)
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)


def main():
    print("Uso: {0} <server_ip> <server_port>".format(sys.argv[0]))
    print("{0} {1} {2}".format(sys.argv[0], server_ip, server_port))

    server_socket.bind(server_address)
    server_socket.settimeout(0.1)

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.LOW)

    try:
        while True:
            try:
                msg = server_socket.recv(1)
                if msg == b"1":
                    GPIO.output(output_pin, GPIO.HIGH)
                elif msg == b"0":
                    GPIO.output(output_pin, GPIO.LOW)
            except socket.timeout:
                pass
    finally:
        GPIO.cleanup()
        server_socket.close()


if __name__ == '__main__':
    main()
#include <Arduino.h>

#define LED_PIN 2
#define INPUT_PIN 4
#define OUTPUT_PIN 5

int  state = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_PIN,OUTPUT);
  pinMode(INPUT_PIN,INPUT);
  pinMode(OUTPUT_PIN,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  state = digitalRead(INPUT_PIN);
  digitalWrite(LED_PIN,!state);
  digitalWrite(OUTPUT_PIN,state);
  delay(300);
}

do you think it could be the power supply?

https://forums.developer.nvidia.com/t/jetson-nano-cannot-serial-communication-with-arduino-when-when-they-use-the-same-power-source/195518

No USB module rebuild should be required. So far as the USB side goes, this part is guaranteed to be working:

[ 4119.374661] usb 1-2.1.2: new full-speed USB device number 9 using tegra-xusb
[ 4119.395922] usb 1-2.1.2: New USB device found, idVendor=1a86, idProduct=7523
[ 4119.395927] usb 1-2.1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4119.395931] usb 1-2.1.2: Product: USB2.0-Ser!

Next, you know the driver is working via this (USB announced the device and the driver which can work with it not only attached, it generated the device special file):

[ 4119.397730] ch341 1-2.1.2:1.0: ch341-uart converter detected
[ 4119.399323] usb 1-2.1.2: ch341-uart converter now attached to ttyUSB0

If you have changed USB, then probably you should either reflash or revert those changes. I am not a Python guy, but problems at this point are probably with the software. As something to test, is there a particular command you can send to the Arduino which would simply echo back what you sent? Loopback modes (such as echo back) are quite useful for this. Any text you could send which has a known expected response would help. The goal would be to take that content and bypass the Python program and simply use a terminal emulator. The output as a reply would be visible to see if the UART itself is working as expected.

I already reinstalled the system, even with the SDK manager, but I have the same problem of not being able to send or receive information, the drive really seems to be working, but without transmitting the data.

On my computer it works, but when i test on jetson it doesn’t

I don’t have one of these to test with, but does the communication use pins on the nodeMCU ESP-12E? Or does it use USB directly? If it uses pins, do you have an oscilloscope? I suggest this because it is easy to tell if communications exist even if the nodeMCU ESP-12E does not reply as expected.

As far as power goes, sometimes it is correct that external devices receiving power from the Jetson might fail. Power supplies have to be well regulated, and additionally, if the Jetson itself is powered over USB, then there might not be enough power for the Jetson’s own USB to power another USB device. External power to the nodeMCU ESP-12E would be best, but if the unit is not shutting down, then probably power is ok. It would be worth describing how power is supplied to both the Jetson and the nodeMCU ESP-12E.

Provided that this setup works on another Linux system I am thinking that the issue is probably with the software itself. For example, perhaps a different version of Python is used on the desktop PC compared to the Jetson. It is hard to check that out though before verifying the above hardware questions.

The nodeMCU ESP-12E is one of the examples that is not working in jetson, but I got around it using GPIO, it was ugly.

None of the usb seial devices I plugged into the jetson transmitted data

I tested using external power and it didn’t work either.

what I’m testing would be to send 0 or 1 via serial using python (pyserial), gtkterm, screen or minicom

i can test it on arduino uno too, then i’ll tell you if it worked.

The Arduino works

#include <Arduino.h>

#define LED_PIN 13

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN,OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    char data = Serial.read();
    
    if(data=='0' || data=='1'){
      Serial.print("Data: ");
      Serial.print(data-'0');
      Serial.print("\r\n");
      digitalWrite(LED_PIN,data-'0');
    }
  }
}

I am interested in knowing if this is correct:

  • One end of the cable is a regular USB connector. This is plugged into the Jetson.
  • The other end has individual wires you can access.

If the above is correct, then it is easy to use loopback to test and debug. Are there individual wires exposed at the Arduino side?