SparkFun Forums 

Where electronics enthusiasts find answers.

Tips and questions relating to the GPS modules from SFE
By fireball003
#53475
hi,
I need to read line, that is it will read the whole string when it will receive a '\n'.

But I couldn't find out any solution using SER.receive() , SER.receivebyte() and SER.read(). When I use SER.receive(timeout) or SER.receivebyte(timeout) then after timeout or after receiving first character it goes to next prompt.

Close one is SER.read() with MOD.sleep(timeout). But say user enter data in the last moment of timeout or can not enter data within timeout period , then the data is scattered.

Anyone build readline() function? Any suggestion on how can I solve this ?

Thanks in advance.
By Jonek
#53721
Cant you just wait in a loop? Something like:
Code: Select all
r = SER.receive(20)
while(r.find('\r\n')==-1):
      r = r+SER.receive(20)