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
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
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
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', '')
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)))
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)
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
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
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
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
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
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
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
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()