I am trying to interface a Samsung Galaxy tab A8 Android tablet with an embedded device. I can make the connection with a OTG style USB-C cable and can communicate with the embedded device using the "Serial USB Terminal" app that I downloaded from the Play Store. But I need to connect with a Python app that I installed on the tablet. I know the "Serial USB Terminal" app uses the virtual serial port to communicate with the embedded device. But in order to get my Python application to connect I need to know the name of the virtual serial port. I have used the same Python code to communicate with the embedded device using my PC, but on the PC the port is called "COM6". My Linux system calls it "/dev/ttysUSB1". I need to know what the tablet calls that communication port.
Here is the Python code:
import serial # Open the serial port ser = serial.Serial('COM6', 9600, timeout=1) while True: # Get user input user_input = input("Enter a string (or 'quit' to exit): ") if user_input == 'quit': break # Send the user input to the serial port ser.write(user_input.encode()) # Read the response from the serial port response = ser.readline().decode().strip() # Display the response print("Response:", response) # Close the serial port ser.close()
The only missing piece (since the code works flawlessly on my Windows PC version of python3) is that in the third line of code, the name, "COM6", is an unresolved reference. I have tried every variation I can think of for this port name, but it would be nice if it were documented somewhere.