--- ubxtool.orig	2018-10-19 12:45:52.000000000 -0700
+++ ubxtool	2018-11-18 16:35:45.000000000 -0800
@@ -2068,6 +2068,7 @@ class gps_io(object):
         "Initialize class"
 
         Serial = serial_class
+        Serial_v3 = Serial.VERSION.split('.')[0] >= '3'
         # buffer to hold read data
         self.out = b''
 
@@ -2127,6 +2128,9 @@ class gps_io(object):
             # configure the serial connections (the parameters refer to
             # the device you are connecting to)
 
+            # pyserial Ver 3.0+ changes writeTimeout to write_timeout
+            # Using the wrong one causes an error
+            write_timeout_arg = 'write_timeout' if Serial_v3 else 'writeTimeout'
             try:
                 self.ser = Serial.Serial(
                     baudrate=opts['input_speed'],
@@ -2137,10 +2141,7 @@ class gps_io(object):
                     stopbits=Serial.STOPBITS_ONE,
                     # read timeout
                     timeout=0.05,
-                    # pyserial Ver 3.0+ changes writeTimeout to write_timeout
-                    # just set both
-                    write_timeout=0.5,
-                    writeTimeout=0.5,
+                    **{write_timeout_arg: 0.5}
                 )
             except Serial.serialutil.SerialException:
                 # this exception happens on bad serial port device name
--- zerk.orig	2018-10-19 12:46:11.000000000 -0700
+++ zerk	2018-11-18 16:35:45.000000000 -0800
@@ -1402,6 +1402,7 @@ class gps_io(object):
         "Initialize class"
 
         Serial = serial_class
+        Serial_v3 = Serial.VERSION.split('.')[0] >= '3'
         # buffer to hold read data
         self.out = b''
 
@@ -1460,6 +1461,9 @@ class gps_io(object):
             # configure the serial connections (the parameters refer to
             # the device you are connecting to)
 
+            # pyserial Ver 3.0+ changes writeTimeout to write_timeout
+            # Using the wrong one causes an error
+            write_timeout_arg = 'write_timeout' if Serial_v3 else 'writeTimeout'
             try:
                 self.ser = Serial.Serial(
                     baudrate=opts['input_speed'],
@@ -1470,10 +1474,7 @@ class gps_io(object):
                     stopbits=Serial.STOPBITS_ONE,
                     # read timeout
                     timeout=0.05,
-                    # pyserial Ver 3.0+ changes writeTimeout to write_timeout
-                    # just set both
-                    write_timeout=0.5,
-                    writeTimeout=0.5,
+                    **{write_timeout_arg: 0.5}
                 )
             except Serial.serialutil.SerialException:
                 # this exception happens on bad serial port device name