Skip to content

Commit

Permalink
add script to turn on/off power and rss-422
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasIbrahim authored and akrv committed May 25, 2020
1 parent 4a7d69b commit 7886d2a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
40 changes: 40 additions & 0 deletions floor_flasher/all_turn_on_comm_off.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import serial
import os
import json
import ow
import argparse

if __name__ == '__main__':
# args
parser = argparse.ArgumentParser()
parser.add_argument('--turn-on', dest='powered', action='store_true')
parser.add_argument('--turn-off', dest='powered', action='store_false')
parser.set_defaults(powered=False)

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

if args.powered:
print('turning all nodes on, communication off')
else:
print('turning all node off')

# get the wire1 lib setup to talk the devices
(ow.init('localhost:4304'))
node_list = ow.Sensor('/').sensorList()

# turn on and put them in a not communicating mode
for sensor in node_list:
if sensor.type == "DS2408":
if args.powered:
sensor.PIO_BYTE = "64" # turn off
sensor.PIO_BYTE = "147" # turn on with comms
sensor.PIO_7 = "0" # turn off RX & TX
sensor.PIO_6 = "1"
else:
sensor.PIO_BYTE = "64" # turn off
sensor.PIO_7 = "0" # turn off RX & TX
sensor.PIO_6 = "1"
10 changes: 10 additions & 0 deletions floor_flasher/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def webui():
def reboot():
run('sudo reboot now')

@parallel
def turnon():
with cd('~/sensorfloor/floor_flasher'):
run('python all_turn_on_comm_off.py --turn-on')

@parallel
def turnoff():
with cd('~/sensorfloor/floor_flasher'):
run('python all_turn_on_comm_off.py --turn-off')

# /Users/akrv/Documents/dev/sensorfloor/imu_app/imu_ti_workspace/imu_data_interrupt/Release/imu_data_interrupt.bin

def cssh():
Expand Down
53 changes: 53 additions & 0 deletions floor_flasher/rss_on_off.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import serial
import os
import json
import ow
import argparse

if __name__ == '__main__':
# args
parser = argparse.ArgumentParser()
parser.add_argument('--node-id', type=int, default='')
parser.add_argument('--rss-on', dest='rss_state', action='store_true')
parser.add_argument('--rss-off', dest='rss_state', action='store_false')
parser.set_defaults(rss_state=False)

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

# get the wire1 lib setup to talk the devices
(ow.init('localhost:4304'))
node_list = ow.Sensor('/').sensorList()

# serial port to talk through rs422
ser = serial.Serial('/dev/ttyUSB0', baudrate=115200, timeout=1)
ser.reset_input_buffer()

with open(os.path.dirname(os.path.realpath(__file__)) + '/../addr_finder/node_order.json') as json_file:
strip_path_inorder = json.load(json_file)
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
for sensor in node_list:
if sensor.type == "DS2408":
sensor.PIO_7 = "0" # turn off RX & TX
sensor.PIO_6 = "1"

# turn on RSS 422 for desired node
sensor = strip_path_inorder[args.node_id-1]
sensor = ow.Sensor(str(sensor))
if sensor.type == "DS2408":
if args.rss_state == True:
# turn on RS422
print('Turn on rss for sensor ID:' + str(args.node_id) + ' 1-wire: '+ str(sensor._path))
sensor.PIO_7 = "1"
sensor.PIO_6 = "0"
else:
# 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"

0 comments on commit 7886d2a

Please sign in to comment.