Example #1
0
  def __init__(self, *args, **kwargs):
    try:
      update = kwargs.pop('update')
    except KeyError:
      update = True
    self.console_output = OutputStream()
    sys.stdout = self.console_output
    sys.stderr = self.console_output
    self.log_file = None
    log = kwargs.pop('log')
    reset = kwargs.pop('reset')
    try:
      self.link = serial_link.SerialLink(*args, **kwargs)
      self.link.add_callback(ids.PRINT, self.print_message_callback)
      self.link.add_callback(ids.DEBUG_VAR, self.debug_var_callback)
      # Setup logging
      if log:
        log_name = serial_link.generate_log_filename()
        self.log_file = open(log_name, 'w+')
        print "Logging at %s." % log_name
        self.link.add_global_callback(serial_link.default_log_callback(self.log_file))
        if reset:
          self.link.send_message(ids.RESET, '')

      settings_read_finished_functions = []

      self.tracking_view = TrackingView(self.link)
      self.solution_view = SolutionView(self.link)
      self.baseline_view = BaselineView(self.link)
      self.observation_view = ObservationView(self.link,
                                              name='Rover', relay=False)
      self.observation_view_base = ObservationView(self.link,
                                              name='Base', relay=True)
      self.system_monitor_view = SystemMonitorView(self.link)

      self.update_view = UpdateView(self.link, prompt=update)
      settings_read_finished_functions.append(self.update_view.compare_versions)

      self.settings_view = \
          SettingsView(self.link, settings_read_finished_functions)
      self.update_view.settings = self.settings_view.settings

      self.python_console_env = {
          'send_message': self.link.send_message,
          'link': self.link,
      }
      self.python_console_env.update(self.tracking_view.python_console_cmds)
      self.python_console_env.update(self.solution_view.python_console_cmds)
      self.python_console_env.update(self.baseline_view.python_console_cmds)
      self.python_console_env.update(self.observation_view.python_console_cmds)
      self.python_console_env.update(self.system_monitor_view.python_console_cmds)
      self.python_console_env.update(self.update_view.python_console_cmds)
      self.python_console_env.update(self.settings_view.python_console_cmds)
    except:
      import traceback
      traceback.print_exc()
Example #2
0
    def __init__(self, port=serial_link.DEFAULT_PORT):
        self.console_output = OutputStream()

        self.link = serial_link.SerialLink(port)
        self.link.add_callback(serial_link.MSG_PRINT,
                               self.print_message_callback)

        self.tracking_view = TrackingView(self.link)
        self.almanac_view = AlmanacView(self.link)
        self.solution_view = SolutionView(self.link)

        self.flash = flash.Flash(self.link)
        self.flash.start()
        self.python_console_env = {
            'send_message': self.link.send_message,
            'link': self.link,
            'flash': self.flash
        }
        self.python_console_env.update(self.tracking_view.python_console_cmds)
        self.python_console_env.update(self.almanac_view.python_console_cmds)
        self.python_console_env.update(self.solution_view.python_console_cmds)
Example #3
0
    if args.stm and args.m25:
        parser.error("Only one of -s or -m options may be chosen")
        sys.exit(2)
    elif not args.stm and not args.m25:
        parser.error("One of -s or -m options must be chosen")
        sys.exit(2)
    ihx = IntelHex(args.file)

    # Create serial link with device
    print "Waiting for device to be plugged in ...",
    sys.stdout.flush()
    found_device = False
    while not found_device:
        try:
            link = serial_link.SerialLink(serial_port,
                                          baud=baud,
                                          use_ftdi=args.ftdi,
                                          print_unhandled=False)
            found_device = True
        except KeyboardInterrupt:
            # Clean up and exit
            link.close()
            sys.exit()
        except:
            # Couldn't find device
            time.sleep(0.01)
    print "link successfully created."
    link.add_callback(ids.PRINT, serial_link.default_print_callback)

    # Reset device if the payload is running
    link.send_message(ids.RESET, '')
Example #4
0
#!/usr/bin/env python

import sys, os, time
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'scripts'))
import serial_link

link = serial_link.SerialLink()

link.add_callback(serial_link.MSG_PRINT, serial_link.default_print_callback)

data = ''.join(map(chr, range(0, 22)))

try:
    while True:
        time.sleep(0.02)
        link.send_message(0x22, data)
except KeyboardInterrupt:
    pass
finally:
    link.close()
  parser = argparse.ArgumentParser(description='Acquisition Monitor')
  parser.add_argument("-f", "--ftdi",
                      help="use pylibftdi instead of pyserial.",
                      action="store_true")
  parser.add_argument('-p', '--port',
                      default=[serial_link.DEFAULT_PORT], nargs=1,
                      help='specify the serial port to use.')
  args = parser.parse_args()
  serial_port = args.port[0]

  print "Waiting for device to be plugged in ...",
  sys.stdout.flush()
  found_device = False
  while not found_device:
    try:
      link = serial_link.SerialLink(serial_port, use_ftdi=args.ftdi)
      found_device = True
    except KeyboardInterrupt:
      # Clean up and exit.
      link.close()
      sys.exit()
    except:
      # Couldn't find device.
      time.sleep(0.01)
  print "link with device successfully created."
  link.add_callback(ids.PRINT, serial_link.default_print_callback)

  acq_results = AcqResults(link)

  # Wait for ctrl+C before exiting.
  try:
Example #6
0
    def __init__(self, *args, **kwargs):
        try:
            update = kwargs.pop('update')
        except KeyError:
            update = True

        self.console_output = OutputStream()
        sys.stdout = self.console_output
        sys.stderr = self.console_output

        try:
            self.link = serial_link.SerialLink(*args, **kwargs)
            self.link.add_callback(ids.PRINT, self.print_message_callback)

            self.link.add_callback(ids.DEBUG_VAR, self.debug_var_callback)

            settings_read_finished_functions = []

            self.tracking_view = TrackingView(self.link)
            self.almanac_view = AlmanacView(self.link)
            self.solution_view = SolutionView(self.link)
            self.baseline_view = BaselineView(self.link)
            self.observation_view = ObservationView(self.link,
                                                    name='Rover',
                                                    relay=False)
            self.observation_view_base = ObservationView(self.link,
                                                         name='Base',
                                                         relay=True)
            self.system_monitor_view = SystemMonitorView(self.link)
            self.simulator_view = SimulatorView(self.link)
            self.settings_view = SettingsView(self.link)

            if update:
                self.ocu = OneClickUpdate(self.link, self.console_output)
                settings_read_finished_functions.append(self.ocu.start)

            self.settings_view = \
                SettingsView(self.link, settings_read_finished_functions)

            if update:
                self.ocu.point_to_settings(self.settings_view.settings)

            self.python_console_env = {
                'send_message': self.link.send_message,
                'link': self.link,
            }
            self.python_console_env.update(
                self.tracking_view.python_console_cmds)
            self.python_console_env.update(
                self.almanac_view.python_console_cmds)
            self.python_console_env.update(
                self.solution_view.python_console_cmds)
            self.python_console_env.update(
                self.baseline_view.python_console_cmds)
            self.python_console_env.update(
                self.observation_view.python_console_cmds)
            self.python_console_env.update(
                self.system_monitor_view.python_console_cmds)
        except:
            import traceback
            traceback.print_exc()
Example #7
0
            p.n_sats) + "\n"
    print(gps_data_string)
    f = open('piksi_data.txt', 'w+')
    f.write(gps_data_string)
    f.close()


try:
    f = open('piksi_data.txt', 'w+')
    f.close()

except:
    print("Could not open file\n")
    exit()

try:
    link = serial_link.SerialLink(port="/dev/ttyUSB0")
except:
    print("No device found\n")
    exit()

link.add_callback(sbp.SBP_POS_LLH, pos_callback)
print("Reading data from piksi\n")

try:
    while True:
        time.sleep(60)
except:
    link.close()
    print("Exiting\n")