I am trying to get pyserial to send/receive ascii text to/from Meade ETX-90 telescope. I have tested the comm link using Putty and Tera term and COM3 is working properly. My requirement is simple. If I send "#:GR# " I should receive "19:00:21#" The program runs and I think I am sending out the string #:GR# but the serial. receive does not seem to work. All I get is b' ' ? I find very little good documentation of these functions. I hope someone sees my problem.
import serial
import time
ser = serial.Serial("COM3", 9600, timeout = 1)
while 1:
name = input("Get a name: ")
print(name)
print(ser.is_open)
if name == "exit" :
ser.close()
exit()
if ser.isOpen():
print("ser is open")
ser.write("hello".encode("utf-8")) #Note 1
print("write completed")
time.sleep(2)
#instr = ser.readline().strip().decode("utf-8") #Note 2
#instr = ser.readline() #Note 3
print(ser.read())
print(ser.read())
print(ser.read())
print(ser.read())
print(ser.read())
#print(instr)
print("End of while")
Following is what I send and reeive.
#python Hello.py
#Get a name: #:GR#
#True
#ser is open
#write completed
#''
#End of while
#Putty, when I send #:GR# I receive 19:00:21#
import serial
import time
ser = serial.Serial("COM3", 9600, timeout = 1)
while 1:
name = input("Get a name: ")
print(name)
print(ser.is_open)
if name == "exit" :
ser.close()
exit()
if ser.isOpen():
print("ser is open")
ser.write("hello".encode("utf-8")) #Note 1
print("write completed")
time.sleep(2)
#instr = ser.readline().strip().decode("utf-8") #Note 2
#instr = ser.readline() #Note 3
print(ser.read())
print(ser.read())
print(ser.read())
print(ser.read())
print(ser.read())
#print(instr)
print("End of while")
Following is what I send and reeive.
#python Hello.py
#Get a name: #:GR#
#True
#ser is open
#write completed
#''
#End of while
#Putty, when I send #:GR# I receive 19:00:21#