-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathkeypad_server.py
More file actions
38 lines (29 loc) · 829 Bytes
/
keypad_server.py
File metadata and controls
38 lines (29 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
File name: keypad_server.py
Author: Anton Karazeev <anton.karazeev@gmail.com>
This file is part of joystick project (https://github.com/akarazeevprojects/joystick)
"""
import socket
import sys
import time
import numpy as np
import utils
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Bind the socket to the port
server_address = ('192.168.0.3', 6665)
print('starting up on %s port %s' % server_address)
sock.bind(server_address)
# Listen for incoming connections
sock.listen(1)
connection, client_address = sock.accept()
s = utils.State()
presses = []
utils.find_pattern(s, presses)
while True:
data = connection.recv(16)
data = data.decode().split()
for x in data:
presses.append(int(x))
presses = utils.find_pattern(s, presses)
time.sleep(0.01)