asynycio as_GPS

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
romeotango
Posts: 29
Joined: Tue Jun 16, 2015 10:52 am
Location: Germany

asynycio as_GPS

Post by romeotango » Mon Jan 06, 2020 10:09 am

os.uname()
(sysname='LoPy', nodename='LoPy', release='1.20.1.r2', version='v1.11-06dfad0 on 2019-11-30', machine='LoPy with ESP32', lorawan='1.0.2', pybytes='1.3.0')

For a project for motorcyclists I need current GPS data.
First step is to determine and record data for the simulation during the ride.
I found the wonderful libraries of Peter Hinch. Isn't he also a motorcyclist?
I use
uasyncio in the fast_io version
as_GPS
os.listdir("as_GPS")
>['as_GPS.py', 'as_GPS_utils.py', 'as_rwGPS.py']
>
>asyncio works in simple tests.
>
>But as_GPS does not want to instantiate:
gps = as_GPS.AS_GPS(sreader, fix_cb=callback) # Instantiate GPS
AttributeError: 'module' object has no attribute 'AS_GPS'
>I can't find any typos.
>No difference when using the original uasyncio version
I posted this topic at Pycom-forum some days ago.
My hope is, that Peter Hinch will read this topic here.
Same Problem on other hardware (FiPy)
precompiling to -.mpy-files made no difference
Thank you for help...



>(DeepL helped me to translate)
>
>
>(2020, 1, 4, 11, 6, 55, 480879, None)
>Pycom MicroPython 1.20.1.r2 [v1.11-06dfad0] on 2019-11-30; LoPy with ESP32
>Pybytes Version: 1.3.0
>Type "help()" for more information.
import uasyncio as asyncio
import as_GPS
from machine import UART
uart= UART(1, baudrate=9600, pins=('P20','P21'))
sreader = asyncio.StreamReader(uart) # Create a StreamReader
gps = as_GPS.AS_GPS(sreader, fix_cb=callback) # Instantiate GPS
>Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>AttributeError: 'module' object has no attribute 'AS_GPS'


i don think, it is not a memory problem:
see this test on FiPy
Pycom MicroPython 1.20.1.r2 [v1.11-06dfad0] on 2019-11-30; FiPy with ESP32
Pybytes Version: 1.3.0
Type "help()" for more information.
>>> import gc
>>> gc.mem_free()
2549728
>>> import uasyncio as asyncio
>>> gc.mem_free()
2533104
>>> import as_GPS
>>> gc.mem_free()
2532832
>>> uart= UART(1, baudrate=9600, pins=('P20','P21'))
>>> gc.mem_free()
2532480
>>> sreader = asyncio.StreamReader(uart)
>>> gc.mem_free()
2532256
>>> gps = as_GPS.AS_GPS(sreader, fix_cb=callback)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'AS_GPS'
>>> gc.mem_free()
2531776
>>>

jedie
Posts: 252
Joined: Fri Jan 29, 2016 12:32 pm
Contact:

Re: asynycio as_GPS

Post by jedie » Mon Jan 06, 2020 10:39 am

romeotango wrote:
Mon Jan 06, 2020 10:09 am

Code: Select all

os.listdir("as_GPS")
>['as_GPS.py', 'as_GPS_utils.py', 'as_rwGPS.py']
gps = as_GPS.AS_GPS(sreader, fix_cb=callback)  # Instantiate GPS
AttributeError: 'module' object has no attribute 'AS_GPS'
Think the error message AttributeError: 'module' object has no attribute 'AS_GPS' says it clearly.

What's the output of this:

Code: Select all

import as_GPS
print(dir(as_GPS))

User avatar
romeotango
Posts: 29
Joined: Tue Jun 16, 2015 10:52 am
Location: Germany

Re: asynycio as_GPS

Post by romeotango » Mon Jan 06, 2020 12:13 pm

import as_GPS
>>> print (dir(as_GPS))
['__class__', '__name__', '__path__']

The sourceCode hat this in it...

User avatar
romeotango
Posts: 29
Joined: Tue Jun 16, 2015 10:52 am
Location: Germany

Re: asynycio as_GPS

Post by romeotango » Mon Jan 06, 2020 12:23 pm

This is the output in the FiPy
(sysname='FiPy', nodename='FiPy', release='1.20.1.r2', version='v1.11-06dfad0 on 2019-11-30', machine='FiPy with ESP32', lorawan='1.0.2', sigfox='1.0.1', pybytes='1.3.0')
>>> import as_GPS
>>> dir (as_GPS)
['__class__', '__name__', '__path__']

This is the output on my mac
os.uname()
posix.uname_result(sysname='Darwin', nodename='Rainers-iMac-27-16.fritz.box', release='17.7.0', version='Darwin Kernel Version 17.7.0: Sun Dec 1 19:19:56 PST 2019; root:xnu-4570.71.63~1/RELEASE_X86_64', machine='x86_64')

>>> dir (as_GPS)
['ALTITUDE', 'AS_GPS', 'COURSE', 'DATE', 'DD', 'DM', 'DMS', 'DMY', 'GGA', 'GLL', 'GSA', 'GSV', 'KML', 'KNOT', 'KPH', 'LONG', 'MDY', 'MPH', 'POSITION', 'RMC', 'VTG', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'asyncio', 'const', 'modf']

And that seems to be ab big difference.
I cannot find a reason for this behaviour ...

Thankyou for thinking

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: asynycio as_GPS

Post by Roberthh » Mon Jan 06, 2020 12:47 pm

Uploading as_GPS to an Generic ESP32 works fine and returns the proper set of class members:

Code: Select all

MicroPython v1.12-35-g10709846f-dirty on 2020-01-01; ESP32 module (spiram) with ESP32
Type "help()" for more information.
>>> import as_GPS
>>> dir(as_GPS)
['__class__', '__name__', 'const', '__file__', 'LONG', 'modf', 'asyncio', 'DD', 'DMS', 'DM', 'KML', 'KPH', 'MPH', 'KNOT', 'MDY', 'DMY', 'RMC', 'GLL', 'VTG', 'GGA', 'GSA', 'GSV', 'POSITION', 'ALTITUDE', 'DATE', 'COURSE', 'AS_GPS']
>>> 
The same picture on a Fipy. You may try a re-install starting with an erased devices and reloading all code. Use robust tools for upload like filezilla, rshell or pyboard.py, not pymakr.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: asynycio as_GPS

Post by pythoncoder » Tue Jan 07, 2020 7:59 am

I agree with @Roberthh - it looks like an upload problem.
romeotango wrote:
Mon Jan 06, 2020 10:09 am
...Peter Hinch. Isn't he also a motorcyclist?...
I'm intrigued. How did you know that? Alas I had to abandon a lifelong love of bikes owing to health issues.
Peter Hinch
Index to my micropython libraries.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: asynycio as_GPS

Post by Roberthh » Tue Jan 07, 2020 8:11 am

How did you know that? (Motocyclist)
It's in your profile.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: asynycio as_GPS

Post by pythoncoder » Tue Jan 07, 2020 8:15 am

So it is :!:
Peter Hinch
Index to my micropython libraries.

User avatar
romeotango
Posts: 29
Joined: Tue Jun 16, 2015 10:52 am
Location: Germany

Re: asynycio as_GPS

Post by romeotango » Tue Jan 07, 2020 1:20 pm

OKAY,
I have installed a version without r2 on the FiPy with PycomUpdater.
Then reload all as_GPS files from github.
Filezilla:
Content of /fast.io into the directory /lib/uasyncio
From /as_GPS as_GPS.py and the utils were loaded directly into /lib
import as_GPS now shows all in dir(as_GPS)! Hurray!
gps-callback.py starts, but I import as_GPS before asyncio This worked several times, the other way around some times it didn't work.

Full of energy and drive, I then plugged the LoPy onto the expansion board.
Flashed with PycomUpdater with the same version. Reduced baud rate
:x Same procedure as last time.
Import of as_GPS does not succeed.
gps-callback.py: Error can't allocate 138 bytes
Conclusion: Lopy works. My LoPy (LoPy1) is not working.

Question about Flash:
Filesystem: FatFs or LittleFS
Which version do you think is the best?
I am really looking forward to further help.

User avatar
MostlyHarmless
Posts: 166
Joined: Thu Nov 21, 2019 6:25 pm
Location: Pennsylvania, USA

Re: asynycio as_GPS

Post by MostlyHarmless » Tue Jan 07, 2020 6:42 pm

pythoncoder wrote:
Tue Jan 07, 2020 7:59 am
I'm intrigued. How did you know that? Alas I had to abandon a lifelong love of bikes owing to health issues.
Sorry to hear that.

Just in case it is about shifting, maybe take a second look at Scooters (like the one in his Avatar).

I had a Piaggio 50cc 2-stroke (a quarter century ago back in Hamburg, Germany), a TNG Verona (150cc), Kymco Grand Vista (250cc), Yamaha Majesty (400cc) and am now riding a BMW C650GT. And I did ride the last three of them long distance (about 20 times Philly to Toronto/Boston and back). They are very comfortable and have a CVT, so no shifting gears.


Regards, Jan

Post Reply