Read multiple lines using UART protocol / uart.readline() or uart.read() not perform it

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
diego.cuba
Posts: 5
Joined: Fri Nov 18, 2016 10:05 pm
Contact:

Read multiple lines using UART protocol / uart.readline() or uart.read() not perform it

Post by diego.cuba » Wed Aug 02, 2017 5:51 pm

Dear Micropython Forum,

I would like to read 2 or more lines that are result of response from a GSM board which is receiving AT commands by micropython board,
and for example i need the third line of its response and i'm using uart.read() , also specifying the number of bytes, does not work properly , when i use uart.readline() the same thing it reads until the \n caracter but i cant get read the third line.

Is there any people that can give me a brief solution of it or any topic related with it
Thanks for your attention,

What i receive:

Code: Select all


>>> uart.readline()
b'+CMGL: 1,"REC READ","w49434p41425@4","","17/0'  
  
What i expect receive:

Code: Select all


>>> uart.readline()
b'+CMGL: 1,"REC READ","w49434p41425@4","","17/0'  
A simple demo of SMS text messaging.

OK
((( :geek: Diego Cuba Z )))

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Read multiple lines using UART protocol / uart.readline() or uart.read() not perform it

Post by deshipu » Wed Aug 02, 2017 6:23 pm

readline reads a single line. To read three lines, you have to call it three times.

diego.cuba
Posts: 5
Joined: Fri Nov 18, 2016 10:05 pm
Contact:

Re: Read multiple lines using UART protocol / uart.readline() or uart.read() not perform it

Post by diego.cuba » Wed Aug 02, 2017 10:31 pm

deshipu wrote:readline reads a single line. To read three lines, you have to call it three times.
Thanks deshipu but i performed and while true and does not read the third one.
((( :geek: Diego Cuba Z )))

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Read multiple lines using UART protocol / uart.readline() or uart.read() not perform it

Post by deshipu » Thu Aug 03, 2017 1:09 am

Perhaps the third line doesn't have \n at the end?

Post Reply