it's a multiple lines output what the modem returns to your application. will need multiple readline calls to collect all the output (the OK is not the first response line and neither it is second one, and if readline calls are too fast will be lost the tail of the message). consider following code instead (the answer var would be complete modem reply placeholder):
`
import serial, time
modem = serial.Serial(port='/dev/ttyHS0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=1, xonoff=False, rtscts=False, dsrdtr=False)
cmd = "AT\r"
modem.write(cmd.encode())
answer = ""
read_timeout = 0.1
quantity = modem.in_waiting
while True:
if quantity > 0:
answer += modem.read(quantity)
else:
# read_timeout is depends on port speed
# with following formula it works:
# 0.1 sec + 1.0 sec / baud rate (bits per second) * 10.0 bits (per character) * 10.0 times
# example for 115200 baud rate:
# 0.1 + 1.0 / 115200 * 10.0 * 10.0 ~ 0.1 sec
time.sleep(read_timeout)
quantity = modem.in_waiting
if quantity == 0:
break
`