Here is my code:
class TestRegisters():
def application(self):
return(Popen(["i2c_control.exe"], shell=True, bufsize=0, stdout=PIPE, stdin=PIPE, stderr=PIPE, universal_newlines=True))
def run_read_command(self, address, size):
cmd = "read %s %s" % (address, size)
out = self.application().communicate(cmd)[0]
print('output is: {}\n'. format(out))
# print('error is: \n', err)
return(out)
test = TestRegisters()
for key in register:
address = key
size = int(register[key][1])*4
access = register[key][0]
data_type = register[key][2]
if access == 'Read' or access == 'Read/Write':
test.application()
read = test.run_read_command(address, size)
It prints the output correctly in terminal if I don't PIPE stdout, but when I PIPE stdout, communicate[0] prints empty output as following:
output is:
output is:
output is:
output is:
Not sure what am I doing wrong. Any help is appreciated, thanks.