Created
August 3, 2019 11:13
-
-
Save tjvr/9e1e63cbdb6182405c12b62dec705882 to your computer and use it in GitHub Desktop.
Kramer Protocol 2000 for VS-66HN (and probably other HDMI switchers too)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import struct | |
import sys | |
HOST = "192.168.1.39" | |
PORT = 5000 | |
def switch(input_port): | |
msg = 0x01808081 | (input_port << 16) | |
raw = struct.pack('!I', msg) | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect((HOST, PORT)) | |
sock.send(raw) | |
print 'Sent %s to tcp://%s:%s' %(repr(raw), HOST, PORT) | |
data = sock.recv(1024) | |
sock.close() | |
expect = 0x41808081 | (input_port << 16) | |
got = struct.unpack('!I', data) | |
if got != expect: | |
sys.stderr.write("oh no") | |
return 1 | |
return 0 | |
def main(arguments): | |
if len(arguments) != 2: | |
sys.stderr.write("usage: ./switch.py 2") | |
return 1 | |
try: | |
input_port = int(arguments[1]) | |
except ValueError: | |
sys.stderr.write("not a number: {}".format(arguments[1])) | |
return 1 | |
return switch(input_port) | |
if __name__ == '__main__': | |
sys.exit(main(sys.argv)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment