UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. Jarsa
    J
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Groups 0

    Jarsa

    @Jarsa

    1
    Reputation
    3
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Jarsa Unfollow Follow

    Best posts made by Jarsa

    • Get GPS coordinates via terminal or python?

      What is the (easiest) way to get current location or information about last known location using cli-command or python script? I am trying to write my first app for phones, so help is needed 🙂

      posted in App Development
      J
      Jarsa

    Latest posts made by Jarsa

    • RE: Get GPS coordinates via terminal or python?

      Thank you both! This was more like a pre-app planning and testing ideas thing 🙂

      I didn't know if there is a whoami type of command to location. So I checked the Utrack and quickly writed my own whereami-script.

      Here is the code if someone needs it.

      #!/usr/bin/env python3
      # -*- coding: utf-8 -*-
      
      import subprocess
      
      
      def whereami():
          print('Searching...')
          latitude = ''
          longitude = ''
          for line in get_data():
              if 'latitude' in line.decode("utf-8").lower():
                  latitude = line.decode("utf-8")
              if 'longtide' in line.decode("utf-8").lower():
                  longitude = line.decode("utf-8") 
              if latitude and longitude:
                  print('Location:\n {}\n {}'.format(latitude, longitude))
                  break
                  
      def get_data():
          cmd = "sudo test_gps"
          gps_data = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
          
          while True:
              line = gps_data.stdout.readline().rstrip()
              if not line:
                  break
              yield line
                             
      if __name__=='__main__':
          whereami()
      
      posted in App Development
      J
      Jarsa
    • Get GPS coordinates via terminal or python?

      What is the (easiest) way to get current location or information about last known location using cli-command or python script? I am trying to write my first app for phones, so help is needed 🙂

      posted in App Development
      J
      Jarsa