Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error on Neo-6m-GPS.py #1

Open
OrbisTerrarumProLiberi opened this issue Feb 26, 2020 · 3 comments
Open

Type Error on Neo-6m-GPS.py #1

OrbisTerrarumProLiberi opened this issue Feb 26, 2020 · 3 comments

Comments

@OrbisTerrarumProLiberi
Copy link

TypeError: argument should be integer or bytes-like object, not 'str'

@OrbisTerrarumProLiberi OrbisTerrarumProLiberi changed the title Type Error Type Error on Neo-6m-GPS.py Feb 26, 2020
@YannickLecroart
Copy link

Hi,

You are getting this error message because the parse method from the pynmea2 library expects a string as argument but you are passing bytes.

To solve that issue you need to convert the byte message into string before passing it to the parser as follows:

import serial
import pynmea2



def parseGPS(str_conv):

    if str_conv.find('GGA'): #now you can search for string characters
        msg = pynmea2.parse(str_conv) #if found use parser
        print("Timestamp: %s -- Lat: %s %s -- Lon: %s %s -- Altitude: %s %s" % (msg.timestamp,msg.lat,msg.lat_dir,msg.lon,msg.l$

 
while True:

    serialPort = serial.Serial("/dev/serial0", 9600, timeout=0.5)
    str = serialPort.readline()
    str_conv = str.decode('utf-8').strip() #convert bytes to string

    try:

        parseGPS2(str_conv)

    except:

        continue

Hope it helps!

Regards,

@maximilianwank
Copy link

maximilianwank commented Aug 25, 2020

Hi, I forked the project because I wanted to work on the Python part of the repo. In particular, my plan is to remove the dependency to pynmea2. Unfortunately, at the moment I have not too much to work on that but I will definitely fix it on a long run. I will let you guys know when I'm ready for a pull request ;-)

@FranzTscharf
Copy link
Owner

yes please let me know. This repo is just a collection of useful code for the Neo-6m because I didn't find as many useful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants