2020-06-02 18:10:07 -05:00
|
|
|
#!/usr/bin/python
|
|
|
|
import socket
|
|
|
|
import threading
|
2020-06-03 12:18:51 -05:00
|
|
|
import pyxinput
|
2020-06-02 22:11:32 -05:00
|
|
|
from time import sleep
|
2020-06-03 01:07:28 -05:00
|
|
|
import pickle
|
2020-06-02 18:10:07 -05:00
|
|
|
# Define server ip and port
|
2020-06-02 22:11:32 -05:00
|
|
|
ip = '192.168.122.1'
|
2020-06-02 18:10:07 -05:00
|
|
|
port = 2222
|
2020-06-03 12:18:51 -05:00
|
|
|
# Create virtual controller
|
|
|
|
MyVirtual = pyxinput.vController()
|
|
|
|
# Connect to Server
|
2020-06-03 23:45:10 -05:00
|
|
|
conn = socket.create_connection((ip, port))
|
|
|
|
from_server = conn.makefile(mode='rb')
|
2020-06-03 16:28:03 -05:00
|
|
|
#Decode Sever message
|
2020-06-03 23:45:10 -05:00
|
|
|
#unpickler = pickle.Unpickler(file)
|
2020-06-03 12:18:51 -05:00
|
|
|
while True:
|
2020-06-03 23:45:10 -05:00
|
|
|
#decodedServerData = unpickler.load()
|
|
|
|
decodedServerData = pickle.load(from_server)
|
|
|
|
#print("Raw Data:", from_server)
|
|
|
|
#print("Unpicked Data: ", decodedServerData)
|
|
|
|
# pyxinput will only accept values one at a time, so we need to apply the items in the dictionary one by one
|
2020-06-03 12:18:51 -05:00
|
|
|
for event, state in decodedServerData.items():
|
|
|
|
MyVirtual.set_value(event, state)
|
2020-06-03 23:45:10 -05:00
|
|
|
#print('\''+event+'\''+',', state)
|