def SeriLeon(inp): """ This function takes a input string and then calls 'leonstart' to open a serial port. Then it sends the input argument over with 'leonsend' on the port opened. Finally it captures the response of the device. :param inp: Input string to be sent over the serial port. :returns: y, a string containing the response of the Leon3 board. """ import leonSer import time end=0 #Open the serial port port = leonSer.leonstart() #Check if the port is open, or else return -1 that indicates an error if port !=-1: y=leonSer.leonsend(port, inp) if y==1: print 'No correct responce' end+=1 #Close the Opened Port leonSer.leonstop(port) return y else: return -1
def GuiLeon(inp): """ This function takes a input string and then calls 'leonstart' to open a serial port. Then it sends the input argument over with 'leonsend' on the port opened. :param inp: Input string to be sent over the serial port. """ import leonSer import time #Open the serial port port = leonSer.leonstart() #Small delay to allow the Serial Link to be established time.sleep(0.001) #Send the data on the port leonSer.leonsend(port, inp+'\n') #Close the opened port leonSer.leonstop(port)
def kickoff(StrGuiinput): '''This function starts the execution of the module. It handles and sends the values to the proper functions. In this build it is also used for debugging by forcing input and printing the output of the module and by sending the data to the *ahbSeri* module.f ''' import time import ahbSeri import leonSer global Debug Debug='1' # debuging mode, Enables printing and disables the communication testing. NumberOfEffects=12 # the number of the effects included in the design. WordLength=4 # the length of each data packet to be written in memory, measured in bytes. WordNumber=28 # the number of words that will be written on the memory. StartingAdress='0x40f00000' # Starting Address where the data will be written. print "Debug mode= ",Debug Multiplier_list=[[10,1,10], # Multipliers[0] = bass, peak, treble [255,2.55,2.55],[2.55,2.55,2.55,1],[2.55,2.55,2.55,2.55], # Multipliers[1:4] = Delay, Chorus, Flanger [2.55,2.55,2.55,1],[2.55,2.55,1],[2.55,2.55,2.55,1], # Multipliers[4:7] = Tremolo, Vibrato, Wahwah [2.55,2.55,2.55], [2.55,2.55,2.55,2.55,1], # Multipliers[7:9] = Phaser, Distortion [2.55], [2.55], [2.55]] # Multipliers[9:11] = Noise Gate, Gain1, Gain2 Adder_list= [120,0,0] # Adders[0] = Treble, bass, Peak zomginput1= StrGuiinput zomginput2= ''',0,1,0,0,0,0,0,0,0,0,0,#, -4.0,200,0.7,#,2.0,800,1.0,#,1.0,8000,1.0,#, 0.0,15,40,#,23,20,89,2#,0,0,0,0,#, 99,40,32,0,#,50,22,0,#,15,20,92,0,#, 15,20,52,#,15,20,92,50,1,#, 50,#,35,#,20,''' #test Communication----------------------------------------------------------------------------------- testcom=leonSer.leonstart() if testcom==-1: print "Error in Communication!" if Debug=='0': print "Aborting Program!!!!" exit() else: print "Communication relay works!" leonSer.leonstop(testcom) #end of Testing Communication------------------------------------------------------------------------- Priority_list,String_list=guiparse(zomginput1) # <--------------------input goes here if Debug=='1': print "Priority_list: ", Priority_list Priority_packets=prioritizer(Priority_list,NumberOfEffects) #checked for all effects if Debug=='1': print 'Priority_packets: ', Priority_packets Number_list=parsed2values(String_list) #checked for all effects, float and int values Formated_list=data4intformator(Number_list,Multiplier_list,Adder_list) #Multiplies, adds, and turns to int. For variable number of effects depending on input. hexed_list=hexizer(Formated_list) #checked for all effects Data_packets=hexconcatenator(hexed_list,Priority_packets) #checked for all effects #--------------------------------------------Creating adresses addresses=addresser(StartingAdress,WordNumber,WordLength) print 'The data packets are: ',len(Data_packets), Data_packets Errorcount=0 Errorlog=[] Data_number=len(Data_packets) for x in range(len(Data_packets)): confirm=ahbSeri.ahbwrite(addresses[x],Data_packets[x]) if confirm==-1: print "Error in Communication!" break #---------------------------Test the written data and compare them with those in the device y=ahbSeri.ahbread(addresses[x]) if x==0: pass elif y==Data_packets[x]: print 'Package'+str(x)+'',Data_packets[x],' delivered succesfully in address: ',addresses[x] else: print 'ERROR IN PACKAGE'+str(x),': ',Data_packets[x], 'in address: ',addresses[x] Errorcount=Errorcount+1 Errorlog.append(str(Data_packets[x])) if Errorcount!=0 : print 'Communication was executed with ',Errorcount, 'Errors.' print 'the packets lost are: ',Errorlog elif confirm!=-1 and testcom!=-1: print 'Communication was succesfull!!!'