0

I am trying to send multiple commands to a device using openocd. The problem is it receives my first command and then stops. It never receives the next one.

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()
homeGrown
  • 375
  • 1
  • 8
  • 25
  • Does the device reply? Are you sure your commands are correct (EOL)? Have you tested with a server script [that others could use to reproduce the error]? – handle Aug 04 '16 at 14:15
  • Yes first command is received and does its job. Second one doesnt. If i just send these command using commandline tool nc it works fine – homeGrown Aug 04 '16 at 14:18
  • So your script does things differently, somehow. As I wrote, check the EOL. Or have a look with wireshark. Or your receiving part has a problem (timing?). We don't have your server to test with. Log your socket data as binary and compare? Also you're not specific in where your code "stops". – handle Aug 04 '16 at 14:25

0 Answers0