I need to use some At commands & read the data for that I am using below cmds, the response I would be getting is in multiple lines
serialPort.write(b"AT+CMD\r\n")
time.sleep(1)
response = serialPort.readlines()
if I am using only readline() i dont get full expected response but if i do read lines() i do get the full data but some lines skipped sometime, i need to know the difference between these 2 methods & also for the
timeout flag
how does it effects functionality of these
readline()
: reads one line, if you use multiple times, each time it will keep giving next line until it reaches end of file or file is closed.
readlines()
: returns a list of lines from a file
If you want the output of a whole file, you can use read()
instead.
About the timeout
flag, I don't think timeout flag exists for I/O operations in Python? But if you are talking about the one in Serial
, then it specifies the maximum time to wait for serial data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.