Esempio n. 1
0
def scan_boards():

	geniePi.genieWriteStr(2, 'Searching boards...')
	devices = bus.scan()

	print devices

	for i in range(1,5):
		time.sleep(0.1)
		geniePi.genieWriteStr(i+2, str(devices[i-1]))    

	geniePi.genieWriteStr(2, 'Found boards!')

	print >>sys.stderr, ("Scan realizado com sucesso!\n") 
Esempio n. 2
0
def opening_serial_communication(f):

	setup_port()

	printing_ip_on_display()	
	
	time.sleep(0.2)
	geniePi.genieWriteStr(2, 'Searching boards...')
	devices = bus.scan()
	
	for i in range(1,5):
		geniePi.genieWriteStr(i+2, str(devices[i-1]))    

	geniePi.genieWriteStr(2, 'Found boards!')
	print >>sys.stderr, ("Scan realizado com sucesso!\n")
Esempio n. 3
0
def handler_received_data(string_data):

	print("Treating receveid string data: " + str(string_data))

	if (string_data == '\n'):
		print >>sys.stderr, ("Receive from client invalid command!")
		return

	length = len(string_data)

	if (length < MINIMUM_DATA_SIZE):
		print >>sys.stderr, ("The package size is too small!")
		return

	if (length > MAXIMUM_DATA_SIZE):
		print >>sys.stderr, ("The package size is too large!")
		return

	integer_data = []
	
	print("Converting string data to integers...\n")
	
	for i in range(length):
		integer_data.append(ord(string_data[i]))

	check    = integer_data[0]
	command  = integer_data[1]

	print ("Check: ", str(check))
	print ("Command: ", str(command))

	if(check == CHECK):

		if(command == 1):
		
			print ("REALIZANDO SCAN!\n")
			devices = bus.scan()
			print devices
			return devices

		elif(command == 2):

			print ("REALIZANDO LOOPBACK!\n")
			address = integer_data[2]
			data = [1,2,3,4,5,6,7,8]
			read = bus.loopback(address,data)
			print "Dados enviados: ", data
			print "Dados recebidos: ", read
				
		elif(command == 3):

			print ("REALIZANDO DAC!\n")

		elif(command == 4):

			print ("REALIZANDO MOTOR!\n")
			board_address 		= integer_data[2]
			direction 		= integer_data[3]
			velocity 		= integer_data[4]
			position	 	= integer_data[5]			
			
			motor(board_address, direction, velocity, position)
			
		elif(command == 5):

			print ("REALIZANDO TEMPERATURA!\n")
		
		elif(command == 6):

			print ("REALIZANDO CORRENTE!\n")

		else:
			print >>sys.stderr, ("Error: Incorrect Command\n")
			return                
	else:
		print >>sys.stderr, ("Error: Incorrect Package\n") 		
		return

	print("Cheguei no fim da funcao handler\n")
Esempio n. 4
0
import time              # Library time
import RPi.GPIO as GPIO  # Library GPIO
import bus               # Library Bus SPI Control
#import server            # Library Ethernet Communication
#import display           # Library Display Control
 
print '\nTeste SCAN\n'

#address   = int(raw_input('What is address ? '))
address = 3


a = [82, address]

typeBoard = 3

if typeBoard == 1:   
	a.append(50) 
elif typeBoard == 2: 
	a.append(52)
elif typeBoard == 3: 
	a.append(53)
elif typeBoard == 4: 
	a.append(51)	
else: print 'Error: Incorrect Board'

print a

for i in range(1):
	b = bus.scan(address)