Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
fmhall committed Apr 9, 2019
1 parent dd96eb6 commit 32c00de
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
11 changes: 9 additions & 2 deletions RaspberryPi-master/Arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ def __init__(self,port,speed=9600):
self.orderQueue = []

def tryConnect(self):
while not self.is_connected:
count = 1
conn = None
while not self.is_connected and count < 3:
try:
conn = serial.Serial(port,speed)
self.is_connected = True
print("Connected to:")
print(self)
return conn
except:
print("\nAttempting to connect with ", str(self))
time.sleep(1)
time.sleep(1)
count += 1
print("\nCould not connect to Arduino")
return conn
#How the object will represent itself when called or printed
def __repr__(self):
Expand Down
8 changes: 4 additions & 4 deletions RaspberryPi-master/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from robust_serial import write_order, Order, write_i8, write_i16, read_i8, read_order
from robust_serial.utils import open_serial_port
def setup():
ard1 = Arduino(port="/dev/ttyUSB0",speed=9600)
ard2 = Arduino(port="/dev/ttyUSB1",speed=9600)
ard3 = Arduino(port="/dev/ttyUSB2",speed=9600)
ard4 = Arduino(port="/dev/ttyUSB3",speed=9600)
ard1 = Arduino(port="/dev/ttyACM0",speed=9600)
ard2 = Arduino(port="/dev/ttyACM1",speed=9600)
ard3 = Arduino(port="/dev/ttyACM2",speed=9600)
ard4 = Arduino(port="/dev/ttyACM3",speed=9600)
ardList = [ard1,ard2,ard3,ard4]
flag = True
for ard in ardList:
Expand Down
1 change: 1 addition & 0 deletions RaspberryPi-master/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

def send_on_off():
return

10 changes: 10 additions & 0 deletions RaspberryPi-master/tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import print_function, division, absolute_import
import serial
import time
import struct
from Arduino import Arduino
from robust_serial import write_order, Order, write_i8, write_i16, read_i8, read_order
from robust_serial.utils import open_serial_port

ard1 = Arduino(port="/dev/ttyACM0",speed=9600)

0 comments on commit 32c00de

Please sign in to comment.