Apr-11-2022, 12:47 PM
I have an application that execute AT commands on certain device via USB.
First I have to open Terminal, run the application via command line then start to execute AT commands.
my first trial
I also tried :
First I have to open Terminal, run the application via command line then start to execute AT commands.
Output:> connectDev (then I press enter)
Type in your commands:
at+XYZ=? (I start to execute my AT commands)
I tried to write some script with python using subporcess module but it didn't workmy first trial
import subprocess p1 = subprocess.run(['connectDev'], capture_output=True, text=True) #print(p1.stdout) p2 = subprocess.run(['AT+XYZ'], capture_output=True, text=True) print(p2.stdout)the script was waiting for the application to finish but it keep waiting.
I also tried :
import subprocess results = subprocess.Popen(['connectDev'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) results.poll() stdout,stderr = results.communicate() print(stdout)is there anyway that I can run the AT commands using Python after I exeucte the application(connectDev) ?