Allow RMC Sentences with no course data

pull/28/head
Calvin McCoy 2018-12-04 19:47:09 -08:00
rodzic 77c6705513
commit f67aeb93bb
2 zmienionych plików z 31 dodań i 13 usunięć

Wyświetl plik

@ -242,7 +242,10 @@ class MicropyGPS(object):
# Course
try:
course = float(self.gps_segments[8])
if self.gps_segments[8]:
course = float(self.gps_segments[8])
else:
course = 0.0
except ValueError:
return False

Wyświetl plik

@ -15,46 +15,61 @@ test_RMC = ['$GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62\
'$GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68\n',
'$GPRMC,180041.896,A,3749.1851,N,08338.7891,W,001.9,154.9,240911,,,A*7A\n',
'$GPRMC,180049.896,A,3749.1808,N,08338.7869,W,001.8,156.3,240911,,,A*70\n',
'$GPRMC,092751.000,A,5321.6802,N,00630.3371,W,0.06,31.66,280511,,,A*45\n']
'$GPRMC,092751.000,A,5321.6802,N,00630.3371,W,0.06,31.66,280511,,,A*45\n',
'$GPRMC,193448.00,A,3746.2622056,N,12224.1897266,W,0.01,,041218,,,D*58\n',
'$GPRMC,193449.00,A,3746.2622284,N,12224.1897308,W,0.01,,041218,,,D*5D\n']
rmc_parsed_strings = [['GPRMC', '081836', 'A', '3751.65', 'S', '14507.36', 'E', '000.0', '360.0', '130998', '011.3', 'E', '62'],
['GPRMC', '123519', 'A', '4807.038', 'N', '01131.000', 'E', '022.4', '084.4', '230394', '003.1', 'W', '6A'],
['GPRMC', '225446', 'A', '4916.45', 'N', '12311.12', 'W', '000.5', '054.7', '191194', '020.3', 'E', '68'],
['GPRMC', '180041.896', 'A', '3749.1851', 'N', '08338.7891', 'W', '001.9', '154.9', '240911', '', '', 'A', '7A'],
['GPRMC', '180049.896', 'A', '3749.1808', 'N', '08338.7869', 'W', '001.8', '156.3', '240911', '', '', 'A', '70'],
['GPRMC', '092751.000', 'A', '5321.6802', 'N', '00630.3371', 'W', '0.06', '31.66', '280511', '', '', 'A', '45']]
rmc_crc_values = [0x62, 0x6a, 0x68, 0x7a, 0x70, 0x45]
['GPRMC', '092751.000', 'A', '5321.6802', 'N', '00630.3371', 'W', '0.06', '31.66', '280511', '', '', 'A', '45'],
['GPRMC', '193448.00', 'A', '3746.2622056', 'N', '12224.1897266', 'W', '0.01', '', '041218', '', '', 'D', '58'],
['GPRMC', '193449.00', 'A', '3746.2622284', 'N', '12224.1897308', 'W', '0.01', '', '041218', '', '', 'D', '5D']]
rmc_crc_values = [0x62, 0x6a, 0x68, 0x7a, 0x70, 0x45, 0x58, 0x5D]
rmc_longitude = [[145, 7.36, 'E'],
[11, 31.0, 'E'],
[123, 11.12, 'W'],
[83, 38.7891, 'W'],
[83, 38.7869, 'W'],
[6, 30.3371, 'W']]
[6, 30.3371, 'W'],
[122, 24.1897266, 'W'],
[122, 24.1897308, 'W']]
rmc_latitude = [[37, 51.65, 'S'],
[48, 7.038, 'N'],
[49, 16.45, 'N'],
[37, 49.1851, 'N'],
[37, 49.1808, 'N'],
[53, 21.6802, 'N']]
[53, 21.6802, 'N'],
[37, 46.2622056, 'N'],
[37, 46.2622284, 'N']]
rmc_utc = [(8, 18, 36.0),
(12, 35, 19.0),
(22, 54, 46.0),
(18, 0, 41.896),
(18, 0, 49.896),
(9, 27, 51.0)]
(9, 27, 51.0),
(19, 34, 48.0),
(19, 34, 49.0)]
rmc_speed = [[0.0, 0.0, 0.0],
[22.4, 25.7824, 41.4848],
[0.5, 0.5755, 0.926],
[1.9, 2.1869, 3.5188],
[1.8, 2.0718, 3.3336],
[0.06, 0.06906, 0.11112]]
[0.06, 0.06906, 0.11112],
[0.01, 0.011510000000000001, 0.018520000000000002],
[0.01, 0.011510000000000001, 0.018520000000000002]]
rmc_date = [(13, 9, 98),
(23, 3, 94),
(19, 11, 94),
(24, 9, 11),
(24, 9, 11),
(28, 5, 11)]
rmc_course = [360.0, 84.4, 54.7, 154.9, 156.3, 31.66]
rmc_compass = ['N', 'E', 'NE', 'SSE', 'SSE', 'NNE']
(28, 5, 11),
(4, 12, 18),
(4, 12, 18)]
rmc_course = [360.0, 84.4, 54.7, 154.9, 156.3, 31.66, 0.0, 0.0]
rmc_compass = ['N', 'E', 'NE', 'SSE', 'SSE', 'NNE', 'N', 'N']
test_VTG = ['$GPVTG,232.9,T,,M,002.3,N,004.3,K,A*01\n']
test_GGA = ['$GPGGA,180050.896,3749.1802,N,08338.7865,W,1,07,1.1,397.4,M,-32.5,M,,0000*6C\n']
@ -360,7 +375,7 @@ def test_logging():
with open('test.txt', 'rb') as log_file:
log_hash = hashlib.md5()
log_hash.update(log_file.read())
assert log_hash.digest() == b'\x8e\xe4\x29\x5a\xad\xf6\xed\x7d\xd1\x81\x5a\xbf\x62\xa7\x60\xe4'
assert log_hash.digest() == b'\x33\xa7\x5e\xae\xeb\x8d\xf8\xe8\xad\x5e\x54\xa2\xfd\x6a\x11\xa3'
assert my_gps.start_logging('test.txt', mode="append")
for GSV_sentence in test_GSV:
for y in GSV_sentence:
@ -369,7 +384,7 @@ def test_logging():
with open('test.txt', 'rb') as log_file:
log_hash = hashlib.md5()
log_hash.update(log_file.read())
assert log_hash.digest() == b'\xc5\xf7\x2f\x7d\x4a\xee\xe3\x7d\x1c\x0c\x57\xc0\xe6\x68\x4a\x63'
assert log_hash.digest() == b'\xa4\x16\x79\xe1\xf9\x30\x0e\xd9\x73\xc8\x43\xc4\xa4\x0f\xe4\x3b'
def test_pretty_print():