Skip to content

Commit

Permalink
edit flashing script to flash a single node
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasIbrahim committed May 25, 2020
1 parent 7886d2a commit 28daa58
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
3 changes: 2 additions & 1 deletion floor_flasher/all_turn_on_comm_off.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python2
import serial
import os
import json
Expand Down Expand Up @@ -37,4 +38,4 @@
else:
sensor.PIO_BYTE = "64" # turn off
sensor.PIO_7 = "0" # turn off RX & TX
sensor.PIO_6 = "1"
sensor.PIO_6 = "1"
53 changes: 38 additions & 15 deletions floor_flasher/flashfloor.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
#!/usr/bin/python3

import os, requests, sys, json
import asyncio
import argparse

from fabfile import RPi_IPs

if len(sys.argv) > 1:
if sys.argv[1] == 'check':
check = True
else:
check = False
filename = sys.argv[1]
else:
print('Please provide absolute path file name as arg to flash')
print('check will check if all services are up')


def send_flash_req(ip_addr, filename, devices=0):
if filename:
url = "http://" + ip_addr
Expand Down Expand Up @@ -44,8 +36,39 @@ def check_all_services(RPi_IPs):
else:
print('failed: ', ips['ip_addr'])

if __name__ == '__main__':
# args
parser = argparse.ArgumentParser()
parser.add_argument('--firmware-path', type=str)

parser.add_argument('--check', dest='check', action='store_true')
parser.set_defaults(check=False)

parser.add_argument('--flash-all', dest='flash_all', action='store_true')
parser.add_argument('--flash-one-node', dest='flash_all', action='store_false')
parser.set_defaults(flash_all=False)

if check:
check_all_services(RPi_IPs)
else:
flash_coroutine(RPi_IPs, filename)
parser.add_argument('--strip-id', type=int)
parser.add_argument('--node-id', type=int)

try:
args = parser.parse_args()
except:
print('args provided are wrong')
exit()

if args.check:
print('Check all services')
check_all_services(RPi_IPs)
exit()

if args.firmware_path is None:
print('Please provide absolute path file name as arg to flash')
exit()

if args.flash_all:
print('Flashing the whole floor')
flash_coroutine(RPi_IPs, args.firmware_path)
else:
print('Flashing node strip_id:', args.strip_id, 'node_id:', args.node_id)
send_flash_req(RPi_IPs[args.strip_id-1]['ip_addr'], args.firmware_path, devices=args.node_id)
5 changes: 3 additions & 2 deletions floor_flasher/rss_on_off.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python2
import serial
import os
import json
Expand Down Expand Up @@ -31,7 +32,7 @@
json_file.close()
strip_path_inorder = [node_name['wire1'] for node_name in strip_path_inorder]

# turn on and put them in a not communicating mode
# turn off all nodes communication
for sensor in node_list:
if sensor.type == "DS2408":
sensor.PIO_7 = "0" # turn off RX & TX
Expand All @@ -50,4 +51,4 @@
# turn off RS422
print('Turn off rss for sensor ID:' + str(args.node_id) + ' 1-wire: '+ str(sensor._path))
sensor.PIO_7 = "0"
sensor.PIO_6 = "1"
sensor.PIO_6 = "1"

0 comments on commit 28daa58

Please sign in to comment.