Index: src/python/bin/gnuboat-log-converter
===================================================================
--- src/python/bin/gnuboat-log-converter	(revision 0c140820a3fdec4bf886430511bfab47f3ccebf6)
+++ src/python/bin/gnuboat-log-converter	(revision cef09b2d71cb456528b56141971636a26fed18ac)
@@ -34,5 +34,7 @@
 
 regex_nmea_sentence = re.compile(r"^([^\$!]{0,})([\$!]{1}[\w]{2}[\w]{3}[^\*]+\*[\da-zA-Z]+)$")
-regex_nmea_position = re.compile(r"^([0-9]+)([0-9]{2}\.[0-9]+)$")
+regex_nmea_sentence_without_checksum = re.compile(r"^([^\$!]{0,})([\$!]{1}[\w]{2}[\w]{3}[^\*]+)\*[\da-zA-Z]+$")
+regex_nmea_position_latitude = re.compile(r"^([0-9]{2})([0-9]{2}\.[0-9]+)$")
+regex_nmea_position_longitude = re.compile(r"^([0-9]{3})([0-9]{2}\.[0-9]+)$")
 
 def toFloat(string, current_row):
@@ -46,13 +48,13 @@
            return 0
 
-def nmeaToDecimalDegrees(nmea_value, current_row):
-    global regex_nmea_position
+def nmeaLatitudeToDecimalDegrees(nmea_value, current_row):
+    global regex_nmea_position_latitude
 
     if toFloat(nmea_value, current_row) == 0:
         return 0
 
-    matches = regex_nmea_position.match(nmea_value)
+    matches = regex_nmea_position_latitude.match(nmea_value)
     if matches is None:
-        print('INFO: Failed to convert position value from line {} into decimal degrees: {}'.format(current_row, nmea_value))
+        print('INFO: Failed to convert latitude position value from line {} into decimal degrees: {}'.format(current_row, nmea_value))
         return
     decimalDegrees = toFloat(matches.group(1), current_row)
@@ -60,6 +62,21 @@
     return decimalDegrees + (decimalMinutes / 60.0)
 
-def convertToCsv(input_file_path, output_file_path, errors_ignore, strip_time):
+def nmeaLongitudeToDecimalDegrees(nmea_value, current_row):
+    global regex_nmea_position_longitude
+
+    if toFloat(nmea_value, current_row) == 0:
+        return 0
+
+    matches = regex_nmea_position_longitude.match(nmea_value)
+    if matches is None:
+        print('INFO: Failed to convert longitude position value from line {} into decimal degrees: {}'.format(current_row, nmea_value))
+        return
+    decimalDegrees = toFloat(matches.group(1), current_row)
+    decimalMinutes = toFloat(matches.group(2), current_row)
+    return decimalDegrees + (decimalMinutes / 60.0)
+
+def convertToCsv(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time):
     global regex_nmea_sentence
+    global regex_nmea_sentence_without_checksum
 
     try:
@@ -87,5 +104,10 @@
     for line in input_file:
         line = line.strip()
-        matches = regex_nmea_sentence.match(line)
+        if checksums_fix:
+            matches = regex_nmea_sentence_without_checksum.match(line)
+            pynmea_parse_check = False
+        else:
+            matches = regex_nmea_sentence.match(line)
+            pynmea_parse_check = True
         if matches is None:
             print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row))
@@ -95,5 +117,5 @@
                 sys.exit(4)
         else:
-            nmea_sentence = pynmea2.parse(matches.group(2))
+            nmea_sentence = pynmea2.parse(matches.group(2), check=pynmea_parse_check)
             if nmea_sentence.sentence_type == 'RMC':
                 if last_row is not None:
@@ -101,7 +123,7 @@
                 last_row = {'datetime': '{} {}'.format(nmea_sentence.datestamp, nmea_sentence.timestamp),
                             'gps_status': nmea_sentence.status,
-                            'latitude': nmeaToDecimalDegrees(nmea_sentence.lat, current_row),
+                            'latitude': nmeaLatitudeToDecimalDegrees(nmea_sentence.lat, current_row),
                             'latitude_direction': nmea_sentence.lat_dir,
-                            'longitude': nmeaToDecimalDegrees(nmea_sentence.lon, current_row),
+                            'longitude': nmeaLongitudeToDecimalDegrees(nmea_sentence.lon, current_row),
                             'longitude_direction': nmea_sentence.lon_dir,
                             'speed_over_ground': toFloat(nmea_sentence.spd_over_grnd, current_row),
@@ -119,6 +141,7 @@
     input_file.close()
 
-def convertToNmea0183(input_file_path, output_file_path, errors_ignore, strip_time):
+def convertToNmea0183(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time):
     global regex_nmea_sentence
+    global regex_nmea_sentence_without_checksum
 
     try:
@@ -138,5 +161,10 @@
     for line in input_file:
         line = line.strip()
-        matches = regex_nmea_sentence.match(line)
+        if checksums_fix:
+            matches = regex_nmea_sentence_without_checksum.match(line)
+            pynmea_parse_check = False
+        else:
+            matches = regex_nmea_sentence.match(line)
+            pynmea_parse_check = True
         if matches is None:
             print('INFO: Failed to parse nmea sentence ({}) at line {}\n'.format(line, current_row))
@@ -146,5 +174,5 @@
                 sys.exit(4)
         else:
-            nmea_sentence = pynmea2.parse(matches.group(2))
+            nmea_sentence = pynmea2.parse(matches.group(2), check=pynmea_parse_check)
             output_string = str(nmea_sentence)
             if not strip_time and matches.group(1):
@@ -154,11 +182,9 @@
     input_file.close()
     
-def convertToGpx(input_file_path, output_file_path, errors_ignore, strip_time):
-    global regex_nmea_sentence
-    
+def convertToGpx(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time):
     # make sure, nmea input file, does not have timestamps in front of the nmea
     # sentences
     [nmea_without_timestamps_handle, nmea_without_timestamp_file_path] = tempfile.mkstemp(text=True)
-    convertToNmea0183(input_file_path, nmea_without_timestamp_file_path, errors_ignore, True)
+    convertToNmea0183(input_file_path, nmea_without_timestamp_file_path, errors_ignore, checksums_fix, True)
     
     subprocess.call(['gpsbabel', '-i', 'nmea', '-f', nmea_without_timestamp_file_path, '-o', 'gpx', '-F', output_file_path])
@@ -182,4 +208,6 @@
     parser.add_argument('-i', '--ignore-errors', dest='errors_ignore', action='store_false',
                         help='Ignore any errors reading the log file')
+    parser.add_argument('-c', '--checksums-fix', dest='checksums_fix', action='store_true',
+                        help='Ignore all checksums (and replace them with a new correct one, if needed)')
     parser.add_argument('input_file', metavar='input_file_path', type=str,
                         help='File to be converted (input)')
@@ -203,4 +231,7 @@
         errors_ignore = arguments.errors_ignore
         
+    if arguments.checksums_fix is not None:
+        checksums_fix = arguments.checksums_fix
+        
     if arguments.strip_time is not None:
         strip_time = arguments.strip_time
@@ -209,5 +240,5 @@
         print('ERROR: No input file specified')
         sys.exit(2)
-    elif not os.path.exists(arguments.input_file):
+    #elif not os.path.exists(arguments.input_file):
         print('ERROR: Specified input file does not exists: {}'.format(arguments.input_file))
         sys.exit(3)
@@ -225,9 +256,9 @@
 
     if output_format == Format.CSV.value: 
-        convertToCsv(input_file_path, output_file_path, errors_ignore, strip_time)
+        convertToCsv(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time)
     elif output_format == Format.NMEA0183.value:
-        convertToNmea0183(input_file_path, output_file_path, errors_ignore, strip_time)
+        convertToNmea0183(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time)
     elif output_format == Format.GPX.value:
-        convertToGpx(input_file_path, output_file_path, errors_ignore, strip_time)
+        convertToGpx(input_file_path, output_file_path, errors_ignore, checksums_fix, strip_time)
     else:
         print('ERROR: Undefined output format!\n')
