Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ You may download the entire repository [using this link](https://github.com/jchu
- The ability to install some software
- Some light coding and the ability to run a Python script

### Required Python Packages
- jupyter
- matplotlib

### License

This software and associated materials are Copyright (c) 2016 by the Texas Advanced Computing Center, protected under the MIT License. [Full text of the license can be found here](./LICENSE.txt).
1 change: 0 additions & 1 deletion server/Logger/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from logger import *
18 changes: 9 additions & 9 deletions server/Logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Accelerometer server helper code

import SocketServer
import socketserver
import socket
import time
from threading import Thread, Lock
Expand Down Expand Up @@ -75,7 +75,7 @@ def udp_broadcast(data):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto(data, ('<broadcast>', PORT))
s.sendto(data.encode(), (b'<broadcast>', PORT))
s.close()

def send_configuration(ip):
Expand Down Expand Up @@ -110,7 +110,7 @@ def run(self):

# Check for timed out clients
client_lock.acquire()
for ip, client in clients.iteritems():
for ip, client in clients:
if time.time() - client.last_announce > CLIENT_TIMEOUT:
client.state = STATE_DISCONNECTED
client_lock.release()
Expand Down Expand Up @@ -146,7 +146,7 @@ def process_data(self, data):
update_status()

# UDP listener that responds to packets sent by clients
class AccelUDPHandler(SocketServer.BaseRequestHandler):
class AccelUDPHandler(socketserver.BaseRequestHandler):
def handle(self):
global clients

Expand Down Expand Up @@ -175,7 +175,7 @@ def handle(self):
clients[client_ip].process_data(packet[1:])

# Required mix-in class for threaded UDP server
class ThreadedUDPServer(SocketServer.ThreadingMixIn, SocketServer.UDPServer):
class ThreadedUDPServer(socketserver.ThreadingMixIn, socketserver.UDPServer):
pass

# Get a list of local interfaces and a good guess as to which interface to use
Expand All @@ -201,7 +201,7 @@ def update_status():
global sample_count_labels
global ms
milliseconds_label.value = str(ms)
for _, client in clients.iteritems():
for client in clients:
sample_count_labels[client.clientId].value = str(len(client.events))

# Formats a single client data event for fractions of Gs
Expand Down Expand Up @@ -251,11 +251,11 @@ def start():
accelThread.start()
print("Server is listening")
except Exception as e:
print e
print(e)

# Outputs a matplotlib preview of client data
def plot():
print "Plotting preview..."
print("Plotting preview...")
global clients
f, subplots = plt.subplots(len(clients), 3, sharex='col', sharey='row')
for i in range(len(clients.keys())):
Expand Down Expand Up @@ -332,7 +332,7 @@ def start_click(b):
col2_children = [ widgets.Label() ] * 3
col3_children = [ widgets.Label(value="Milliseconds", layout=widgets.Layout(width="100%")), widgets.Label(), widgets.Label(value="Status") ]
col4_children = [ milliseconds_label, widgets.Label(), widgets.Label("Samples")]
for _, accel in clients.iteritems():
for _, accel in clients:
col2_children.append(widgets.Label(value=accel.clientId))
status_labels[accel.clientId] = widgets.Label(
value=accel.state,
Expand Down
12 changes: 6 additions & 6 deletions server/server.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@
"outputs": [],
"source": [
"%matplotlib inline\n",
"import logger\n",
"from Logger import logger\n",
"logger.start()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down