JarvisSan22 / OPC-N3_python

Python repository for OPCN3 and OPCN2 on RPI3
GNU General Public License v3.0
12 stars 8 forks source link

python 3 versus 2 #2

Open kyussinchains opened 4 years ago

kyussinchains commented 4 years ago

Hello Daniel,

Your work has been a godsend! I'm trying to replicate what you've done almost exactly, however I'm having the issue that the start.py code throws up an error when run in python 2, but runs happily in python 3, however when I set GPS mode, the GPS code only runs in python 2.....

any suggestions?

JarvisSan22 commented 4 years ago

Hi kyussinchains

Thanks for your message. I checked over the code for the GPS and there was few python 2 formatted prints I have updated, but also think the issue may come from the "run" functions in GPS2.py

def run(self): global gpsd while gpsp.running: gpsd.next() #this will continue to loop and grab EACH set of gpsd info to clear the buffer

After a quick check, the issue may by the .next() command not working in python3 the same was as python2 https://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html

Sadly I currently don't have an RPI3 at hand to test the code. Could you please test if its this is the cause?

kind regards Daniel Jarvis

kyussinchains commented 4 years ago

Hi Daniel,

I tried the new version and I am running up against the same error, the issue seems to be that there is no gps header to import under python 3, so the main start.py code runs under python 3 (I get various struct.unpack errors under python 2) but the GPS code runs under python 2, it seems both will run independently, but not together.... have you managed to get the code running in GPS mode during your testing?

best regards Simon