Jul-09-2018, 02:30 PM
[quote='DeaD_EyE' pid='51872' dateline='1530950771']
I have tried both of the suggested approaches and it just causes a loop to occur at the readline for whatever reason.
Updated Code:
Quote:If you're able to open the port again, then send bytes and not a str.
ser.write(b'SENS:VOLT:RANG 10 \r\n')or
ser.write('SENS:VOLT:RANG 10 \r\n'.encode())
I have tried both of the suggested approaches and it just causes a loop to occur at the readline for whatever reason.
Updated Code:
import serial import time ser = serial.Serial() ser.baudrate = 9600 ser.bytesize = 8 ser.stopbits = 1 ser.xonxoff = 0 ser.rtscts = 0 ser.timeout = None ser.port = "COM4" parity=serial.PARITY_NONE ser.open() print ("Connection to Fluke successful") ser.write('MEAS:VOLT:RANG 10 \r\n'.encode()) time.sleep(2) print ("Time Sleep successful") print(ser.readline()) ser.close() print ("Connection Severed")
Output:Connection to Fluke successful
Time Sleep successful