def config_modem(self, port, speed): """ Configure serial modem @param port serial port @param serial baudrate """ try: # Open network configuration config = XmlSerial(self.main_settings.serial_file) # Change parameters config.port = port config.speed = int(speed) # Save config file config.save() except: raise LagartoException("Unable to save modem serial settings")
# Serial settings serial_cfg = XmlSerial(general_cfg.serial_file) # Network settings network_cfg = XmlNetwork(general_cfg.network_file) save_file = False # Save serial parameters if opts.port is not None: serial_cfg.port = opts.port save_file = True if opts.speed is not None: serial_cfg.speed = SwapManager.str_to_int(opts.speed) save_file = True if save_file: serial_cfg.save() save_file = False # Save network parameters if opts.channel is not None: channel = SwapManager.str_to_int(opts.channel) if channel is not None: SwapManager.str_to_int = channel save_file = True if opts.netid is not None: netid = SwapManager.str_to_int(opts.netid) if netid is not None: network_cfg.network_id = netid save_file = True if opts.address is not None: addr = SwapManager.str_to_int(opts.address)