I have compiled a windows executable that connects to a software radio and reads out the values in its registers. When I execute this in command prompt, it returns me the following output
My hardware is connected via USB to COM4, when I pass these as arguments, I get the following screen where I can choose between ranging to other radios with their ID's (100 is the Host Radio. 101, 102 103 and 104 are other radios) or can quit the application by typing 'q'.
If I input the ID of the radio to be ranged, I get the ranging information and this process continues until i quit by typing 'q'
Now, Im trying to write a python script where I can call this executable, get the values and store them for further processing. I have read in other topics that this can be achieved by the library 'subprocess'. My code snippet as follows
#!/usr/bin/env python
import subprocess
import time
#subprocess.Popen([r"C:\Users\Raja\Documents\SUMO_Final\rcmSampleApp.exe"])
p = subprocess.Popen("C:/Users/Raja/Documents/SUMO_Final/rcmSampleApp.exe -u COM4", shell = True, stdin = subprocess.PIPE)
p.stdin.write('104')
time.sleep(5)
p.stdin.write('q')
p.kill()
When I execute this in .py file, the .exe loops indefintely as shown below
Some answers in the forum suggest changing shell = False and terminate the process before killing it but it is not clear for me. Can someone please help?
Cheers