Contact Us

CATEGORIES

Whoops…Nothing found

Try other keywords in your search

Trigger API via Python over TCP

 0 Minutes

 2 Likes

 2036 Views

start_tcp.py

This is an example of how to remote control Pixera via Python calls via the API.
This example uses the Json/TCP(dl) setting that uses the delimiter 0xPX at the end of an API call.
This example uses the compound namespace. Please exchange the timeline name: "Abcd" to your real timeline name in the API call. Mode 1 = play

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #server ip and port server_address = ('127.0.0.1',1400) print('connecting to %s port %s' %server_address) #connect to server sock.connect(server_address) try:     #message     MESSAGE = b'{"jsonrpc":"2.0", "id":23, "method":"Pixera.Compound.setTransportModeOnTimeline", "params":{"timelineName":"Abcd","mode":1}}0xPX'     print("message: %s" % MESSAGE)     #send     sock.sendall(MESSAGE)     #look for the response     amount_received = 0     amount_expected = 1024     data = bytearray(0)     pixDL = bytearray('0xPX','utf-8')     while amount_received < amount_expected:         data += sock.recv(1)         amount_received += 1         if len(data) > 4:             if data[amount_received-4] == pixDL[0] and data[amount_received-3] == pixDL[1] and data[amount_received-2] == pixDL[2] and data[amount_received-1] == pixDL[3]:                 print('received %s' %data.decode('utf-8'))                 break         finally:     print('closing socket')     sock.close()


Was this article helpful?