Well it has been far to long since I wrote anything. This is a project I did back in November of 2016, so it isn’t too far in the Wayback Machine. I wanted a GPS location device for a Emergency Shelter webpage server and I wanted it to display it’s current coordinates. This happened to be implemented on a Pi-2 (not sure if it was a B model). Anyway this unit is for the Pi-2 from the Adafruit.com site at: https://www.adafruit.com/products/746 I personally think it was a bit pricey, but everyone needs to make a little to stay in business.

I chose this one since they had a tutorial and the fact like most of us I’m basically lazy. This particular unit is to be implemented on a Broadband Hamnet network, but that is more information than you require since it will work on any Pi-2 Ethernet/WiFi connection. Now Laydada has provided a Tutorial and it is quite complete. I chose to implement their tutorial, but I did not prefer to connect to another system to get information online since this is an Emergency Shelter location and the device most likely would not have Internet Access under its condition. I believe the site was initialstate.com at that time.

I did do all the setup for the initialstate stuff and figured out that would not quite work for what I wanted, but it did load all the software needed except for the part I wanted. I have been programming for years and find programming in python a boring of a language and very rigid in its formatting (indention’s) way; they should get away from restricted forms of coding. I thought they did with Java and Object Oriented C. None the less I used it and since I wasn’t interested in learning all its nuances I just fudged it and got things to work. So I will pickup my understanding after the previous Tutorials have been done and all the necessary software and library’s have been installed.

Lets start off with the simplest code that they provided and expand from there. So here is the gps.py provided. Note I am not taking any credit from the original authors and this is just to help

******************************************************************************

My perl script follows:

 

#!/usr/bin/env python

import serial

#####Global Variables################################
#be sure to declare the variable as ‘global var’ in the fxn

ser = 0

posfix = ”
satellites = ”
longtitude = ”
latitude = ”
dirlat = ”
dirlon = ”
altitude = ”
count = 0
timenow = ”

#####FUNCTIONS##################################
#initialize serial connection

def init_serial():
# COMNUM = 9 #set you COM port # here
global ser #must be declared in each fxn used
ser = serial.Serial()
ser.baudrate = 9600
# ser.port = COMNUM – 1 #starts at 0, so subtract 1
ser.port = ‘/dev/ttyAMA0’ #uncomment for linux

#you must specify a timeout (in seconds) so that the
# serial port doesn’t hang
ser.timeout = 1
ser.open() #open the serial port

# print port open or closed – uncomment if testing
# if ser.isOpen():
# print ‘Open: ‘ + ser.portstr
# else:
# print ‘Closed: ‘ + ser.portstr
#####SETUP#####################################
#this is a good spot to run your initializations

init_serial()

#####MAIN LOOP#################################

while 1:
#prints what is sent in on the serial port
bytes = ser.readline() #reads in bytes followed by a newline
if bytes[18:21].isdigit(): # check to see if the string has digits
# loop if not
# print ‘Received: ‘ + bytes #print to the console
# print ‘Parsed:’

timenow = bytes[7:13] # probably use later
print ‘GPS Time:’,
print timenow[0:2] + u’\N{COLON}’ + timenow[2:4] + u’\N{COLON}’ +timenow[4:6] + ‘ UTC’

for count in range(53,60):
if bytes[count] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’

posfix = bytes[43] # get the Fix Quality type
satellites = bytes[45:46] # get number of current Satellites
if posfix == 0:
print ‘GPS fix by: Invalid ‘ + posfix # fix quality = 0
elif posfix == 2:
print ‘GPS fix by: DGPS ‘ + posfix # fix quality = 2
else:
print ‘GPS fix by: GPS ‘ + posfix # fix quality G= 1 good
print ‘Using ‘ + u’\N{NUMBER SIGN}’ + ‘ Satellites: ‘ + satellites
latitude = bytes[18:26] # positional info for latitude
dirlat = bytes[28] # direction of latitude
print ‘Lat: ‘ + latitude + ‘ ‘ + dirlat
longtitude = bytes[31:39] # positional posistion of longtitude
dirlon = bytes[41] # direction of longitude
print ‘Lon: ‘ + longtitude + ‘ ‘ + dirlon
for count0 in range(53,60):
if bytes[count0] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’
# print ‘Position: ‘, count0 # used for debugging
print ‘Altitude: ‘ + altitude
break # we are now through so break out of while
#hit ctr-c to close python window

************************************************************************

OK lets walk through some of this. The first part sets up the Global Variables as described.

ser = 0

posfix = ”
satellites = ”
longtitude = ”
latitude = ”
dirlat = ”
dirlon = ”
altitude = ”
count = 0
timenow = ”

Now we move to functions

#initialize serial connection

def init_serial():
# COMNUM = 9 #set you COM port # here
global ser #must be declared in each fxn used
ser = serial.Serial()
ser.baudrate = 9600
# ser.port = COMNUM – 1 #starts at 0, so subtract 1
ser.port = ‘/dev/ttyAMA0’ #uncomment for linux

#you must specify a timeout (in seconds) so that the
# serial port doesn’t hang
ser.timeout = 1
ser.open() #open the serial port

Then they run the initialization to set things up.

init_serial()

Then we get to the main loop of the program and it continually loops till it gets to the altitude and then breaks out after reading it and displaying.

#####MAIN LOOP#################################

while 1:
#prints what is sent in on the serial port
bytes = ser.readline() #reads in bytes followed by a newline
if bytes[18:21].isdigit(): # check to see if the string has digits
# loop if not
# print ‘Received: ‘ + bytes #print to the console
# print ‘Parsed:’

timenow = bytes[7:13] # probably use later
print ‘GPS Time:’,
print timenow[0:2] + u’\N{COLON}’ + timenow[2:4] + u’\N{COLON}’ +timenow[4:6] + ‘ UTC’

for count in range(53,60):
if bytes[count] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’

posfix = bytes[43] # get the Fix Quality type
satellites = bytes[45:46] # get number of current Sattelites
if posfix == 0:
print ‘GPS fix by: Invalid ‘ + posfix # fix quality = 0
elif posfix == 2:
print ‘GPS fix by: DGPS ‘ + posfix # fix quality = 2
else:
print ‘GPS fix by: GPS ‘ + posfix # fix quality G= 1 good
print ‘Using ‘ + u’\N{NUMBER SIGN}’ + ‘ Satellites: ‘ + satellites
latitude = bytes[18:26] # positional info for latitude
dirlat = bytes[28] # direction of latitude
print ‘Lat: ‘ + latitude + ‘ ‘ + dirlat
longtitude = bytes[31:39] # positional posistion of longtitude
dirlon = bytes[41] # direction of longitude
print ‘Lon: ‘ + longtitude + ‘ ‘ + dirlon
for count0 in range(53,60):
if bytes[count0] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’
# print ‘Position: ‘, count0 # useed for debugging
print ‘Altitude: ‘ + altitude
break # we are now through so break out of while
#hit ctr-c to close python window

So their isn’t a lot to it, but can cause a lot of problems if you mistype or not follow directions very closely. Something I noticed was in my future dealings with the created /dev/ttyAMA0 serial port I ad problems getting things to work with the settings of the port. IE, only root could get access to it all the time, so I changed it from:

crw—— 1 root dialout 204, 64 Apr 2 11:00 /dev/ttyAMA0

to:

crw-rw-rw- 1 root dialout 204, 64 Apr 2 11:00 /dev/ttyAMA0

by being super user and doing the following:

chmod 766 /dev/ttyAMA0

Before changing be sure to note down what its original state was. The 766 changed the bits in the following manor. 7 is rwx (r = read, w w= write and x = execute (run). so the 7 is read,write,execute and the 6 is read, write only.

******************************************************************************

Now the received string from:

/dev/ttyAMA0

I get:

$GPGGA,145042.000,2838.9667,N,08119.9112,W,1,09,0.91,19.0,M,-31.1,M,,*6A

 Now if you notice in the character position in the string  position[7 to 13] is the time
string. In positions [18 to 26] is the Latitude of (2838.9667) with byte [28] being
position of the (East or West). With characters in the positions [31 to 39] the Longitude
and in position [41] being the position of [North or South]. There is a bunch of
information in the GPS string and can be parsed and printed in most any manor you
desire. Now for me I did not want 2838.9667 N and 08119.9112 W for my display. I must admit
I had another reason and that was I use YAAC (Yet Another APRS Client) on my Pi-3 for
APRS (Amateur Radio Positioning), I deeded it to read 
ow I wan't wanting everything so I paired down the main loop code a bit. in doing so,
I took the easy way out and just commented out the lines I did not want to execute to just:

#####MAIN LOOP###############################

while 1:
#prints what is sent in on the serial port
bytes = ser.readline() #reads in bytes followed by a newline
if bytes[18:21].isdigit(): # check to see if the string has digits
# loop if not
# print ‘Received: ‘ + bytes #print to the console
# print ‘Parsed:’

timenow = bytes[7:13] # probably use later

# print ‘GPS Time:’,
# print timenow[0:2] + u’\N{COLON}’ + timenow[2:4] + u’\N{COLON}’ +timenow[4:6] + ‘ UTC’

for count in range(53,60):
if bytes[count] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’

posfix = bytes[43] # get the Fix Quality type
# satellites = bytes[45:46] # get number of current Satellites
# if posfix == 0:
# print ‘GPS fix by: Invalid ‘ + posfix # fix quality = 0
# elif posfix == 2:
# print ‘GPS fix by: DGPS ‘ + posfix # fix quality = 2
# else:
# print ‘GPS fix by: GPS ‘ + posfix # fix quality G= 1 good
# print ‘Using ‘ + u’\N{NUMBER SIGN}’ + ‘ Satellites: ‘ + satellites
latitude = bytes[18:26] # positional info for latitude
dirlat = bytes[28] # direction of latitude
# print ‘Lat: ‘ + latitude + ‘ ‘ + dirlat
longtitude = bytes[31:39] # positional posistion of longtitude
dirlon = bytes[41] # direction of longitude
print ‘Lat: ‘ + latitude + ‘ ‘ + dirlat + ‘ Lon: ‘ + longtitude + ‘ ‘ + dirlon
for count0 in range(53,60):
if bytes[count0] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’
# print ‘Position: ‘, count0 # useed for debugging
print ‘Altitude: ‘ + altitude
break # we are now through so break out of while
#hit ctr-c to close python window

This now gives me out the data I wanted to:

Lat: 2838.958 N Lon: 8119.919 W
Altitude: 31.2

Now that is short and sweet.

But this want’s a format I can easily relate to so onward and??? Who knows if this is up or down! I needed a DEG MIN SEC format for me to easily equate in my world so I did what I call cheating math and look at one single problem at a time and resolve it. So in included a crude conversion section from DEG.Minutes to DEG MIN SEC.

************************************************************************

Credits:

I obtained the conversion information from:
http://http://www.directionsmag.com/site/latlong-converter/
and
http://mathforum.org/sarah/hamilton/ham.degrees.html

So they get the credit, not me. I just implemented their ideas.

 

 Most of the changes I did in the software was in the Main loop and maybe add in a few
global variables where needed. I have my files located in script/gps.py from my home
directory with permission bits set to 755, root has rwx, group has r-x and user had r-x
to allow them to run. BTW most of my Linux machines are using Ubuntu 16.04 or newer.
The gps.py when ran shows an output like:

Lat: 28 Min: 38 Sec: 57.84 W
Lon: 81 Min: 19 Sec: 55.08 N

 For me I just went to a few sites on the internet and saw what and how they were
converting and did likewise in my conversion area of the code.

 The code:

Degrees = str(int(float(latitude) / 100))
minutes = str(int(((float(latitude) / 100) - int(Degrees)) * 100))
tmp = str((float(latitude) - (int(Degrees) * 100)) - int(minutes))
seconds = str((float(tmp) * 60))

Breaks down:
Degrees = str(int(float(latitude) / 100))
Takes the str (string) of "latitude" and first converts it to a float with float(latitude)
then divided it by 100. Now we have it divided by 100 we convert it to an int (integer)
and with int((float(latitude) / 100)) it drops off the decimal point leaving the 28 in
this case. now we have an integer I out it back to a string by casting it with str(xxxxxx)
then storing it into the variable Degrees
minutes = str(int(((float(latitude) / 100) - int(Degrees)) * 100)) follows the same idea,
by drooping off everything just link in Degree, but then I cast the Degrees to an 
int(Degrees) and subtract giving us something like a float of .389667 then multiplying it
by 100 giving us 38.9667. Again casting it to an integer and dropping off the float part
giving us 38 degrees.

tmp = str((float(latitude) - (int(Degrees) * 100)) - int(minutes)) following along the
same path I store in the following into a string of tmp. now it would have been easier to
take the string 2838.9667 cast it to a float then cast to integer then subtract it from
the original string to get the minutes, but I wanted to stay consistent and take the
int(Degrees * 100) subtracting it from the original string and subtracting the Minutes
with int(minutes) to get .9667 then storing it to tmp.
seconds = str((float(tmp) * 60)) and then dividing tmp by 60 to get seconds.

 Note that it the original latitude or longitude was stored in strings so I kept every 
conversion to store them back to strings. As for the Longitude, same was as the Latitude,
just get everything from the original string and go with it.

 GPS Time: 21:10:32 UTC
 GPS fix by: GPS 1
 Using # Satellites: 0
 Lat: 2838.959 N
 Lon: 8119.919 W
 Altitude: 28.3

#####MAIN LOOP######################################

while 1:
#prints what is sent in on the serial port
bytes = ser.readline() #reads in bytes followed by a newline
if bytes[18:21].isdigit(): # check to see if the string has digits
# loop if not

timenow = bytes[7:13] # probably use later

for count in range(53,60):
if bytes[count] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’

posfix = bytes[43] # get the Fix Quality type
latitude = bytes[18:26] # positional info for latitude
dirlat = bytes[28] # direction of latitude
longtitude = bytes[31:39] # positional posistion of longtitude
dirlon = bytes[41] # direction of longitude
print ‘Lat: ‘ + latitude + ‘ ‘ + dirlat + ‘ Lon: ‘ + longtitude + ‘ ‘ + dirlon

# conversion area. Lat 2838.961 to 28:38:57.xx
Degrees = str(int(float(latitude) / 100))
minutes = str(int(((float(latitude) / 100) – int(Degrees)) * 100))
tmp = str((float(latitude) – (int(Degrees) * 100)) – int(minutes))
seconds = str((float(tmp) * 60))
print ‘Lat: ‘ + Degrees + ‘ Min: ‘ + minutes + ‘ Sec: ‘ + seconds + ‘ ‘ + dirlon

Degrees = str(int(float(longtitude) / 100))
minutes = str(int(((float(longtitude) / 100) – int(Degrees)) * 100))
tmp = str((float(longtitude) – (int(Degrees) * 100)) – int(minutes))
seconds = str((float(tmp) * 60))
print ‘Lon: ‘ + Degrees + ‘ Min: ‘ + minutes + ‘ Sec: ‘ + seconds + ‘ ‘ + dirlat

# from decimas degrees of GPS info.
for count0 in range(53,60):
if bytes[count0] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’
print ‘Altitude: ‘ + altitude
break # we are now through so break out of while
#hit ctr-c to close python window

And the following is what I sort of wanted:

Lat: 2838.964 N Lon: 8119.918 W
Lat: 28 Min: 38 Sec: 57.84 W
Lon: 81 Min: 19 Sec: 55.08 N

Now I have done several versions so they could be placed in my webpage using perl cgi formats. I am not going to go through them, but will show my cgi-bin/update.pl webpage code for testing of my Emergency Shelter webpage: The following is the complete code for my testing code of the server. BTW it is an apache 2.4 server which I run of both my home and the broadband servers.

***************************************************************************

#!/usr/bin/perl -w

# if your system’s Perl interpreter is not located in /usr/local/perl

print(<<END);
Content-type: text/html;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<HTML>
<HEAD>
<TITLE>Emergency Shelter Info Page</TITLE>
<meta name=”viewport” content=”width=device-width, initial-scale=1″ />
<meta name=”author” content=”Benny D. Miller Jr – w4qed” /> <!– Benny D. Miller Jr ARS w4qed
<link href=”css/print.css” rel=”stylesheet” type=”text/css” media=”print” />
<link href=”css/screen.css” rel=”stylesheet” type=”text/css” media=”screen, projection” />
<!–[if lte IE 6]><link rel=”stylesheet” href=”css/ielte6.css” type=”text/css” media=”screen” /><![endif]–>

</HEAD>
<BODY>
<CENTER>
<H2>Emergency Shelter Information System</H2>
<H3>Provided by: The Central Florida Broadband HamNET Group.</H3>
END
system(‘uptime’);
print(<<END);
<br>
END
system(“hostname -s”);

print(<<END);

<BR>
END
system(‘/home/w4qed/script/gps.pos.py’);

print(<<END);
<BR>
END
system(‘/home/w4qed/script/gps.pos.lat.deg.min.sec.py’);

#print(<<END);
# <BR>
#END
system(‘/home/w4qed/script/gps.pos.lon.deg.min.sec.py’);

print(<<END);

<BR>
</CENTER>
<h1>Memory Info</h1>
<PRE>
END

system(“free -m”);

print(<<END);
</PRE>
<h1>Disk Usage:</h1>
<PRE>
END
system(“du -H”);

print(<<END);
</PRE>
<h1>Disk Info:</h1>
<PRE>
END

system(“df -H”);

print(<<END);
</PRE>
<h1>Logged in user</h1>
<PRE>
END

system(“who | awk ‘{print $1}’ | sort | uniq”);
print(<<END);
</PRE>
<H1>GPS Information:</H1>
<PRE>
END

system(“/home/w4qed/script/gps.update.py”);

print(<<END);
</PRE>
<CENTER>Information generated on
END
system(“date -u”);

print(<<END);
</CENTER>

<h1>ifconfig:</h1>

END
system(“ifconfig”);
print(<<END);
</CENTER>

</BODY>
</HTML>
END
exit;

The above also shows how in perl cgi script you can execute commands using the system(cmd); code. I have not included the css style sheets as they probably won’t be necessary. The above starts off with defining it is a perl shell script and it builds a webpage as a print function

print(<<END)

Treat it as a perl print till you find a corresponding:

END

after the end it is basic perl coding for commands such as:

system(‘/home/user/script/gps.pos.py’);

Now the additional gps.pos.lxx.deg.min.sec.py code follows and is basically just modified code from previous information. (lxx being lat or lon)

gps.pos.lat.deg.min.sec.py

*************************************************************************

#!/usr/bin/env python

import serial

#####Global Variables################################
#be sure to declare the variable as ‘global var’ in the fxn

ser = 0

posfix = ”
satellites = ”
longtitude = ”
latitude = ”
dirlat = ”
dirlon = ”
altitude = ”
count = 0
timenow = ”

# got conversion from:
# http://http://www.directionsmag.com/site/latlong-converter/
# and
# http://mathforum.org/sarah/hamilton/ham.degrees.html

# Degrees Minutes Seconds to Degrees Minutes.m
# Degrees = Degrees
# Minutes.m = Minutes + (Seconds / 60)

# Degrees Minutes.m to Decimal Degrees
# .d = M.m / 60
# Decimal Degrees = Degrees + .d
Degrees = ”
Minutes = ”
Minutes_m = ”
dot_d = ”
minutes = ”
seconds = ”
tmp = ”
temp2 = ”

DM_s = ”
DM_m = ”
DM_d = ”

#####FUNCTIONS######################################
#initialize serial connection

def init_serial():
# COMNUM = 9 #set you COM port # here
global ser #must be declared in each fxn used
ser = serial.Serial()
ser.baudrate = 9600
# ser.port = COMNUM – 1 #starts at 0, so subtract 1
ser.port = ‘/dev/ttyAMA0’ #uncomment for linux

#you must specify a timeout (in seconds) so that the
# serial port doesn’t hang
ser.timeout = 1
ser.open() #open the serial port
#####SETUP####################################
#this is a good spot to run your initializations

init_serial()

#####MAIN LOOP##############################

while 1:
#prints what is sent in on the serial port
bytes = ser.readline() #reads in bytes followed by a newline
if bytes[18:21].isdigit(): # check to see if the string has digits
# loop if not

timenow = bytes[7:13] # probably use later

for count in range(53,60):
if bytes[count] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’

posfix = bytes[43] # get the Fix Quality type
latitude = bytes[18:26] # positional info for latitude
dirlat = bytes[28] # direction of latitude
longtitude = bytes[31:39] # positional posistion of longtitude
dirlon = bytes[41] # direction of longitude
# print ‘Lat: ‘ + latitude + ‘ ‘ + dirlat + ‘ Lon: ‘ + longtitude + ‘ ‘ + dirlon

# conversion area. Lat 2838.961 to 28:38:57.xx

Degrees = str(int(float(latitude) / 100))
minutes = str(int(((float(latitude) / 100) – int(Degrees)) * 100))
tmp = str((float(latitude) – (int(Degrees) * 100)) – int(minutes))
seconds = str((float(tmp) * 60))
print ‘Lat: ‘ + Degrees + ‘ Min: ‘ + minutes + ‘ Sec: ‘ + seconds + ‘ ‘ + dirlon

# from decimas degrees of GPS info.
for count0 in range(53,60):
if bytes[count0] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’
# print ‘Altitude: ‘ + altitude
break # we are now through so break out of while
#hit ctr-c to close python window

****************************************************************************

and gps.pos.lon.deg.min.sec.py :

****************************************************************************

#!/usr/bin/env python

import serial

#####Global Variables############################
#be sure to declare the variable as ‘global var’ in the fxn

ser = 0

posfix = ”
satellites = ”
longtitude = ”
latitude = ”
dirlat = ”
dirlon = ”
altitude = ”
count = 0
timenow = ”

# got conversion from:
# http://http://www.directionsmag.com/site/latlong-converter/
# and
# http://mathforum.org/sarah/hamilton/ham.degrees.html

# Degrees Minutes Seconds to Degrees Minutes.m
# Degrees = Degrees
# Minutes.m = Minutes + (Seconds / 60)

# Degrees Minutes.m to Decimal Degrees
# .d = M.m / 60
# Decimal Degrees = Degrees + .d
Degrees = ”
Minutes = ”
Minutes_m = ”
dot_d = ”
minutes = ”
seconds = ”
tmp = ”
temp2 = ”

DM_s = ”
DM_m = ”
DM_d = ”

#####FUNCTIONS#################################
#initialize serial connection

def init_serial():
# COMNUM = 9 #set you COM port # here
global ser #must be declared in each fxn used
ser = serial.Serial()
ser.baudrate = 9600
# ser.port = COMNUM – 1 #starts at 0, so subtract 1
ser.port = ‘/dev/ttyAMA0’ #uncomment for linux

#you must specify a timeout (in seconds) so that the
# serial port doesn’t hang
ser.timeout = 1
ser.open() #open the serial port
#####SETUP####################################
#this is a good spot to run your initializations

init_serial()

#####MAIN LOOP################################

while 1:
#prints what is sent in on the serial port
bytes = ser.readline() #reads in bytes followed by a newline
if bytes[18:21].isdigit(): # check to see if the string has digits
# loop if not

timenow = bytes[7:13] # probably use later

for count in range(53,60):
if bytes[count] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’

posfix = bytes[43] # get the Fix Quality type
latitude = bytes[18:26] # positional info for latitude
dirlat = bytes[28] # direction of latitude
longtitude = bytes[31:39] # positional posistion of longtitude
dirlon = bytes[41] # direction of longitude
# print ‘Lat: ‘ + latitude + ‘ ‘ + dirlat + ‘ Lon: ‘ + longtitude + ‘ ‘ + dirlon

# conversion area. Lat 2838.961 to 28:38:57.xx

Degrees = str(int(float(latitude) / 100))
minutes = str(int(((float(latitude) / 100) – int(Degrees)) * 100))
tmp = str((float(latitude) – (int(Degrees) * 100)) – int(minutes))
seconds = str((float(tmp) * 60))
print ‘Lat: ‘ + Degrees + ‘ Min: ‘ + minutes + ‘ Sec: ‘ + seconds + ‘ ‘ + dirlon

# from decimas degrees of GPS info.
for count0 in range(53,60):
if bytes[count0] == ‘,’:
altitude = bytes[53:count]
break
else:
altutude = ‘not defined’
# print ‘Altitude: ‘ + altitude
break # we are now through so break out of while
#hit ctr-c to close python window

*************************************************************************

Here is what the output of the page looks like:

Emergency Shelter Information System

Provided by: The Central Florida Broadband HamNET Group.

17:56:43 up 3 days, 6:56, 3 users, load average: 0.01, 0.03, 0.05
n4eh-RPi-2b Page last modified on 04/05/2017 17:56:45
Lat: 2838.958 N Lon: 8119.926 W Altitude: 35.9
Lat: 28 Min: 38 Sec: 57.48 W Lon: 81 Min: 19 Sec: 55.5 N Altitude: 35.9m

Memory Info

              total        used        free      shared  buff/cache   available
Mem:            925         484          26          72         414         339
Swap:             0           0           0

Disk Usage:

12	./pageCounter
4	./nr10_edited/img
4	./nr10_edited/css
12	./nr10_edited
252	./img
40	./css
1184	.

Disk Info:

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.8G  4.6G  3.2G  59% /
devtmpfs        481M     0  481M   0% /dev
tmpfs           486M  439k  485M   1% /dev/shm
tmpfs           486M   50M  436M  11% /run
tmpfs           5.3M  4.1k  5.3M   1% /run/lock
tmpfs           486M     0  486M   0% /sys/fs/cgroup
/dev/mmcblk0p1   68M   21M   47M  32% /boot
tmpfs            98M   29k   98M   1% /run/user/1000

Logged in user

w4qed    pts/1        Apr  5 16:11 (192.168.1.12)
w4qed    pts/2        Apr  5 16:13 (192.168.1.12)
w4qed    tty7         Apr  2 11:00 (:0)

GPS Information:

Open: /dev/ttyAMA0
Received: $GPGGA,215648.000,2838.9582,N,08119.9257,W,1,08,1.05,35.9,M,-31.1,M,,*60

Parsed:
GPS Time: 21:56:48 UTC
GPS fix by: GPS 1
Using # Satellites: 0
Lat: 2838.958 N
Lon: 8119.925 W
Altitude: 35.9

Information generated on Wed Apr 5 21:56:48 UTC 2017

ifconfig:

enxb827eba7966b Link encap:Ethernet HWaddr b8:27:eb:a7:96:6b inet addr:10.6.39.188 Bcast:10.6.39.191 Mask:255.255.255.248 inet6 addr: fe80::7683:533e:b1df:840b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3001625 errors:0 dropped:0 overruns:0 frame:0 TX packets:2381109 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:469584888 (469.5 MB) TX bytes:1155611737 (1.1 GB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:19702 errors:0 dropped:0 overruns:0 frame:0 TX packets:19702 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1816349 (1.8 MB) TX bytes:1816349 (1.8 MB)

I’ve noticed that when the server gets hit several times doing refreshes or other things, the data comes back erratic and not complete. Perhaps I should do something like read the data and store it to a file, then have the webpage read the file. That makes it more complicated than necessary.Note I go to my main Pi-3 for getting a Camera picture out the Ham/Computer shack window.

That about sums it up. If you have any questions, feel free to contact me here. If you have constructive comments I would like to read them and improve my coding. So for now:

QED.

 

Advertisements