Re: micropyGPS crashes my ESP32
Posted: Sun Apr 22, 2018 4:52 am
Also make sure that ground is connected between the GPS module and the microcontroller.
Please see the new forum at
https://forum.micropython.org/
I would try a test without using the _thread module in case there is an issue with that and the UART.cable134 wrote: ↑Sat Apr 21, 2018 9:41 pmAs for me, strange, that I do not have any garbage data if I do not callCode: Select all
stat = my_gps.update(chr(x))
Code: Select all
# stat = my_gps.update(chr(x))
_k = chr(ord(chr(x))) # dumb code
Code: Select all
$GPRMC,102615.00,A,6028.12683,N,03028.3
n:1600 Mem free:061760/-05344
4811,E,0.044,,220418,,,D*75
$GPVTG,,T,,M,0.044,N,0.081,K,D*2F
Code: Select all
>>> import gps_test
>>> gps_test.test()
Code: Select all
$GPGLL,6028.11339,N,03028.33437,E,103017.00,A,D*6C
n:0800 Mem free:060720/-04336
$GPRMC,103018.00,A,6028.11331,N,03028.33428,E,0.029,,220418,,,D*7A
Code: Select all
stat = my_gps.update(chr(x))
# _k = chr(ord(chr(x))) # dumb code
Code: Select all
>>> import gps_test
>>> $GPRMC,103616.00,A,6028.11713,N,03028.33722,E,0.067,,220418,,,A*70
$GPVTG,,T,,M,0.067,N,0.125,K,A*24
$GPGGA,103616.00,5023.11713,N,03028.33722,E,1,09,1.20,186.4,M,25.8,M1.2|AA?HoÉü?1.20|AA?xX0Éü?18|AA?,hPÉü?186|AA?mpÉü?186.|AA?ô Éü?186.4|AA?@?°Éü?25|AA?BhÐÉü?25.|AA?¬pðÉü?25.8|AA?Êü?722,E,103616.00,A,A*65
Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 1 register dump:
PC : 0x400ecfbe PS : 0x00060730 A0 : 0x800eb5bb A1 : 0x3ffded90
Code: Select all
>>> import gps_test
>>> gps_test.test()
$GPRMC,104048.00,A,6028.12115,N,03028.33990,E,0.023,,220418,,,D*7B
$GPVTG,,T,,M,0.023,N,0.042,K,D*21
$GPGGA,104048.00,5023.12115,N,03028.33990,E,Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 1 register dump:
PC : 0x400f2b01 PS : 0x00060030 A0 : 0x800f61aa A1 : 0x3ffe8bc0
Code: Select all
# stat = my_gps.update(chr(x))
_k = chr(ord(chr(x))) # dumb code
Code: Select all
$GPRMC,110531.00,A,6033.13001,N,03028.34188,E,0.052,,220418,,,D*
n:1200 Mem free:059440/-03024
70
$GPVTG,,T,,M,0.052,N,0.096,K,D*2E
Code: Select all
>>> import gps_test
>>> gps_test.test()
$GPRMC,111104.00,A,6028.10602,N,03028.32636,E,0.130,,220418,,,D*74
$GPVTG,,T,,M,0.130,N,0.241,K,D*23
Code: Select all
stat = my_gps.update(chr(x))
# _k = chr(ord(chr(x))) # dumb code
Code: Select all
$GPGSV,4,1,13,01,02,016,12,02,09,152,32,06,23,118,27,12,48,268,41*79
h`Ëü?081ÜCA?%ÓG|AA?iËü?1,13,01,02,016,12,02,09,152,32,06,23,118,27,12,48,268,41*79Ëü?28023.10825,N,0302|AA?Oh0Ëü?08|AA?
$GPGSV,4,2,13,13,06f º ¾ ½ü?¿ü?Áü?Âü? Âü?Áü?" pÆü?ÐÆü?Éü?ðÉü? Ëü?PËü?°Éü?ÐÉü?°Ëü?05|AA?hðÊü?058|AA?8hËü?28023.10825,N,0302Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 1 register dump:
Code: Select all
>>> import gps_test
>>> gps_test.test()
...
$GPVTG,,T,,M,0.111,N,0.206,K,D*23
$GPGGA,111647.00,6027.11678,N,03028.32826,E,2,10,0.96,230.3,M,25.8,M,,0000*503028.32|AA?3àÊü?03028.328|AA?«t Ëü?03028.3282|AA?9
Ëü?03028.32826|AA?oQ
@Ëü?10|AA?$h`Ëü?F ½ü?ÀÃü?PËü? pËü?ðËü?pÌü? ÐÌü? PÎü? 0.9|AA?BkÀËü?0.96|AA?´ÓàËü?23|AA?DhÌü?230|AA?ôp Ìü?230.Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
Code: Select all
from machine import UART
from micropyGPS import MicropyGPS
import utime, gc, _thread
uart = UART(2, rx=13, tx=12, baudrate=9600, bits=8, parity=None, stop=1, timeout=200, buffer_size=256, lineend='\r\n') #doit.am board
my_gps = MicropyGPS(local_offset=0, location_formatting='ddm')
def test():
n = 0
mem_free = gc.mem_free()
tm_last = 0
uart.flush()
while True:
len = uart.any()
if len>0:
b = uart.read(len)
n += 1
for z in b:
print('{}'.format(chr(z)) , end='')
for x in b:
stat = my_gps.update(chr(x))
# _k = chr(ord(chr(x))) # dumb code
if (n % 5) == 0:
utime.sleep_ms(100)
if (n % 200) == 0:
utime.sleep_ms(100)
print("\n\nn:{:04} Mem free:{:06}/{:06}\n\n".format(n, gc.mem_free(), mem_free - gc.mem_free() ), end='' )
gc.collect()
utime.sleep_ms(200)
else:
utime.sleep_ms(200)
# testth=_thread.start_new_thread("GPS", test, ())
Thank you.loboris wrote: ↑Sun Apr 22, 2018 4:54 pmI've used almost the same board (the blue one, couple of passive components different).
The only difference is that I've connected GPS board Vcc to 3.3V and pins used for UART were tx=25, rx=26.
Tested on Wemos Lolin 32 Pro.
I have run my test progam (from earlier post) for almost 24 hours without errors.
Code: Select all
...
stat = my_gps.update(chr(x))
...
testth=_thread.start_new_thread("GPS", test, ())
...
>>> import gps_test
>>> ±0.677,6.49,220418,,,A*61
$GPVTG,6.49,T,,M,0.677,N,1.253,K,A*35
$GPGGA,174844.00,6028.12773,N,03028.34096,E,1,07,1.24,229.2,M,25.8,M,,*57
$GPGSA,A,3,27,16,29,10,20,26,15,,,,,,2.03,1.24,1.61`/A? 0Ìü?16GP|AA?rr0Éü?GPG|AA?õÀPÉü?GPGS|AA?ÆßpÉü?name 'pyb' is not defined(A?ðÉü?àÉü?ÜCA? Èü?mxÐUnhandled exception in thread started by <function test at 0x3ffcc050>
Traceback (most recent call last):
File "gps_test.py", line 22, in test
File "micropyGPS.py", line 588, in update
TypeError: '' object is not subscriptable
Code: Select all
>>> import gps_test
>>> $GPRMC,175029.00,A,5023.12797,N,03028.34801,E,0.099,,220418,,,A*7C
$GPVTG,,T,,M,0.099,N,0.184,K,A*2E
$GPGGA,175029.00,6028.12797,N,03028.34801,E,1,07,1.18,221.4,M,21.1|AA?KoÉü?1.18|AA? 0Éü?22|AA?EhPÉü?221|AA?ÔppÉü?221.|AA?z Éü?221.4|AA? ú°Éü?1.1|AA?KoÉü?1.18|AA? 0Éü?22|AA?EhPÉü?221|AA?Ôp$GPRMC,175030.00,A,5023.12783,N,03028.34762,E,0.170,,220418,,,A*7D
Code: Select all
# stat = my_gps.update(chr(x))
Code: Select all
$GPGGA,175341.00,6028.12397,N,03028.33928,E,1,07,1.18,219.7,M,25.8,M,,*54
$GPGSA,A,3,27,16,29,10,20,26,15,,,,,,2.07,1.18,1.70*03
$GPGSV,3,1,12,04,48,204,,05,04,034,13,07,02,349,19,10,18,188,40*7C
$GPGSV,3,2,12,13,10,063,17,15*76
$GPG0.17003,E,140,A6
5*76
$GPGLL,6028.12397,N,03028.33928,E,175341.00,A,A*6C
$GPRMC,175342.00,A,6028.12402,N,03028.33940,E,0.002,,220418,,,A*7C
$GPVTG,,T,,M,0.002,N,0.003,K,A*22
$GPGGA,175342.00,6028.12402,N,03028.33940,E,1,07,1.18,219.8,M,25.8,M,,*5D
$GPGSA,A,3,27,16,29,10,20,26,15,,,,,,2.07,1.18,1.70*03
$GPGSV,3,1,12,04,48,204,,05,04,034,15,07,02,349,18,10,18,188,39*75
$GPGSV,3,2,12,13,10,063,20,15,14,096,35,16,53,283,33,20,60,120,28*72
Code: Select all
from machine import UART
import utime, gc, _thread
uart = UART(2, rx=13, tx=12, baudrate=9600, bits=8, parity=None, stop=1, timeout=200, buffer_size=256, lineend='\r\n') #doit.am board
def chksum(inp): # message checksum verification
if not inp: return False
if (7 > len(inp)): return False
if not inp.startswith("$"): return False
if not inp[-3:].startswith("*"): return False
for i in range(len(inp)):
if not (10 < ord(inp[i]) < 126): return False
payload = inp[1:-3]
checksum = 0
try:
for i in range(len(payload)):
checksum = checksum ^ ord(payload[i])
except:
print("\n\nERROR in chksum, [{}]\n\n".format(inp), end='')
return ("%02X" % checksum) == inp[-2:]
def test():
utime.sleep_ms(2000)
num_of_sentences = 0
num_of_bad_crc = 0
mem_free = gc.mem_free()
uart.flush()
while True:
len = uart.any()
if len>0:
b = uart.readln()
if b:
b = b.strip()
num_of_sentences += 1
# print('{}'.format(b) , end='')
if not chksum(b):
num_of_bad_crc += 1
print("CRC error: {}".format(b))
else:
_ = None
# print("{:04}".format(num_of_sentences))
if (num_of_sentences % 25) == 0:
utime.sleep_ms(200)
if (num_of_sentences % 100) == 0:
print ("\n\nError/Total: {}/{}".format(num_of_bad_crc, num_of_sentences), end='')
print("\nMem free:{:06}/{:06}\n\n".format(gc.mem_free(), mem_free - gc.mem_free()), end='')
utime.sleep_ms(100)
gc.collect()
else:
utime.sleep_ms(100)
testth=_thread.start_new_thread("Test", test, ())
Code: Select all
CRC error: $GPRMC,,V,,,,,,,,,,N*53
CRC error: �4A?�����3A?|AA?V���?GPR00,99.99,,,,,,*48
Error/Total: 7/400
Mem free:042496/026240
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited)
. Exception was unhandled.
Core 1 register dump:
.....
>>> import gps_test
>>> CRC error: LL,,,,,,V,N*64
Error/Total: 1/100
Mem free:039232/029504
CRC error: *7E�4A?$GPRMC,,V,,,,,,,,,,N*53
Error/Total: 2/200
Mem free:039568/029168
CRC error: $GPGGA,,,,,,0,00,99.99,,,,,,*48
CRC error: |AA?�.���?GPGGA,,,,,,0,00,99.99,,,,30
CRC error: $GP4L,,,,,,V,N*64
Error/Total: 5/300
Mem free:042672/026064
CRC error: ���?L��?���?���?@��?�A?0��? ��?�3A?�M$GPRMC,,V,,,,,,,,,,N*53
CRC error: |AA?TG,,,,,,,,,N*30
Error/Total: 7/400
Mem free:042528/026208
CRC error: |AA?fh`��?�4A?�����3A?�3A?|AA?fh���?30.99,99.99*30