Skip to content

Commit

Permalink
I worked on th enameserver
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Wallar committed Sep 16, 2015
1 parent 48124d9 commit e26b1f2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/jammi/heart.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, host, port, rate):
self.port = port
self.rate = rate
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.data = {}
self.data = dict()
self.running = False

def set_data(self, data):
Expand Down
12 changes: 10 additions & 2 deletions src/jammi/nameserver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@


class NameServer(object):

def __init__(self):
pass
def __init__(self, host, port, interval):
self.host = host
self.port = port
self.interval = interval
self.names = dict()

def start():
def __thread():
pass
9 changes: 7 additions & 2 deletions tests/heart_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
import socket
import rospy
import zlib
import json


def test_start():
"""
Tests that the heart class is able to start and send messages over UDP
"""

rospy.init_node("jammi_test", anonymous=False)
host, port = "localhost", 5005
rate = 20
Expand All @@ -21,11 +26,11 @@ def test_start():
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((host, port))
i = 0
while i < 20:
while i < 5:
i += 1
data_zip, addr = sock.recvfrom(1024)
data = zlib.decompress(data_zip)
print i, data, addr
assert(json.loads(data) == heart.data)
heart.kill()


Expand Down

0 comments on commit e26b1f2

Please sign in to comment.