I am writing an article for the first time, mainly records the process of this code, the requirements of the teacher is on the nano version of reading to the GPS data from the python and parses the latitude and longitude, the rate and the number of satellite late by GUI graphical and less on the reading of the GPS in the nano tutorial, there are also the article use the GPS module but is not conducive to I work late, so their imitation has written a series of simple code.
first download and install cutecom to see if nano has read the GPS data. Use the command:
sudo apt-get install cutecom
is followed by Nano installation of pthon3-serial and pynmea2.
I remember using sudo apt-get intsall python3-serial last night, but PIP install pyserial
is also available online
as for which can try by itself, I think this process is not important, as long as pyserial is installed successfully, pyserial is understood to be python serial communication module, through which we can read the serial port tool.
for installation of pynmea2I want to mention that the file PIP is not found with PIP, but rather we use python3 and PIP should be called pip3 so that the installation is successful. Pynmea2 is understood as a third party module for handling the NMEA 0183 protocol. Used by us to resolve the NAME 0183 protocol. http://gnss.help/2018/03/01/pynmea2-readme/index.html this is my reference page. And then you write your own code.
is first to import two downloaded modules, followed by import time module, I don’t know what is the use is to follow them to add.
the ser is a serial port assignment in ser (about this), the first one is behind your serial port of the serial port is usually ttyTHS1 USB is usually ttyUSB0 these names should be available through cutecom, the second is the baud rate I use the default 115200 online is a lot of the people followed 9600 change, the timeout I followed others change, I feel it doesn’t matter how much I feel OK. This is followed by a while statement. Line 8 USES pyserial to read the serial data and assign it to the line variable, line 9 because line reads bytes and then needs to be changed to a string (that’s about it), followed by the GPRMC in the two if statements. This is what you read using GPS, line 11 USES pynmea2.parse () to parse
let me mention why I use this instead of using lists like many other tutorials on the web. The main reason is that I think GPS signals can be unstable and lead to parsing errors. This method is also very useful, but I just don’t know if it will go wrong. If you add a break at the end of the if statement, you can stop the loop, because there are two if statements here. We’d better add a break at the second if. If you add a break at the first if, it will make the second if unusable, then it will just exit the while statement.
p>
18 is saved into TXT file at the beginning, mainly I have been written in a+ way, at the beginning I was using W or W+ to try to find TXT only GPGGA data after the interview. 19 changed to STR, because Python can only be a string, 20 is a blank line, 21 needs to be saved.
p>
p>
. Well, that’s about it. I won’t go into much detail. Don’t understand can go baidu once. First time write success, go to the next refueling!
Read More:
- Error in installing torch vision or pilot on Linux or Jetson nano: the headers or library files could not be found for JPEG
- pandas parse_ Data exception, automatically skip
- Unable to read meta data for class
- Python failed to read TIF file exported by envi.
- Coursera Using python to access Web data quiz 4
- Mixing iteration and read methods would lose data
- java.lang.IllegalStateException : unable to read meta data for class
- Pandas read_ Error in json() valueerror: training data
- Quirky error 18: transfer closed with outstanding read data rem
- Depending on the custom component jar package, unable to read meta data for class appears after startup
- Python conversion hex to string, high and low data processing
- Python data analysis dataframe converts dates to weeks
- Solve the problem of unable to locate package python3.6 when upgrading from python3.5 to python3.6 in ubantu16.04
- Python export data (CSV format)
- Data analysis to obtain Yahoo stock data: some problems are encountered when using panda datareader (cannot import name ‘is_ list_ Like ‘problem)
- Add a new springboot, and it will appear unable to read meta data for class when it is dependent
- C + + programming fault handling — error: assignment of read only data member ‘STD:: pair
- Interesting undefined columns selected from read.table and read.csv
- Python Numpy.ndarray ValueError:assignment destination is read-only
- [leetcode] 295. Find Median from Data Stream Python