Exemple #1
0
 def readMotorAmps(self):
     #RECEBER OS DADOS E RETORNAR UM VETOR COM O VALOR DOS DOIS DADOS
     serial.write('?A'+'\r')
     serial.read_until('\r')
     receivedData = str(serial.read_until('\r'))
     receivedData = receivedData.split('=')[1].split(':')
     return receivedData 
Exemple #2
0
 def readTemperature(self, channel):
     ''' 
     channel 1: MCU
     channel 2: channel1 side
     channel 3: channel2 side'''
     serial.write('?T ' + str(motorch)+'\r')
     serial.read_until('\r')
     receivedData = str(serial.serial.read_until('\r'))
     receivedData = receivedData.split('=')[1]
     return receivedData 
Exemple #3
0
 def readVolts(self):
     ''' 
     1 : Internal volts
     2 : Battery volts
     3 : 5V output'''  
     serial.write('?V'+'\r')
     serial.read_until('\r')
     receivedData = str(serial.serial.read_until('\r'))
     receivedData = receivedData.split('=')[1].split(':')
     return receivedData 
Exemple #4
0
def sendCommand(serial, command, value=None):
    write(serial, command)

    if value is not None:
        write(serial, value)

    out = serial.read_until(b'OK\r').decode('ascii')
    return out.replace('OK\r', '')
Exemple #5
0
def read_image(serial):
    print("Reading Image...")
    data = serial.read(width * height)
    print("Received Image...")
    image = Image.frombytes('P', (width, height), data)
    image.save('./image.bmp')

    ok = serial.read_until('***')
    print(("Arduino says {}".format(ok)))
Exemple #6
0
def drawText():
    serial.write("CONF?".encode('utf-8'))
    query = getMode(serial.read_until())
    modeText = query[0]
    modifierText = query[1]

    serial.write("READ?".encode('utf-8'))
    data = serial.read_until()
    canvas.itemconfigure(value, text=data)
    canvas.itemconfigure(modifier, text=modifierText)
    canvas.itemconfigure(mode, text=modeText)

    font = Font(family="LcdStd", size=60)
    length = font.measure(data)
    canvas.coords(modifier, length, 38)
    canvas.coords(mode, length, 13)

    serial.write("SYSTEM:LOCAL?".encode('utf-8'))
    root.after(100, drawText)
Exemple #7
0
 def readPositionRelativeTracking(self, motorch):
     serial.write('?TR ' + str(motorch)+'\r')
     serial.read_until('\r')
     receivedData = str(serial.serial.read_until('\r'))
     receivedData = receivedData.split('=')[1]
     return receivedData 
Exemple #8
0
 def readEncoderSpeedRelative(self, motorch):
     serial.write('?SR ' + str(motorch)+'\r')
     serial.read_until('\r')
     receivedData = str(serial.read_until('\r'))
     receivedData = receivedData.split('=')[1]
     return receivedData 
Exemple #9
0
 def readMotorPowerOutputApplied(self, motorch):
     serial.write('?P ' + str(motorch)+'\r')
     serial.read_until('\r')
     receivedData = str(serial.read_until('\r'))
     receivedData = receivedData.split('=')[1]
     return receivedData 
Exemple #10
0
 def readFeedback(self, motorch):
     serial.write('?F ' + str(motorch)+'\r')
     serial.read_until('\r')
     receivedData = str(serial.read_until('\r'))
     receivedData = receivedData.split('=')[1]
     return receivedData 
Exemple #11
0
 def readClosedLoopError(self, motorch):
     serial.write('?E ' + str(motorch)+'\r')
     serial.read_until('\r')
     receivedData = str(serial.read_until('\r'))
     receivedData = receivedData.split('=')[1]
     return receivedData    
Exemple #12
0
 def readEncoderCounteAbsolute(self, motorch):
     serial.write('?C ' + str(motorch)+'\r')
     serial.read_until('\r')
     receivedData = str(serial.read_until('\r'))
     receivedData = receivedData.split('=')[1]
     return receivedData
Exemple #13
0
 def readBatteryAmps(self):
     serial.write('?BA R:'+'\r')
     serial.read_until('\r')
     receivedData = str(serial.read_until('\r'))
     receivedData = receivedData.split('=')[1].split(':')
     return receivedData 
Exemple #14
0
import serial

serial = serial.Serial('COM4', 9600, timeout=5)

for i in range(10):
    serial.write(str.encode('Hello;'))
    print('Sent Message %s' % i)
    serial.flush()

print(serial.read_until(';'))

print('Received')

serial.close()