def write_ini_file(file_name, port='/dev/ttyUSB0', baud=115200):
    '''
    Write setting from an ini file to the Multi

    Args:
        file_name: file name of the ini file
        port: serial port [default='/dev/ttyUSB0']
        baud: baud rate [default=115200]

    Returns:
        None
    '''

    print('Reading from {} at {}'.format(port, baud))

    with PySerialDriver(port, baud) as driver:
        with Handler(Framer(driver.read, driver.write,
                            verbose=True)) as source:

            parser = configparser.ConfigParser()
            parser.optionxform = str
            with open(file_name, 'r') as f:
                parser.read_file(f)

            source.add_callback(settings_callback, SBP_MSG_SETTINGS_READ_RESP)

            for section, settings in parser.items():
                print('\nSECTION: {}'.format(section))
                for setting, value in settings.items():
                    print('{} = {}'.format(setting, value))
                    write(source, section, setting, value)

            source(MsgSettingsSave())
Exemple #2
0
  def enable_piksi_sim(self, save=True):
    if not self.framer:
      return False

    section = "simulator"
    name    = "enabled"
    value   = "True"
    msg = MsgSettingsWrite(setting='%s\0%s\0%s\0' % (section, name, value))
    self.framer(msg)
    if save:
      msg = MsgSettingsSave()
      self.framer(msg)
    return True
Exemple #3
0
  def toggle_base_pos_broadcast(self, value=False, save=True):
    if not self.framer:
      return False

    section = "surveyed_position"
    name    = "broadcast"
    settingValue   = "False"
    
    if value:
      settingValue = "True"

    print "module_SBPUDPBroadcast: Broadcast base pos location: ", settingValue

    msg = MsgSettingsWrite(setting='%s\0%s\0%s\0' % (section, name, settingValue))
    self.framer(msg)
    if save:
      msg = MsgSettingsSave()
      self.framer(msg)
    return True
Exemple #4
0
  def set_base_pos_location(self, lat, lon, alt, save=True):
    '''
    assumes lat, lon, alt are already strings in the decimal degrees
    '''
    if not self.framer:
      return False

    print "module_SBPUDPBroadcast: Setting base pos location: ", lat, lon, alt

    section = "surveyed_position"
    msg = MsgSettingsWrite(setting='%s\0%s\0%s\0' % (section, "surveyed_lat", lat))
    self.framer(msg)
    msg = MsgSettingsWrite(setting='%s\0%s\0%s\0' % (section, "surveyed_lon", lon))
    self.framer(msg)
    msg = MsgSettingsWrite(setting='%s\0%s\0%s\0' % (section, "surveyed_alt", alt))
    self.framer(msg)
    if save:
      msg = MsgSettingsSave()
      self.framer(msg)
    return True
Exemple #5
0
 def save(self):
     """Save settings to flash"""
     self.link(MsgSettingsSave())
Exemple #6
0
 def _settings_save_button_fired(self):
     self.link(MsgSettingsSave())
Exemple #7
0
 def save(self):
     self.link(MsgSettingsSave())