我正在尝试使用openocd向设备发送多个命令。问题是它收到我的第一个命令,然后停止。它永远不会收到下一个。
import socket
class App(object):
def connect(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print('connecting to host')
sock.connect(('localhost',4444))
return sock
def send(self, command):
sock = self.connect()
recv_data = ""
data = True
print('sending: ' + command)
sock.sendall(command)
while data:
data = sock.recv(1024)
recv_data += data
print('received: ' + data)
sock.close()
return recv_data
def main():
test = App()
print test.send("targets")
print test.send("reset")
if __name__=='__main__':
main()