Skip to content

Commit

Permalink
column_num int to str cast
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdev2 committed Jun 8, 2020
1 parent 9a58d65 commit 479cded
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 2 deletions.
7 changes: 6 additions & 1 deletion floor_flasher/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@

@parallel
def r():
with cd('~/sensorfloor'):
run('git config --global user.email "aswinkarthik.ramachandran@tu-dortmund.de"')
run('git config --global user.name "akrv"')

run('sudo timedatectl set-timezone Europe/Berlin')
run('git stash')
run('git pull')
# run('ntpstat')


@parallel
Expand Down
2 changes: 1 addition & 1 deletion imu_reader/read_past_imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def reader_worker(strip_id, strip_path_inorder, node_list, serial_handler, mqtt_

# construct topic for publishing
mqtt_publish_topic = 'imu_reader' + "/" + strip_id[0] + "/" + node_id
mqtt_publish_topic1 = 'imu_reader' + "/" + strip_id[1] + "/" + node_id
mqtt_publish_topic1 = 'imu_reader' + "/" + str(strip_id[1]) + "/" + node_id

switching_start_time = time()
# set all devices PIO 6 and 7 RX and TX off.
Expand Down
11 changes: 11 additions & 0 deletions summerschool-api/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask

app = Flask(__name__)

@app.route('/cur')
def hello_world():
"""Print 'Hello, world!' as the response body."""
return 'Hello, world!'

# running the server
app.run(debug = True) # to allow for debugging and auto-reload
57 changes: 57 additions & 0 deletions summerschool-api/redis-pusher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import paho.mqtt.client as mqtt
import redis, json


RPi_IPs = [
{"column_num": 1, "ip_addr": "129.217.152.74", "mac_id": "b8:27:eb:41:99:a0", "hostname": "raspberrypi"},
{"column_num": 2, "ip_addr": "129.217.152.111", "mac_id": "b8:27:eb:c0:fd:6a", "hostname": "raspberrypi"},
{"column_num": 3, "ip_addr": "129.217.152.79", "mac_id": "b8:27:eb:18:92:c7", "hostname": "raspberrypi"},
{"column_num": 4, "ip_addr": "129.217.152.54", "mac_id": "b8:27:eb:53:f2:33", "hostname": "raspberrypi"},
{"column_num": 5, "ip_addr": "129.217.152.86", "mac_id": "b8:27:eb:e7:6f:dc", "hostname": "raspberrypi"},
# {"column_num": 6, "ip_addr": "129.217.152.110", "mac_id": "b8:27:eb:9b:69:9a", "hostname": "raspberrypi"},
{"column_num": 6, "ip_addr": "129.217.152.89", "mac_id": "b8:27:eb:38:4b:07", "hostname": "raspberrypi"},
{"column_num": 7, "ip_addr": "129.217.152.84", "mac_id": "b8:27:eb:1b:cf:26", "hostname": "raspberrypi"},
{"column_num": 8, "ip_addr": "129.217.152.119", "mac_id": "b8:27:eb:6d:0e:53", "hostname": "raspberrypi"},
{"column_num": 9, "ip_addr": "129.217.152.77", "mac_id": "b8:27:eb:b7:a3:b7", "hostname": "raspberrypi"},
{"column_num": 10, "ip_addr": "129.217.152.118", "mac_id": "b8:27:eb:be:dc:32", "hostname": "raspberrypi"},
{"column_num": 11, "ip_addr": "129.217.152.69", "mac_id": "b8:27:eb:ff:a4:48", "hostname": "raspberrypi"},
{"column_num": 12, "ip_addr": "129.217.152.59", "mac_id": "b8:27:eb:a9:7d:4d", "hostname": "raspberrypi"},
{"column_num": 13, "ip_addr": "129.217.152.85", "mac_id": "b8:27:eb:c4:f8:c7", "hostname": "raspberrypi"},
{"column_num": 14, "ip_addr": "129.217.152.48", "mac_id": "b8:27:eb:e4:43:6d", "hostname": "raspberrypi"},
{"column_num": 15, "ip_addr": "129.217.152.63", "mac_id": "b8:27:eb:98:69:6e", "hostname": "raspberrypi"},
{"column_num": 16, "ip_addr": "129.217.152.50", "mac_id": "b8:27:eb:75:c7:a2", "hostname": "raspberrypi"},
{"column_num": 17, "ip_addr": "129.217.152.37", "mac_id": "b8:27:eb:09:3d:77", "hostname": "raspberrypi"},
{"column_num": 18, "ip_addr": "129.217.152.60", "mac_id": "b8:27:eb:05:d8:4d", "hostname": "raspberrypi"},
{"column_num": 19, "ip_addr": "129.217.152.64", "mac_id": "b8:27:eb:36:da:22", "hostname": "raspberrypi"},
{"column_num": 20, "ip_addr": "129.217.152.62", "mac_id": "b8:27:eb:f5:5d:04", "hostname": "raspberrypi"},
{"column_num": 21, "ip_addr": "129.217.152.51", "mac_id": "b8:27:eb:88:8d:56", "hostname": "raspberrypi"},
{"column_num": 22, "ip_addr": "129.217.152.87", "mac_id": "b8:27:eb:00:be:93", "hostname": "raspberrypi"},
{"column_num": 23, "ip_addr": "129.217.152.33", "mac_id": "b8:27:eb:c0:10:ae", "hostname": "raspberrypi"},
]

def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
for RPi in RPi_IPs:
for node in range(1,16): # range 1 to 16 is an array from 1 to 15.
client.subscribe("imu_reader/"+RPi['mac_id']+"/"+str(node))


def on_message(client, userdata, msg):
if msg.payload.decode():
j_msg = json.loads(msg.payload.decode('utf-8'))

# set paho.mqtt callback
client = mqtt.Client()
client.connect("129.217.152.1",8883,60)
client.on_connect = on_connect
client.on_message = on_message

# open as many dbs as required for every strip
for ip in RPi_IPs:
ip['redis_handler']= redis.Redis(host='129.217.152.1', port=6379, db=ip["column_num"])

try:
client.loop_forever()
except KeyboardInterrupt:
print('disconnect')
client.disconnect()
1 change: 1 addition & 0 deletions summerschool-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redis==3.5.3

0 comments on commit 479cded

Please sign in to comment.