Add files via upload

This commit is contained in:
Ram Reddy 2022-01-30 17:14:57 -05:00 committed by GitHub
parent 4bc2bb1ebf
commit bb9b2f8874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 10 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,11 +6,13 @@
# 1 for executing the first action in the priority queue
from Propioception import *
from commands import *
import threading
import socket
import heapq
import time
import serial
class Receiver:
def __init__(self, host, port):
@ -42,31 +44,46 @@ class Receiver:
if "Password" in action:
heapq.heappush(self.actions,action)
print(self.actions)
conn.send(action.encode()+bytes(" works",'utf-8'))
else:
print("Incorrect Command")
conn.send(bytes("Incorrect Commandc",'utf-8'))
# Sending reply
conn.send(action.encode()+bytes(" works",'utf-8'))
def execute(self):
while len(self.actions) > 0:
if self.timer == 0:
print("Executed: ", heapq.heappop(self.actions))
command = heapq.heappop(self.actions)
if command == "Password A_on_LED":
if onAndOfffLed():
print("Executed: ", command)
else:
print("Did not execute correctly ", command)
time.sleep(5)
heapq.heappush(self.actions, "Password Balancing")
if "Password Balancing" not in self.actions:
heapq.heappush(self.actions, "Password Balancing")
print("Inside execute",self.actions)
def sensorData(self):
# Test
# Read from Arduinos to know what motors and sensors there are
print("test")
print("Inside")
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1)
ser.reset_input_buffer()
while True:
print("Inside data")
# Read from Arduinos to know what motors and sensors there are
ser.write("Send ****s plz\n".encode('utf-8'))
line = ser.readline().decode('utf-8').rstrip()
print(line)
def runSimul(self):
threading.Thread(target=self.priorityQueue).start()
threading.Thread(target=self.execute()).start()
threading.Thread(target=self.sensorData()).start()
threading.Thread(target=self.execute).start()
threading.Thread(target=self.sensorData).start()
def startBoot():
simulation = Receiver('10.235.1.127',12345)
simulation = Receiver('10.235.1.148',12345)
simulation.runSimul()

BIN
Control System/bootup.pyc Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
# Commands for arduino
import serial
import time
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1) # fix
ser.reset_input_buffer()
def onAndOfffLed():
ser.write("ON\n".encode('utf-8'))
line = ser.readline().decode('utf-8').rstrip()
print(line)
time.sleep(4)
ser.write("OFF\n".encode('utf-8'))
line = ser.readline().decode('utf-8').rstrip()
print(line)
time.sleep(4)
if line == "You sent me: OFF":
return 1
else:
return 0

View File

@ -1,6 +1,6 @@
import sys
from bootup import *
def main():
startBoot() # when Olympian is booted up for first time