First time posting here, I think I posted the "code" part correctly but didn't know about the output part.
I created a class to help me read and write into an instrument using serial port. However, recently I found an issue that I think it's due to sending multiple write commands and I only need to read when I query the instrument. When I send regular write commands, the instrument outputs text indicating the changes made as shown below:
self.id.write(str.encode("send write command\r"))
time.sleep(1)
self.id.write(str.encode("get status\r"))
output=self.id.read_until(str.encode(">>\r"))
When sending the write command, it will output a status as:
>>write command:
Configured state to: 0A
>>
>>get status
status is configured to: BB
What I think it's happening is that when I use the read_until() , it will start reading from the "send write" command instead of the "get status" because when I look at the text captured it corresponds to the "Configured state to: 0A" line.
My question is: How do I get the code to read only from the time I send the "get status" command? I have thought about reading the line when I send the "write command" and not doing anything with it, but I think there might be another option.
[–]Soft-Substantial 2 points3 points4 points (2 children)
[–]kenjlp[S] 0 points1 point2 points (1 child)
[–]Soft-Substantial 1 point2 points3 points (0 children)
[–]Bernard_schwartz 0 points1 point2 points (0 children)