Package: pyAutoPort
Quick StartpyAutoPort is a BASH/ZSH toolset for communicating with a Device Under Test (DUT) connected via UART and/or ADB. Embedded system engineers can use this toolset for automating tests.These commands can be executed directly from the terminal as system commands.InstallationInstall pyAutoPort-related commands using:pipinstallpyAutoPortRun this command INSIDE JUPYTER if you want to use this in a Jupyter notebook or Jupyter Lab.Set ConfigurationTo specify the UART port and baudrate or ADB Serial Number, define them in environment variables like this:Linux/MacOSexportTESTER_UART_PORT="/dev/ttyACM0"exportTESTER_UART_BAUDRATE=1250000exportTESTER_ADB_PORT=Serial_numberWindowssetTESTER_UART_PORT="COM0"setTESTER_UART_BAUDRATE=1250000setTESTER_ADB_PORT=Serial_numberadb devices -lcan getSerial_number. Defaultadb shellifTESTER_ADB_PORTnot been setted.Sending UART CommandsSend UART commands and receive replies with:uart_send${MESSAGE}For example, you should be able to see "connected" in the output after running:uart_send"echo connected"You don't need to send other commands to get output;uart_sendwill return the output.For additional information, refer to theBasic Modesection.Interacting with ADBWhileadb shell xxxis widely used to run shell commands from scripts without user interaction, direct interaction via the command-line interface (CLI) is necessary sometimes, especially when running an interactive app behind ADB.This package provides tools for keeping an ADB session open and interacting with it directly from a script without being trapped byadb shell.Open A Persistent ADB Sessionadb_open&Send Commands to ADB Sessionadb_sendsomecommandadb_sendanothercommandClose ADB Sessionsadb_closeThese commands simplify the process of sending and receiving data to and from your DUT using UART and ADB in various testing scenarios.For additional information, refer to theBasic Modesection.Interacting support TeraTerm-compatible commandsTeraTerm Mode Support TTL commands which can making automation scripting easier.TeraTerm Mode StartCreate a Session, Use connect command to configure the connection.In a Session, multiple different types of connections can be connected simultaneously without affecting each other.Linux/MacOSsession_start&Windowsstart/Bsession_startSend TTL commandsFollowing commands supportedconnectlogstartsenddisconnectFor additional information, refer to theTeraTerm Modesection.Session StopAt the end of the session, all connections will be disconnected and the log will be saved if necessary.session_stopBasic ModeBasic Mode provides commands integreated into Shell or Windows Command Propmt or PowerShell. Communication on UART and ADB are wrapped as command line commands.Basic usage of Basic Mode can be found inQuick Startsection. The following part focuses on additional information.UART CommunicationTheuart_sendcommand facilitates interaction with UART. Its usage is as follows:usage:uart_send[-h][-tTIMEOUT]text[text...]positionalarguments:textTexttobesentviaUART

options:-h,--helpDisplaythishelpmessageandexit-tTIMEOUT,--timeoutTIMEOUTTimetowaitbeforestoppingreadingWhen usinguart_send, it will continuously print text received from UART until there is no new text within a 0.5-second interval. To extend the duration before stopping, specify a new timeout value using-t TIMEOUT.IMPORTANT:If UART continues to print text, especially in scenarios with enabled debugging logs, you may need to pressCtrl-Cto stop forcefully.ADB CommunicationUnlike UART, interacting with ADB involves a three-step process: opening an ADB session, interacting within the session, and finally closing the ADB session.To initiate an ADB session, use the commandsadb_openoradb_reopen. If a previous session was not closed safely, it's recommended to useadb_reopenfor recovery.IMPORTANT:Runadb_open&to open the session in the background. Otherwise, usingadb_openalone will block further command execution since it is a blocking command call.For interaction with ADB, employ theadb_sendcommand with the following usage:usage:adb_send[-h][-tTIMEOUT]text[text...]positionalarguments:textTexttosendviaADB

options:-h,--helpshowthishelpmessageandexit-tTIMEOUT,--timeoutTIMEOUTTimetowaitbeforestoppingreadingTheadb_sendcommand will continuously print text received from ADB until no new text is received within a 1-second timeframe. To extend the timeout duration before stopping, use the-t TIMEOUToption.IMPORTANT:In situations where ADB keeps printing text, such as when running logcat, you may need to pressCtrl-Cto stop forcefully.TeraTerm ModeTeraTerm Mode Support TTL commands on Linux or Windows CLI via adb or uart.connectStart one connection or switch other connection.
If switch other connection, the existed connection will not be disconnected.connect[uart|adb]Example:connectadb->ADBconnectioncreate
sendxxx->sendxxxviaADB
connectuart->UARTconnectioncreateandswitchUART
sendxxx->sendxxxviaUART
connectadb->switchADB
sendxxx->sendxxxviaADBlogstartStart to Saving Received Messages to specified file.
This command must be used after one connection has been already created.logstart<filename>Add TimeStamp in logset_timestamp
logstart<filename>sendSend commands via current connection.
Received Messages will be printed on CLI.send<date1><date2>...disconnectStop specified connection.disconnect[uart|adb]Some commands will be supported in the future.How to ContributeSeecontributing guidelinesfor details.commit guidelinesmay also be helpful.LICENSEThis project is under BSD-3 license.CreditsWe express our gratitude to all contributors for their valuable contributions to pyAutoPort!MaintainersYu GUYu.Gu@sony.com(Basice Mode)Shuang LIANGShuang.Liang@sony.com(TeraTerm Mode)ContributorsHappy coding!