I’m trying to use a python script, which has been implemented successfully in the past on a different PC, to read the data output from an Olympus Epoch 650 ultrasound tester and store it as text files. It should use ser.readline()
to read the data output at fixed intervals set using time.sleep(x)
within a loop. However, when the loop is run, it stops at the read/ write step.
Using ser = serial.Serial('COM4')
creates a variable ser
with the correct name:
Serial<id=0x2be03afa200, open=True>(port='COM4', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)
However when using:
import serial
import time
while 1:
ser = serial.Serial('COM4')
print(ser.name)
ser.write(ser.write(str.encode('param_RawData=0,10rn'))
line = ser.readline()
print(len(line))
time.sleep(15)
ser.close()
results in the name being printed correctly, but the loop does not proceed past this point.
I’ve also tried ser.write(str.encode('param_Range=10rn'))
, which should result in a change of the ‘Range’ parameter on the device display, however nothing changes when I run this.
Is there a way to confirm the device connection and read the data?
iambirdy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.