public void run() {
          if (service != null && service.isRunning() && service.queueEmpty()) {
            queueCommands();

            double lat = 0;
            double lon = 0;
            double alt = 0;
            final int posLen = 7;
            if (mGpsIsStarted && mLastLocation != null) {
              lat = mLastLocation.getLatitude();
              lon = mLastLocation.getLongitude();
              alt = mLastLocation.getAltitude();

              StringBuilder sb = new StringBuilder();
              sb.append("Lat: ");
              sb.append(String.valueOf(mLastLocation.getLatitude()).substring(0, posLen));
              sb.append(" Lon: ");
              sb.append(String.valueOf(mLastLocation.getLongitude()).substring(0, posLen));
              sb.append(" Alt: ");
              sb.append(String.valueOf(mLastLocation.getAltitude()));
              gpsStatusTextView.setText(sb.toString());
            }
            if (prefs.getBoolean(ConfigActivity.UPLOAD_DATA_KEY, false)) {
              // Upload the current reading by http
              final String vin = prefs.getString(ConfigActivity.VEHICLE_ID_KEY, "UNDEFINED_VIN");
              Map<String, String> temp = new HashMap<String, String>();
              temp.putAll(commandResult);
              ObdReading reading =
                  new ObdReading(lat, lon, alt, System.currentTimeMillis(), vin, temp);
              new UploadAsyncTask().execute(reading);

            } else if (prefs.getBoolean(ConfigActivity.ENABLE_FULL_LOGGING_KEY, false)) {
              // Write the current reading to CSV
              final String vin = prefs.getString(ConfigActivity.VEHICLE_ID_KEY, "UNDEFINED_VIN");
              Map<String, String> temp = new HashMap<String, String>();
              temp.putAll(commandResult);
              ObdReading reading =
                  new ObdReading(lat, lon, alt, System.currentTimeMillis(), vin, temp);
              myCSVWriter.writeLineCSV(reading);
            }
            commandResult.clear();
          }
          // run again in period defined in preferences
          new Handler().postDelayed(mQueueCommands, ConfigActivity.getObdUpdatePeriod(prefs));
        }